iphoneobjective-ciphone-4

How can I customize the frame of camera of iPhone


Can any one please help me to set the frame of camera to 320X320 frame. It should take picture of things available only in that frame. I have already spent 2 days in finding the solution please help me if any one had done it ever. Please and thanx in advance.


Solution

  • You might be confusing the terms, there are two possible ways to interpret your question, the first is that you have the full screen size of the phone, and you somehow want to just capture a part of the screen. The second is that you want the taken picture to have 320 x 320 source resolution.

    The first thing you have to understand is how the media capture.

    On the iPhone there are 4 possible outputs:

    This means you can only get something through these outputs, for your purpose you can use either the AVCaptureStillImageOutput or the AVCaptureVideoDataOutput.

    The suggestions that others have given you use the AVCaptureStillImageOutput. This is probably the easiest you should try. Here you can try one of these:

    1. You can take the full screen, and crop what you want, here you would probably have the quality set for Photo Which gives you the full screen image with the highest quality (2592x1936 for the iphone 4 for example).

    2. You change the capture quality to Medium which will take a picture with 480x360 pixels (on the iphone4) and ALSO resize the video preview layer to something the appropriate size so that it does not look so pixelated for the user. I think this is what you are looking for, since the preview layer is technically a view you can show it wherever you want on the iphone screen, and since you have lowered the quality of the input the pictures will be taken in the resolution that you set, so it should allow the pictures to be taken much more rapidly and using a lot less memory.

    Now there is another path for this, you can process the frames directly of a video input of AVCaptureVideoDataOutput, this one is a bit more complicated since you have to set your delegate to receive the frame with your desired quality and take the resolution you want, then process this frame so that it can be used.

    SOMETHING VERY IMPORTANT is that these presets are phone dependent, they will change depending on the phone current specs, I do not know if you can ask the camera for a custom preset but I believe you cant.

    You can see more about this in the official apple documentation.

    http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/04_MediaCapture.html#//apple_ref/doc/uid/TP40010188-CH5-SW2