The ModMyTM Family of Sites:
ModMyMotoModMyiModMyGphone




 
 
Register or Connect with Facebook

Discuss AppStore Apps | Browse / Search Cydia | MMi Cydia Stats




  Apple Forums & iPhone Forums, Mods, Hacks, News, Themes, Downloads, and more! | ModMyi.com > 3rd Party Apps For iPhone | iPod Touch > iPhone / iPod Touch SDK | Development Discussion
Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 06-22-2009, 10:44 AM
What's Jailbreak?
 
Join Date: Jun 2009
Device + Firmware: iPhone 3GS, 3.0
Operating System: Mac OS X 10.5.7
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
CameraController, 3GS and 3.0

Hi all,

New member here

I hope you can help with this:

On my old iPhone, I'd written a small app for time-lapse photography. I class-dumped the PhotoLibrary framework and was using the CameraController interface to take photos programmatically without any user input. The app had a configurable delay setting, producing time-lapse sets of photos that were really quite cool.

However, I've so far failed in porting the app to 3.0. I've run class-dump against the new framework and have produced the header fine... but after instantiating the CameraController class, calling startPreview and capturePhoto apparently does nothing. My cameraController callback never gets fired.

Has anyone managed to get this working?

Many thanks,
Chris
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #2  
Old 06-24-2009, 10:50 AM
Green Apple
 
Join Date: Jul 2007
Posts: 61
Thanks: 1
Thanked 10 Times in 8 Posts
Auto Focus

Is it possible for me to get a copy of that class dump? The auto focus works really well, however sometimes when shooting something close you might have to touch the screen multiple times to get a really clear picture and even then while auto focusing you will see the lens pass through the most optimal focus. I would like to write an app that will allow you to control the focus manually but see no references in the 3.0 SDK to the camera class and it's api's.

-David
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #3  
Old 06-24-2009, 08:39 PM
What's Jailbreak?
 
Join Date: Jun 2009
Device + Firmware: iPhone 3GS, 3.0
Operating System: Mac OS X 10.5.7
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks for the reply!

I've attached the PLCameraController header. I used the info here to help me generate the dumped headers.

Good luck -- and let me know if you hit upon something that might help with my problem :)

(I'm wondering if the delegate method signatures have changed. Unfortunately, the class dumps do not describe the PLCameraControllerDelegate protocol, so I don't know exactly what methods I need to implement in my delegate. There's some interesting stuff in PLCameraView.h (also attached) which seems to indicate that the delegate is indeed different for 3.0 -- see - (void)cameraController:(id)fp8 addedVideoAtPath:.. (etc) for example)

Hopefully someone will figure this out - I knew I was out of my depth when I started using writing stuff like:

Code:
	id prot = objc_getProtocol("PLCameraControllerDelegate");
	
	uint propCount;
	objc_property_t *properties = protocol_copyPropertyList(prot, &propCount);
...to try to figure out what the delegate needed to do ;) I'm still quite an objc newbie.
Attached Files
File Type: h PLCameraController.h (3.5 KB, 163 views)
File Type: h PLCameraView.h (5.1 KB, 204 views)
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #4  
Old 06-25-2009, 06:05 AM
What's Jailbreak?
 
Join Date: Jun 2009
Device + Firmware: iPhone 3GS, 3.0
Operating System: Mac OS X 10.5.7
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts

Another update...

I think my delegate implementation's actually OK... I invoked [camera _setCameraMode:0 force:TRUE]; and my cameraController:modeDidChange delegate method got called in return... so that's one thing crossed off the list!

However, try what I can, I can't get [camera isReady] to return YES.

So far, I'm just frantically calling methods and crossing my fingers! Before I call startPreview, I'm doing:

[camera setFocusDisabled:TRUE];
[camera setCaptureAtFullResolution:TRUE];
[camera _setCameraMode:0 force:TRUE];
[camera setDontShowFocus:TRUE];

Just guessing for some of those values

Perhaps I could subclass PLCameraController and try NSLogging some internal states?

