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
  #16  
Old 07-08-2009, 02:29 PM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
SurfaceBuffer Hacks?

Um... Does anyone try to fix this callback on iPhone 3.0? We are so close to the solution to getting the raw frame once again in 2.2 ...

Here is what we have used in 2.2


Code:
static int __camera_callbackHook(CameraDeviceRef cameraDevice,int a,CoreSurfaceBufferRef coreSurfaceBuffer,int b) {

..

}
Code:
- (void)install_camera_callbackHook {
	char *p = NULL;
	object_getInstanceVariable(cameraController,"_camera",(void**)&p);
	if (!p) return;
	
	if (!original_camera_callback) {
		FUNC_camera_callback *funcP = (FUNC_camera_callback*)p;
		original_camera_callback = *(funcP+37);
		(funcP+37)[0] = __camera_callbackHook;
	}
}
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #17  
Old 07-08-2009, 02:59 PM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts

That's my next step...
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #18  
Old 07-17-2009, 01:38 AM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Full screen camera preview

Can someone help here help me up something?
I m now creating a camera app on os 3.0,
i was able to preview the camera,
but i cant resize the camera view,
can someone give me some sample code?
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #19  
Old 07-18-2009, 03:01 AM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
cannot preview using cameraController

Hi,

I'm having the problem.
I cannot preview the camera on 3.0

I created the project using Window-Based-Application template,
and i added the code in appDelegate.h/m file.

In camAppDelegate.h, if i write "id <PLCameraControllerDelegate> _delegate;",
gcc said "error: cannot find protocol declaration for PLCameraControllerDelegate".
So, i wrote "id _delegate;". Is this wrong?


camAppDelegate.h
Code:
#import <UIKit/UIKit.h>

@class AVCapture, PLPreviewView;

@interface PLCameraController : NSObject
{
    AVCapture *_avCapture;
    PLPreviewView *_previewView;
    BOOL _isPreviewing;
    BOOL _isLocked;
    int _cameraMode;
    int _captureOrientation;
    int _focusCount;
    int _autofocusCount;
    unsigned int _previousSimpleRemotePriority;
    id /*<PLCameraControllerDelegate>*/ _delegate;
    double _startTime;
    struct {
        unsigned int supportsVideo:1;
        unsigned int supportsAccurateStillCapture:1;
        unsigned int supportsFocus:1;
        unsigned int capturingVideo:1;
        unsigned int deferStopPreview:1;
        unsigned int deferStartVideoCapture:1;
        unsigned int inCall:1;
        unsigned int continuousAutofocusDuringCapture:1;
        unsigned int focusDisabled:1;
        unsigned int focusedAtPoint:1;
        unsigned int wasInterrupted:1;
        unsigned int resumePreviewing:1;
        unsigned int isReady:1;
        unsigned int didSetPreviewLayer:1;
        unsigned int didNotifyCaptureEnded:1;
        unsigned int dontShowFocus:1;
        unsigned int isChangingMode:1;
        unsigned int lowResolutionCapture:1;
        unsigned int delegateModeDidChange:1;
        unsigned int delegateTookPicture:1;
        unsigned int delegateReadyStateChanged:1;
        unsigned int delegateVideoCaptureDidStart:1;
        unsigned int delegateVideoCaptureDidStop:1;
        unsigned int delegateVideoAdded:1;
        unsigned int delegateFocusFinished:1;
    } _cameraFlags;
}

