iPhone: Get camera preview

后端 未结 3 1649
情话喂你
情话喂你 2020-12-08 12:39

I\'d like to get the image that is being displayed on the UIImagePickerController when user uses the camera. And when I get I want to process the image and display instead

3条回答
  •  囚心锁ツ
    2020-12-08 13:11

    This one is also working quite good. Use it when the camera preview is open:

    UIImage *viewImage = [[(id)objc_getClass("PLCameraController") 
                          performSelector:@selector(sharedInstance)] 
                          performSelector:@selector(_createPreviewImage)];
    

    But as far as I found out it brings the same results than the following solution which takes a 'screenshot' of the current screen:

    extern CGImageRef UIGetScreenImage();
    
    CGImageRef cgoriginal = UIGetScreenImage();
    CGImageRef cgimg = CGImageCreateWithImageInRect(cgoriginal, rect);            
    UIImage *viewImage = [UIImage imageWithCGImage:cgimg];    
    CGImageRelease(cgoriginal);                
    CGImageRelease(cgimg);  
    

    A problem I didn't still find a fix for is, how can one get the camera image very fast without any overlays?

提交回复
热议问题