我如何使用CIPerspectiveTransform过滤器

时间:2011-12-26 12:57:26

标签: image

我想使用IOS核心图像过滤器CIPerspectiveTransform。我有资助一个功能但是当我调用这个功能时,图像从视图中消失了我无法理解为什么图像消失了?

// I have picked picture from UIImageView 
 CIImage *inputImage = [[CIImage alloc] initWithImage:getImageFOrOCR.image];

 CIFilter *filter2 = [CIFilter
                         filterWithName:@"CIPerspectiveTransform"];
    [filter2 setDefaults];
    [filter2 setValue:beginImage forKey:@"inputImage"];
    [filter2 setValue:[CIVector vectorWithX:100 Y:500 ]
               forKey:@"inputTopLeft"];
    [filter2 setValue:[CIVector vectorWithX:600 Y:500 ]
               forKey:@"inputTopRight"];
    [filter2 setValue:[CIVector vectorWithX:600 Y:0  ]
               forKey:@"inputBottomLeft"];
    [filter2 setValue:[CIVector vectorWithX:0  Y:0  ]
               forKey:@"inputBottomRight"];

    CIImage *ciImageOut = [filter2 valueForKey:@"outputImage"];


    CIContext *context = [CIContext contextWithOptions:nil];
   // set image to UIImageView
    getImageFOrOCR.image = [UIImage imageWithCGImage:
                            [context createCGImage:ciImageOut
                                                   fromRect:ciImageOut.extent]];

0 个答案:

没有答案