+ (id)sharedInstance;
- (id)init;
- (void)dealloc;
- (void)_inCallStatusChanged:(BOOL)fp8;
- (BOOL)inCall;
- (void)_setIsReady;
- (BOOL)isReady;
- (BOOL)canCaptureVideo;
- (int)cameraMode;
- (void)_setCameraMode:(int)fp8 force:(BOOL)fp12;
- (void)setCameraMode:(int)fp8;
- (void)_applicationSuspended;
- (void)_applicationResumed;
- (void)_tookPicture:(struct CGImage *)fp8 jpegData:(struct __CFData *)fp12 imageProperties:(struct __CFDictionary *)fp16;
- (void)_tookPhoto:(id)fp8;
- (void)_previewStarted:(id)fp8;
- (void)_previewStopped:(id)fp8;
- (void)_setVideoPreviewLayer;
- (BOOL)_setupCamera;
- (void)viewDidAppear;
- (void)_tearDownCamera;
- (void)setDelegate:(id)fp8;
- (id)delegate;
- (id)previewView;
- (void)startPreview;
- (void)_destroyAVCapture;
- (void)stopPreview;
- (void)resumePreview;
- (BOOL)supportsAccurateStillCapture;
- (void)capturePhoto:(BOOL)fp8;
- (BOOL)isCapturingVideo;
- (void)_captureStarted:(id)fp8;
- (id)_createPreviewImage;
- (void *)_createPreviewIOSurface;
- (void)_captureCompleted:(id)fp8;
- (void)_didStopCapture;
- (void)_wasInterrupted:(id)fp8;
- (void)_interruptionEnded:(id)fp8;
- (BOOL)canStartVideoCapture;
- (BOOL)startVideoCaptureAtPath:(id)fp8;
- (void)_stopVideoCaptureAndPausePreview:(id)fp8;
- (void)stopVideoCaptureAndPausePreview:(BOOL)fp8;
- (id)videoCapturePath;
- (BOOL)focusAtPoint:(struct CGPoint)fp8;
- (void)restartAutoFocus;
- (void)autofocus;
- (void)lockFocus;
- (BOOL)isFocusing;
- (void)setDontShowFocus:(BOOL)fp8;
- (void)setFocusDisabled:(BOOL)fp8;
- (void)setCaptureAtFullResolution:(BOOL)fp8;
- (void)_commonFocusFinished;
- (void)_focusOperationFinished;
- (void)_autofocusOperationFinished;
- (void)_focusCompleted:(id)fp8;
- (void)_focusWasCancelled:(id)fp8;
- (void)_focusStarted:(id)fp8;
- (void)_focusHasChanged:(id)fp8;
- (int)videoCaptureOrientation;
- (void)irisWillClose;
- (void)_serverDied:(id)fp8;

@end


@interface camAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
	PLCameraController *cameraController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;

@end
camAppDelegate.m
Code:
#import "camAppDelegate.h"

@implementation camAppDelegate

@synthesize window;

- (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");
}

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
	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)];
	[window addSubview:previewView];
	[cameraController performSelector:@selector(startPreview)];
	sleep(2);
	
       // Override point for customization after application launch
    [window makeKeyAndVisible];
}


- (void)dealloc {
    [window release];
    [super dealloc];
}
@end
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #20  
Old 07-20-2009, 11:09 AM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts

What if you write:

Code:
@class AVCapture, PLPreviewView;
@protocol PLCameraControllerDelegate;
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #21  
Old 07-20-2009, 06:45 PM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks for the reply.

I added the @protocol code in the header file
and I also added [previewView retain]; in camAppDelegate.m.

Then I can preview the camera!

Thanks!

Last edited by hokuson; 07-20-2009 at 07:35 PM..
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #22  
Old 07-23-2009, 07:19 AM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

Hello All,

Did somebody found any successful way to Surface-callback installation? How to get the raw data from the video flow?

Thanks
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #23  
Old 07-23-2009, 10:34 AM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Video capture

Hi,

I set "CameraMode" to 1, and "canCaptureVideo" returned TRUE.
After that, I'm calling "startVideoCaptureAtPath" method,
then "isCapturingVideo" returns TRUE.

But, delegate doesn't get called.
I'm not sure what's wrong.

