views:

399

answers:

4

Every time the camera of the iPhone captures a new image, I want to modify it and then display it on the iPhone screen. In other way: how to modify in real time the video stream from the iPhone camera?
I need a method who is called every time when a new image comes from the camera.

Thanks for your help! :-)

EDIT: what I want to do is like augmented reality: while I'm taking a video, every image is modified, and is showed in real time on the iPhone screen.

A: 

You could capture an image with the UIImagePickerController's takePicture method and draw your modified version to the cameraOverlayView.

You get the picture recorded as a result of the takePicture message from the UIImagePicker's delegate in a imagePickerController:didFinishPickingMediaWithInfo:. From the dictionary supplied to that method, you can get the original image which you modify and draw to the overlay.

Here is an example for using the cameraOverlayView. You should be able to re-use the captured image from your delegate for drawing your overlay view.

VoidPointer
Thanks, this will help me!But your are talking about taking a picture, and modify it. What I want is to take a video, modify in real time every image of this video, and show the result in real time on the iphone screen. Like Apps that do augmented reality. Sorry if I wasn't clear...
thomas
I have not tried it myself, but can you try to call takePicture repeatedly and update your overlay based on the captured image as fast as possible? Depending on the complexity of what you want to show in the augmented view this may or may not work. For HUD-type displays it may be enough... if you want to render a full-motion display based on the incoming video I fear that's not possible.
VoidPointer
A: 

You cannot process the camera's image data in real time. THere is no API to do this. File a request with Apple using their bug tracker. Many of us have done this already. More requests might lead to this being possible.

St3fan
So how this App is done: http://www.youtube.com/watch?v=wt96OomJY9A ? Because we can see on this video that the images from the camera are used in real time.
thomas
Maybe they use `UIGetScreenImage` .. it seems that it is now ok to use that undocumented call. See http://www.tuaw.com/2009/12/15/apple-relents-and-is-now-allowing-uigetscreenimage-for-app-st/Just know that it is far from realtime. It is just a screenshot. It is pretty fast though, but I don't hink you can do 20fps.
St3fan
A: 

Many augmented reality apps do not actually modify the image but just overlay information based on what they think is on the screen from input from the accelerometer and compass. If this is the kind of AR you are looking to do then try looking at ARKit.

Jon Steinmetz
A: 

Oh, yes, just use an overlay view then. You were talking about modifying the video stream, which is clearly not needed.

St3fan