(so out of my comfort-zone here... but hey, it's fun in a masochistic way!)
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #5  
Old 06-26-2009, 09:12 AM
Green Apple
 
Join Date: Jul 2007
Posts: 61
Thanks: 1
Thanked 10 Times in 8 Posts

Wow! Thanks. Yeah this is a bit out of my comfort zone too. Apple's idea of an any to follow api structure and mine differ a lot! Keep us posted on what you get working, I think I might need your help.

-David
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #6  
Old 06-28-2009, 06:37 PM
What's Jailbreak?
 
Join Date: Jun 2009
Device + Firmware: iPhone 3GS, 3.0
Operating System: Mac OS X 10.5.7
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts

Quote:
Originally Posted by Kaos2800 View Post
Wow! Thanks. Yeah this is a bit out of my comfort zone too. Apple's idea of an any to follow api structure and mine differ a lot! Keep us posted on what you get working, I think I might need your help.

-David
To be fair, we're digging around here in private frameworks ... so these interfaces weren't designed for direct use by developers and therefore official documentation is non-existent.

I've still had no luck yet. Is anyone else out there looking at using the PLCameraController private library in 3.0 on the 3GS? Any tinkerers hit on anything useful-looking?

Cheers,
Chris
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #7  
Old 07-03-2009, 04:06 PM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts

Hi,

I'm having the same issues...

So far, I have used the PLCameraViewController class, and I call the loadView method, this will display the camera view (same as the old startPreview on 2.2.1)

Regarding the capturePhoto method also not working on 3.0, I added the 7 delegate methods on my code (I have not tested removing the ones not needed), and now when calling capturePhoto, my cameraController:tookPicture:... delegate is called . But the display remains with what it appears to be a preview of the picture. Because I don't need that preview I'm trying to take the picture and not display it, but I had not luck for now. Working on this.

Hope this help you, and any other info is welcome.

Thanks!
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #8  
Old 07-07-2009, 11:39 AM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Quote:
Originally Posted by rilocr View Post
Hi,

I'm having the same issues...

So far, I have used the PLCameraViewController class, and I call the loadView method, this will display the camera view (same as the old startPreview on 2.2.1)

Regarding the capturePhoto method also not working on 3.0, I added the 7 delegate methods on my code (I have not tested removing the ones not needed), and now when calling capturePhoto, my cameraController:tookPicture:... delegate is called . But the display remains with what it appears to be a preview of the picture. Because I don't need that preview I'm trying to take the picture and not display it, but I had not luck for now. Working on this.

Hope this help you, and any other info is welcome.

Thanks!
as I can see you have some luck with camera preview on 3.0

My app was using following camera initialization on 2.2.1 and working perfectly. Please help me out with code transition to 3.0, I just need to initialize camera stream. That's it.

declarations in .h:
Code:
@interface PLCameraController : NSObject 
{ 
	CALayer *_cameraLayer; 
	struct CameraDevice *_camera; 
	struct CameraImageQueueHelper *_cameraHelper; 
	id _delegate; 
	UIView *_previewView; 
	BOOL _isPreviewing; 
	BOOL _isLocked; 
	BOOL _wasPreviewingBeforeDeviceLock; 
} 

+ (id)sharedInstance; 
- (id)init; 
- (void)dealloc; 
- (void)_setIsReady; 
- (BOOL)isReady; 
- (void)_applicationSuspended; 
- (void)_applicationResumed; 
- (void)_tookPicture:(struct __CoreSurfaceBuffer *)fp8; 
- (void)_tookPicture:(struct CGImage *)fp8 jpegData:(struct __CFData *)fp12 imageProperties:(struct __CFDictionary *)fp16; 
- (struct CameraImageQueueHelper *)_cameraHelper; 
- (BOOL)_setupCamera; 
- (void)_tearDownCamera; 
- (void)setDelegate:(id)fp8; 
- (id)delegate; 
- (struct CGRect)_cameraFrame; 
- (id)previewView; 
- (void)startPreview; 
- (void)stopPreview; 
- (void)capturePhoto; 

@end
and implementation:
Code:
PLCameraController *cam = [PLCameraController sharedInstance]; 
	camView = [cam previewView];
	[cam startPreview]; 
	[self addSubview:camView];
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #9  
Old 07-07-2009, 12:20 PM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts

On 2.2.1, I had a class that contained the PLCameraContoller and PLCameraView instance, and that class inherited from UIViewController. Now, on 3.0, I just inherited my class from PLCameraViewController found on the private API (you can have it by making a class dump).

On 2.2.1:
Code:
@interface MyClass : UIViewController {
     PLCameraController *cameraController;
     PLCameraView *cameraView;
}
On 3.0:
Code:
@interface MyClass:  PLCameraViewController {
     PLCameraController *cameraController;
}
And instead of calling the startPreview method, I just call the method loadView on PLCameraViewController, that made the camera display appear again.

On 2.2.1:
Code:
[cameraController startPreview];
On 3.0:
Code:
[self loadView];
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #10  
Old 07-07-2009, 01:40 PM
What's Jailbreak?
 
Join Date: Jun 2009
Device + Firmware: iPhone 3GS, 3.0
Operating System: Mac OS X 10.5.7
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts

Ok - I think it've got it:

Basically, I'm bypassing the header file entirely – instead instantiating the camera controller using objc_getClass.

My init code is thus:

Code:
self.cameraController = [(id)objc_getClass("PLCameraController") performSelector:@selector(sharedInstance)];
		[cameraController setDelegate:self];
		[cameraController setFocusDisabled:NO];
		[cameraController setCaptureAtFullResolution:YES];
		[cameraController setDontShowFocus:YES];
		
		UIView *previewView = [cameraController performSelector:@selector(previewView)];
		[containerView addSubview:previewView];
		[cameraController performSelector:@selector(startPreview)];
		sleep(2);
Note that cameraController is declared as (id), not as a class. Notice that I've been tinkering with some of the methods described in the header on the 3GS. They seem to be working and the log file doesn't indicate any unknown selectors. Also, I've found it necessary to sleep for a couple of seconds to allow the camera to initialise correctly (I suppose I should be handling this in the ReadyStateChanged delegate!)

I'm then taking the snapshot with a simple call:

Code:
	[cameraController capturePhoto:TRUE];
My delegate routines are:

Code:
- (void)cameraControllerReadyStateChanged:(NSNotification *)aNotification
{
    NSLog(@"cameraControllerReadyStateChanged: %@", aNotification);	
}

-(void)cameraController:(id)sender
			tookPicture:(UIImage*)picture
			withPreview:(UIImage*)preview
			   jpegData:(NSData*)rawData
		imageProperties:(struct __CFDictionary *)imageProperties
{
	
	NSLog(@"Saving and re-initing...");
	UIImageWriteToSavedPhotosAlbum(picture, self, @selector(imageSavedToPhotosAlbum: didFinishSavingWithError: contextInfo:), nil);  
	[cameraController performSelector:@selector(stopPreview)];
	[cameraController performSelector:@selector(startPreview)];
}

-(void)cameraController:(id)sender
		addedVideoAtPath:(NSString *)path
	  withPreviewSurface:(id)surface
				metadata:(id)meta
		  wasInterrupted:(BOOL)interrupt
{
	
}

-(void)cameraController:(id)sender
		  modeDidChange:(int)mode {
	NSLog(@"cameraController:modeDidChange");
}

-(void)cameraControllerVideoCaptureDidStart:(id)sender {
	NSLog(@"cameraControllerVideoCaptureDidStart");
}

-(void)cameraControllerVideoCaptureDidStop:(id)sender {
	NSLog(@"cameraControllerVideoCaptureDidStop");
}

-(void)cameraControllerFocusFinished:(id)sender {
	NSLog(@"cameraControllerFocusFinished");
}
This works correctly - the tookPicture callback fires and the image is successfully saved to the 'Camera Roll' photo album. I managed to get the camera to re-init by stopping and starting the preview after the image is saved.

Some of those callback routines relating to video capture look intriguing. But what I've got so far has put me well on the way to getting my time-lapse photography app back and working!

Hope this helps you guys!

Cheers,
Chris
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #11  
Old 07-07-2009, 02:58 PM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts

I think there's no need to reinit the camera when calling the capturePhoto method with NO as a value for the parameter. It appears that parameter is something like : (BOOL) showPreview

Code:
[cameraController capturePhoto:NO];
At least, that worked for me.
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #12  
Old 07-07-2009, 03:28 PM
IvanPK's Avatar
My iPhone is a Part of Me
 
Join Date: Apr 2008
Device + Firmware: iPhone 3G 3.0 Unlocked :)
Operating System: Aluminium Macbook Core 2 Duo 150 GB
Location: USA
Posts: 614
Thanks: 56
Thanked 45 Times in 42 Posts

