iPhone: Get camera preview

可紊 提交于 2019-11-28 06:07:22

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?

The unofficial call is:

UIGetScreenImage()

which you declare above the @implementation as:

extern CGImageRef UIGetScreenImage();

There may be a documented way to do this in 3.1, but I'm not sure. If not, please please file a Radar with Apple asking them to make some kind of screen grab access public!!!

That uses your same AppleID you log in to the iPhone development portal with.

Update: This call is not yet documented, but Apple explicitly has given the OK to use it with App Store apps.

at least for now, there's no way to do this. (certainly no official documented way, and as far as I know nobody's figured out an unofficial way either.)

the camera preview data is being drawn by the OS in some way that bypasses the normal graphics methods.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!