Code:
-(void)updateUI:(id)timer
{	
	if([cameraController performSelector:@selector(canCaptureVideo)]){
		NSLog(@"can capture video!");
	}
	
	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory = [paths objectAtIndex:0];
	[cameraController performSelector:@selector(startVideoCaptureAtPath:) withObject:documentsDirectory];
	
	if([cameraController performSelector:@selector(isCapturingVideo)]){
		NSLog(@"isCapturingVideo");
	}
}

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
    application.statusBarHidden = YES;
	self.cameraController = [(id)objc_getClass("PLCameraController") performSelector:@selector(sharedInstance)];
	[cameraController setDelegate:self];
	UIView *previewView = [cameraController performSelector:@selector(previewView)];
	[window addSubview:previewView];
	
	[cameraController performSelector:@selector(startPreview)];
 	[cameraController performSelector:@selector(setCameraMode:) withObject:1];
    // Override point for customization after app launch    
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
	
	[NSTimer scheduledTimerWithTimeInterval:5
									 target:self 
								   selector:@selector(updateUI:)
								   userInfo:0 
									repeats:NO];
}


-(void)cameraController:(id)sender
	   addedVideoAtPath:(NSString *)path
	 withPreviewSurface:(id)surface
			   metadata:(id)meta
		 wasInterrupted:(BOOL)interrupt
{
	NSLog(@"getVideo!!");
}

-(void)cameraControllerVideoCaptureDidStart:(id)sender {
	NSLog(@"cameraControllerVideoCaptureDidStart");
}
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #24  
Old 07-24-2009, 03:46 AM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Video Image

> Did somebody found any successful way to Surface-callback
> installation? How to get the raw data from the video flow?

Look in "camAppDelegate.h" (one of the Hokuson previous post) at the functions:

- (id)_createPreviewImage;
- (void *)_createPreviewIOSurface;

perhaps is what you are looking for.

_createPreviewImage should return an UIImage.
_createPreviewIOSurface should return a CoreSurfaceBuffer.

Good luck
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #25  
Old 07-24-2009, 07:51 AM
What's Jailbreak?
 
Join Date: Jul 2009
Device + Firmware: iPhone 2G 3.0
Operating System: OS X 10.5.7
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Capturing a photo

Hi all!

I've been following this thread for a while. You guys seems to have figured it out, but I can't seem to get this approach to work.. I'm trying to capture a photo on an iPhone 2G on firmware 3.0.

My readyStateChanged delegate gets called if I do a [cameraController _setIsReady]; and my modeDidChange gets called if I do a [cameraController _setCameraMode:0 force:TRUE]; - so my delegates doesn't seem to be the problem.

I just can't get isReady to return YES and my tookPicture delegate never gets called.

I don't need a preview on the screen or anything else, I just need it to capture a photo and call the tookPicture delegate.

(NSLog indicates that my call to capturePhoto takes about 2 seconds, so I know it does something, I just wish it would let me know what )

