Problem in camera activities in ios4 - iphone

hi so far i have used UIImagePickerController for camera activities in IOS3. But in IOS4 the ImagePickerController is not working properly. When i tried to capture image it shows either a white image or else the app gets crashed often.
So i started using the AVCapture device for my camera activities. In this too i started facing new problems. When i capture the image in landscape the image preview shows the image to be portrait and vice versa. And some times it shows memory level warning.
Both the UIImagePickerController and the AVCapture are making problems. I want to know how to solve these problems. Else is there any other way to handle camera activities in IOS4.
Please help me friends.....

If you just want to enable the user to take photos, UIImagePickerController is the way to go. AVFoundation is quite low level and requires you to handle a lot of things yourself (e.g. compensating for the device orientation).
I've used UIImagePickerController extensively on iOS 4 and it works just fine for me. I suspect the white image/crashing problems are due to something else in your code. If you post a few code snippets we can try to figure out what's going on.

Related

How to record screen to video on iPhone with openGL (view preview layer) and UIkit elements?

I have searched everywhere and tried mixing and matching different bits of code but I haven't found anything that works or anyone with the same question.
Basically I want to be able to create video demos of iPhone apps that include standard UIKit elements and also the image coming from the camera (video preview layer). I don't want to use airPlay or iOS simulator to project onto the desktop then capture because I want to be able to make videos outside in public. I have successfully been able to video capture the screen with this code but with the video preview layer being blank. I read that its because its using openGL and what I'm capturing is from the CPU, not the GPU. I have successfully used GPUImage from Brad Larson to capture the video preview layer but it doesn't capture the rest of the UIView. I have seen code that combines both and converts to an image but I'm not sure if that would be too slow for realtime video capture. Can someone point me in the right direction?
It might not be the cleanest solution, but it will work nonetheless: did you consider jailbreaking? I hope Apple does sue me for this one but if you really want to record your screen then simply install a screen recorder. Enough options can be found: http://www.google.be/search?q=iphone+jailbreak+record+screen
And if you don't like it: recover your phone for a previous backup.
(for the record: I'm against jailbreaking and posting this from a productivity point of view)

Using xcode to access rear camera, iphone iOS5

I'm sorry if this is already answered...
All I need is how to fire up the rear facing camera and display it in an image view...no taking pictures, no accessing the photo library, just turning on the camera...simple.
I believe AVCapture is the thing to use, but anything I look into goes way deep than I need and I'm just not that smart. Any help is appreciated.
THANKS!
The AVCam sample from Apple is the best place to start. Be warned that the seemingly simple task of displaying a live video preview from the camera is non-trivial.

AVFoundation Camera Preview Screen gives wrong zoom

I'm currently developing an app that has a camera functionality, with a custom camera screen, featuring a preview screen and an overlay.
I'm using the AVFoundation classes and methods as per the eradication of UIScreenCapture.
The problem I have is that the preview data I get from AVCaptureSession is too zoomed in. If i take a picture with that screen, and another with the iPhone's default camera app, without moving the iPhone, the difference in zoom is far too much.
I need the zoom of my app to be the same as is default for iPhone camera app.
I've tried changing the AVCaptureVideoPreviewLayer.videoGravity, to any of it's 3 possible values, to no avail.
Please, any leads on this problem are truly appreciated.
Arcantos' solution was mostly correct. That will work assuming you're on an iPhone 3G (or any device with a camera that supports 640x480). An iPhone 4 may run into some issues there.
A more correct way would be to test for the availability of and apply this preset:
captureSession.sessionPreset = AVCaptureSessionPresetPhoto;
This will use the raw camera data, regardless of the native resolution.
Turned out to be a resolution issue.
It was fixed by using
myCaptureSession.sessionPreset = AVCaptureSessionPreset640x480
Note that iPhone 3g does not support that, so you have to ask wheter the device supports it
[[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo] supportsAvCaptureSessionPreset:AVCaptureSessionPreset640x480]
Is the aspect ratio of your preview pane identical to that of the camera capture data? If not, the OS may be changing the zoom to fit the data rect into your requested aspect ratio.

App is fast on 3GS but slow on 3G

I'm new to computer coding and have just finished coding an app and tested it on both 3G and 3GS. On 3GS, it worked as normal as on the simulator. However, when I tried to run it on 3G, the app becomes extremely slow. I'm not sure what's the reason and I hope someone could shed some light on me.
Generally, my app has a couple of view controller classes, with one of them being the title page, one being the main page, one is setting, etc. I used a dissolve to transition from the title page to the main page. But even this simple transition shows un-smooth performance on a 3G! My other part of the app involves zooming in to some images by scaling up the images, switching images by push or dissolve upon receiving touch events, saving photos into photo library and storing and retrieving some photos in a folder and some data in a SQlite database, each showing un-smooth actions.
Compared with some heavy graphic or heavy maths app, I think mine is pretty simple. I totally have no clue why the app would behave so slow and un-smooth that it is barely useful on a 3G. Any help/ direction would be much appreciated. Thanks for helping out.
You might want to try profiling your application with Shark to find out where the performance bottlenecks are.
I don't know how relevant it is to your case, but my game (shameless plug) MultiMaze is quite undemanding graphically, and worked beautifully on my 3GS. But when I tried it on a 3G, the frame rate dropped to a glacial 10-20 fps. I ported the whole code base from CoreGraphics to OpenGL ES, and that made a world of difference. It now runs at the limit (60 fps) on my 3GS and very close to it on the 3G.
Are you using a lot of memory? 3G has 128MB while the 3GS has 256MB RAM.
Are you getting memory warnings? In my debug builds I have an NSLog in didReceiveMemoryWarning so I can see if/when I get warnings.
EDIT: Check the size of your photos, are they resized for the iPhone screen or are they original sized?
OK, finally found the problem and got the solution. The problem was that I have about a dozens of transparent images laying on each other to form my main view. So when in any animation, the system needs to redraw on every single layer and calculate their transparent effect and so on. (actually I'm not quite sure, but that's what I think)
The solution I have is to make a temporary composite view containing of them all, and placing the composite as an image in a full screen view before starting any animation. It delays starting the fade a moment, but the fade itself is a lot smoother now.

iPhone - UIImagePickerController shows a white screen sometimes

I am using a shared instance of UIImagePickerController in my application. I am using the Camera Roll as the image source.
Sometimes when the image picker opens, instead of seeing the photos gallery, I am able to see only a blank white screen. This issue is not reproducible every time and happens only some of the times.
Has someone else faced this issue? Is it the memory usage? I checked the app with Instruments while testing on the device but memory doesn't seem to be the issue.
Thanks for any help.
The issue was caused by a memory issue. I created a shared instance of UIImagePickerController and used it throughout the app.