If you get the time lapse application working, could you post it? I'd love to try out something of the sort.
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #13  
Old 07-07-2009, 04:01 PM
What's Jailbreak?
 
Join Date: Jun 2009
Device + Firmware: iPhone 3GS, 3.0
Operating System: Mac OS X 10.5.7
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts

Quote:
Originally Posted by rilocr View Post
I think there's no need to reinit the camera when calling the capturePhoto method with NO as a value for the parameter. It appears that parameter is something like : (BOOL) showPreview

Code:
[cameraController capturePhoto:NO];
Good spot! Behaves the same for me, too.

Quote:
Originally Posted by IvanPK View Post
If you get the time lapse application working, could you post it? I'd love to try out something of the sort.
Will do! It's basically what I've already posted... just a bit of UI to set the capture interval in seconds and use that value in a call to performSelector:afterDelay. At least, that's the idea (it's not written yet!)

Cheers,
Chris
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #14  
Old 07-08-2009, 08:32 AM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

2rilocr:

dont know how to make your approach to work. The point is that 'MyClass' is already inherited some methods from UIView, so I dont know how to organize double inheritance.

I'm trying simplest way to create an instance, like this, but app crashes immediately before start:
Code:
/*PLCameraViewController *cameraStream = [[PLCameraController alloc] init];
	[cameraStream loadView];
	[self addSubview:(UIView *)cameraStream];*/