Code:
@interface Scratch: UIApplication
{
	id cameraController;
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;

@end /* @interface Scratch */

@implementation Scratch

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

- (void)cameraController:(id)sender tookPicture:(UIImage*)picture withPreview:(UIImage*)preview jpegData:(NSData*)rawData imageProperties:(struct __CFDictionary *)imageProperties {
	NSLog(@"tookPicture");
}

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

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

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

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

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

- (void)applicationDidFinishLaunching:(NSNotification*)aNotification {
	freopen([@"/tmp/scratchlog.txt" fileSystemRepresentation], "w", stderr);
	NSLog(@"applicationDidFinishLaunching");


	cameraController = [(id)objc_getClass("PLCameraController") performSelector:@selector(sharedInstance)];
	[cameraController setDelegate:self];
// 	[cameraController setCameraMode: 0];
//	[cameraController _setCameraMode:0 force:TRUE]; // Will trigger modeDidChange delegate
	[cameraController setFocusDisabled:YES];
	[cameraController setDontShowFocus:YES];
	[cameraController setCaptureAtFullResolution:YES];
//	[cameraController _setIsReady]; // Will trigger readyStateChanged delegate

	NSLog(@"CameraMode: %d", [cameraController cameraMode]);
	NSLog(@"isReady: %d", [cameraController isReady]);
	
	NSLog(@"Starting preview");
	[cameraController startPreview];
	
	NSLog(@"isReady: %d", [cameraController isReady]);

	NSLog(@"Sleeping");
	sleep(2);
	NSLog(@"isReady: %d", [cameraController isReady]);
	
	NSLog(@"Capturing photo");
	[cameraController capturePhoto:NO];

	NSLog(@"Stopping preview");
	[cameraController stopPreview];
}

int main (int argc, char **argv) {
	int ret;
	NSAutoreleasePool *pool;
	
	pool = [ [ NSAutoreleasePool alloc ] init ];
	ret = UIApplicationMain (argc, argv, @"Scratch", @"Scratch");
	[pool release];
	
	return ret;
}

@end /* @implementation Scratch */
What is it that I am missing? Any help would be appreciated!
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #26  
Old 07-24-2009, 08:26 AM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
video capture

Hi troffmo5

The UIImage returned from _createPreviewImage is a screen capture image, not a raw data.
So, if there are another layers on the camera layer, they are also captured.

Do you have any idea to get raw image?

Thanks!

Last edited by hokuson; 07-24-2009 at 10:49 AM..
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #27  
Old 07-24-2009, 09:38 AM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts

Hi troffmo5

Yes, _createPreviewImage is a screen capture, so if you have a navigation bar or a tool bar, they will appear on the image, I have tried also with _createPreviewIOSurface and it is the same, it's a screen capture.

Also, both functions return, what it seems, a preprocessed image/buffer, so the size is way too big than the size of the raw data buffer...

But, yes I think that's a solution, but at least, for my app, I really need the raw data :-(

Thanks
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #28  
Old 07-27-2009, 06:45 PM
What's Jailbreak?
 
Join Date: Jul 2009
Device + Firmware: iPhone 3G S
Operating System: iPhone OS 3.0
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

Hi,

This is a great thread and have been following it for a while. I wanted to modify the raw video frames that the user records before saving it to disk. I did my own investigation and I feel that this isn't possible WHILE the user is actually taking the video. It seems this is the case because the PLCameraController (using AVCapture) starts/stops/pauses recording and saves the video to a particular URL on its own. All it gives are delegate methods of notifications of these actions. Thus, it is not possible to access the video frame by frame and modify them while recording.

Can someone confirm if this is true?

If it is, then all we can do is postprocess the video (stored in tmp/capture/capturedvideo.mov). Thus, can someone point me to a good library to read an mov file frame by frame and re-write it? I tried opencv but it doesn't handle audio..

Thanks,
Ankit.
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #29  
Old 07-28-2009, 10:03 AM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts

Hi,

I was able to modify every frame but with the old SurfaceBuffer hack, by reading the raw buffer. With the 3.0 and those delegates, I don't think you can modified them.

But, you can do it if you use the function _createPreviewIOSurface, as stated in a previous post, but you have to verify if you can use it for your app, and if you can use a screen capture.

Thanks
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #30  
Old 07-29-2009, 09:54 AM
What's Jailbreak?
 
Join Date: Jul 2009
Device + Firmware: iPhone 3G + 3.0
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Black Preview Problem

Hi,

first of all this Thread is great! You gave me hope and support when i was about to surrender :-)
I'm just having a small problem reproducing the code from hokuson 's post.
I used his approach in exactly the same way but I don't get a preview screen. Just for a split second the camera-preview appears once after launching the app and than the screen goes black. Except for the white bar at the bottom.

There is just one thing that I am not quite sure about. I read in another post : Mobile Augmented Reality: iPhone:Using PLCameraController how to use the PLCameraController header and added the private framework in /Developer/Platforms/iPhoneOS.platform/ Developer/SDKs/iPhoneOS2.0.sdk/System/Library/
PrivateFrameworks/PhotoLibrary.framework

I also tried the 3.0.sdk version but i get the same result.

Does Anybody have a clue or can tell me if this is the right way to utilize the PLCameraController header?

Thanks a lot

bas

Last edited by basm; 07-29-2009 at 09:59 AM..
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 02:38 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 / / Top