ofxiPhoneImagePicker has a deallocation bug/crash - also needs some cleanup
To stop it from crashing on exit I had to comment out this line in ofxiPhoneImagePicker.mm:
//--------------------------------------------------------------
- (void)dealloc {
_imagePicker.delegate = nil;
//_imagePicker.cameraOverlayView = nil;
[_imagePicker.view removeFromSuperview];
[_imagePicker release];
Other issues:
- The class is quite clunky to use, where you are using bool variables to see if the image has changed and there isn't an easy way to reset the picker.
- Needs cleanup and changes to make it be a bit more OF / friendly. ( why can't it return an ofImage or at least ofPixels ? )
- The current example could use some love and it uses a pointer instead of an object for some reason.
- Would be good to also have an example for image picking from library vs image picking from camera.
Cross-referencing #1717
Also See http://forum.openframeworks.cc/index.php/topic,11230.msg50737.html#msg50737
Might also be good to show how to save a photo to the library as well.
@ofTheo, ive found the UIImagePickerController component very hard to work with across different devices... it seems to behave differently on iphone and ipad and across different iOS versions. the last time i did some updates to ofxiPhoneImagePicker it was a nightmare to work with.
as an alternative ive written a class that allows the user to take photos using AVFoundation and i have been using it on a bunch of projects, but still need to wrap it up for OF... i'll try to get it ready soon.
it would be good to move away from UIImagePickerController and use AVFoundation instead.
L.
okay - sounds good! Thanks for looking into it.
It could be that this code is quite old and so the error creeped in that way.
@julapy that sounds really good, I've used UIImagePicker for a couple of universal projects and yes it is a bit of nightmare to work with, even though ofxiPhoneImagePicker has lots of use full methods in it I prefer to build my own image picker in plain Objective-C code, I'm not an expert but I think taking the native AVFoundation route will be the best for the OF community
Indeed UIImagePickerController can be a little bit misleading as some of their behaviour rely on dismissing the controller after the media(images, music, etc) has been loaded. Most of the crashes I have experienced when using it are related with this. @julapy: are you implementing any of the class protocols?
In regards with the best way to develop OFW++iOS further, I need to agree with Nardove that objective-C is the best way to go. Take for instance GLKit which uses a native view as the drawing canvas for openGL. One question for the developers: is OFW-IOS arc-compatible? Maybe a good architecture would be to keep OFW as a static library that compiles against an arc-enabled project, or to create a wrapper around the main OFW functions and expose them to a more native iOS syntax: [self setup] [self update] [self draw] etc etc.
The advantage of using this approach would be that: 1-It would be easier to interchange UIKit controllers with OFW. 2-No memory leak problems. Seriously, ARC is amazing! 3-I am curious if it would allow a friendlier openGLES 2 architecture...
My two cents!
@julapy any update on this? Since it's listed as both critical and part of milestone 0.7.4 it'd be helpful to know if we're going to be doing the UIImagePicker -> AVFoundation switch now and also where to focus contribution energy for this bug.
+1 for AVFoundation though.
+1 for AVFoundation.
Any progress on this ?
hey @ofTheo and @julapy any updates on this? what kind of help do you need to resolve this issue?
hi @kylemcdonald, i haven't done much more on the AVFoundation version unfortunately... im dedicating the bugfix weekend to re-writting ofxiPhoneSoundStream atm, which is coming along well. this is still probably a couple days of work and testing, and i'll try to get it done soon.
@julapy any chance you could post the AVFoundation image picker code? I could do the OF wrapping if you like.
thanks! Theo
hey @ofTheo, yeah let me have a dig around for it. the thing is, the code for grabbing a photo and grabbing a video is very similar... so i was thinking the same code can be used for image picking and video grabbing. but just need some time to put it all together.
Pushing back issues without assignee to 0.8.1.
I think for now I am going to try and fix the issues listed at the top for 0.8.2 - We can always update the code later if needed.