2displaced

this approach seems working for me, but I have 11 warnings during compilation!

Check it out if I did it correct way:

I declare id *cameraController;
then describe
Code:
@class PLCameraView;

@interface PLCameraViewController : UIViewController 
{
    PLCameraView *_cameraView;
}


- (BOOL)_displaysFullScreen;
- (void)dealloc;
- (void)loadView;
- (void)viewWillDisappear:(BOOL)arg1;
- (void)viewDidAppear:(BOOL)arg1;

@end
then I used your code for camera init. Most of the warnings concerning ID pointer type. I did synthesize it and set @property (nonatomic, retain) id *cameraController;

What did I forget?

PS For some bloody reason I have imported PhotoLibrary.framework from 2.2.1 And either way I'm trying to add it from 3.0 SDK, I will eventually have 2.2.1 reference after "Reveal in Finder" command.
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #15  
Old 07-08-2009, 11:48 AM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts

Ok, just create a new project on XCode, and then add a new UIViewController subclass, let's call it MyClass. So, in the applicationDidFinishLaunching add:

Code:
MyClassView = [[MyClass alloc] initWithNibName:nil bundle:nil];
[window addSubview:[MyClassView view]];
And the MyClass.h should be like:

Code:
@interface MyClass : PLCameraViewController {

	PLCameraController	*cameraController;
}
@end
When MyClass was created, it inherited from UIViewController, I just changed it to PLCameraViewController. Also, I added the PLCameraController instance to this class, and inside the initWithNibName method I just called:

Code:
cameraController = [PLCameraController sharedInstance];
[cameraController setDelegate:self];
With only that code you should be able to see camera display on the device, next just add the 7 delegates and start taking pictures or capturing video.

Any other question just ask me,
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
Reply

  Apple Forums & iPhone Forums, Mods, Hacks, News, Themes, Downloads, and more! | ModMyi.com > 3rd Party Apps For iPhone | iPod Touch > iPhone / iPod Touch SDK | Development Discussion

Tags
3.0, cameracontroller

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Go to Top
ModMyI

All times are GMT -6. The time now is 09:19 PM. Powered by vBulletin® Version 3.8.4
If you need Dedicated Server Hosting, you should check out SingleHop. | Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.0 Copyright © 2007-09 by ModMy, LLC. All rights reserved.

iPhone News / iPhone Forums / Apple News / Apple Forums / RSS / Contact Us / / Privacy Statement / Top