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
  #31  
Old 07-30-2009, 10:39 AM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts

Hi bas,

Can you post your camera code? It would be easy to find something.

There are other solutions in this thread, maybe one of them could work for you.
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #32  
Old 07-30-2009, 04:39 PM
What's Jailbreak?
 
Join Date: Jul 2009
Device + Firmware: iPhone 3G + 3.0
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Thanks for the support

I figured out my mistake

I'm new to Objective C and didn't know what the retain methode is used for, or how to use it. But after reading How To's about the NSObject Class i figured out that the retain method return a pointer to the object and that i had to use it like:

cameraController = [cameraController retain];

Here is the code from hokuson 's post with the changes described in this thread:

camAppDelegate.h

Code:
#import <UIKit/UIKit.h>

@class AVCapture, PLPreviewView;

@protocol PLCameraControllerDelegate;

@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 = [cameraController retain];
	[cameraController setDelegate:self];
	[cameraController setFocusDisabled:YES];
	[cameraController setCaptureAtFullResolution:NO];
	[cameraController setDontShowFocus:YES];

	UIView *previewView = [cameraController performSelector:@selector(previewView)];
	
	[window addSubview:previewView];
	
	[cameraController performSelector:@selector(startPreview)];
	[cameraController performSelector:@selector(setCameraMode:) withObject:0];
	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
  #33  
Old 07-31-2009, 07:18 AM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts

I've used your code but I only get a blank screen - am I supposed to do something in the MainWindow.xib?
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #34  
Old 07-31-2009, 07:28 AM
What's Jailbreak?
 
Join Date: Jul 2009
Device + Firmware: iPhone 3G + 3.0
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post

if with blank screen you mean a white screen than you did not include the private framework as described in Mobile Augmented Reality: iPhone:Using PLCameraController

i did not change the MainWindow.xib. Just used the "Window-based Application" Template within Xcode.
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
The Following User Says Thank You to basm For This Useful Post:
DrMembrane (07-31-2009)
  #35  
Old 08-17-2009, 11:57 PM
What's Jailbreak?
 
Join Date: Aug 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
object_getInstanceVariable returning nil

Hi,

Great thread.
I've been trying to work the camera out on a new 3GS, but met several problems.
Getting the camera controller seems to work, as in:
Quote:
self.cameraController = [objc_getClass("PLCameraController") sharedInstance];
but when I try getting the controller's _camera variable, as in:
Quote:
char *p = NULL;
object_getInstanceVariable(cameraController,"_came ra",(void**)&p);
if (!p) return NULL;
I keep getting nil in p.

Anybody has any idea what I might be doing wrong, or whether this approach doesn't always work?

Thanks guys,
Nate.
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #36  
Old 08-18-2009, 10:59 AM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts

Hi Nate,

The _camera variable was removed from the new SDK 3.0, that's also the reason why the SurfaceBuffer hack stopped working.

You should try any other of the solutions in this thread.

Thanks!
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #37  
Old 08-18-2009, 05:09 PM
What's Jailbreak?
 
Join Date: Aug 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Screen blanking after a couple of frames

Hi rilocr, thanks for your reply.
I found out I was indeed trying to access the non-existing member _camera, looking at the old header.
However, If I'm not wrong, the posts on this thread were only successful at previewing the image, which I managed. What I need is the actual raw video data (rather than a single photo) for further processing.
Perhaps I'm missing on something, but is there any solution to this for the 3.0 SDK so far?

Last edited by natios; 08-18-2009 at 05:42 PM..
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #38  
Old 08-18-2009, 06:12 PM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts

Well, I have not found a solution on 3.0 similar to the SurfaceBuffer hack on 2.2.1.

But, as stated in a previous post, I think you can used one of this functions:

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

Both return a screen capture, but I think is the closest to the raw buffer data.

For my app, I used the createPreviewIOSurface which returns a CoreSurfaceBufferRef similar to the 2.2.1 hack.

That was my workaround, until someone finds how to get the real raw buffer data.
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #39  
Old 08-18-2009, 06:26 PM
What's Jailbreak?
 
Join Date: Aug 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts

What event do you use to access the surface buffer then?
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #40  
Old 08-19-2009, 10:32 AM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts

I just call the _createPreviewIOSurface function inside a thread
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #41  
Old 08-19-2009, 06:15 PM
What's Jailbreak?
 
Join Date: Aug 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts

I tried to do it from a timer called function.

Code:
- (void)frame
{
	CoreSurfaceBufferRef coreSurfaceBuffer = [cameraController performSelector:@selector(_createPreviewIOSurface)];
	uii = [cameraController performSelector:@selector(_createPreviewImage)];
	
	if (!coreSurfaceBuffer) 
		return;
	
		Surface *surface = [[Surface alloc]initWithCoreSurfaceBuffer:coreSurfaceBuffer];
		[surface lock];
		unsigned int height = surface.height;
		unsigned int width = surface.width;
		unsigned int alignmentedBytesPerRow = (width * 4);
		if (!readblePixels) {
			readblePixels = CGBitmapAllocateData(alignmentedBytesPerRow * height);
			NSLog(@"alloced readablepixels");
		}
		unsigned int bytesPerRow = surface.bytesPerRow;
		void *pixels = surface.baseAddress;
		for (unsigned int j = 0; j < height; j++) {
			memcpy(readblePixels + alignmentedBytesPerRow * j, pixels + bytesPerRow * j, bytesPerRow);
		}
		previewWidth = width;
		previewHeight = height;
		pixelDataLength = alignmentedBytesPerRow * height;
		previewBytesPerRow = alignmentedBytesPerRow;
		[surface unlock];
		[surface release];
}	

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
	cameraController = [(id)objc_getClass("PLCameraController") performSelector:@selector(sharedInstance)];
	[cameraController setDelegate:self];
	[cameraController setFocusDisabled:NO];
	[cameraController setCaptureAtFullResolution:YES];
	[cameraController setDontShowFocus:YES];
	[cameraController retain];
	
	UIView *previewView = [cameraController performSelector:@selector(previewView)];
	[previewView retain];

	[window addSubview:previewView];
	[cameraController performSelector:@selector(startPreview)];
	
	sleep(2);
	
    [window makeKeyAndVisible];
	
	self.frameTimer = [NSTimer scheduledTimerWithTimeInterval:1.0/30.0 target:self selector:@selector(frame) userInfo:nil repeats:YES];
}
I then tried to print the data in readblePixels and pixels in various ways, all giving the pixels of a black image with a white alpha channel.
Could you please post your function using the _createPreviewIOSurface or tell me where I'm going wrong?

Thanks.
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #42  
Old 08-21-2009, 09:17 AM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts

Mmm... that should work...

When I was testing with that code, I used readblePixels for creating an UIImage and I was able to see the screen shot...

The only difference with my code is this line:

CoreSurfaceBufferRef *coreSurfaceBuffer = [cameraController _createPreviewIOSurface];

Try using a pointer.
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #43  
Old 08-22-2009, 07:12 PM
What's Jailbreak?
 
Join Date: Aug 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks a lot rilocr.
I'm now able to get the data.
However, after about ten seconds the application is running, it crashes on _createPreviewIOSurface and gdb says:

Program received signal: “0”.
warning: check_safe_call: could not restore current frame

Got any idea what might mess up the stack?
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #44  
Old 08-23-2009, 11:09 AM
What's Jailbreak?
 
Join Date: Aug 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

Hello all (new to these parts),

I've successfully gotten access to the PLCameraController and am stuck where a lot of you are also stuck, trying to access raw image data.

The screen shot accessors from the PLCameraController object are unfortunetly useless to me as I need to modify the current frame, and display it. Unless I did some form of switching back and forth every frame to get a new screenshot but I am certain this would flicker like crazy.

I've tried taking the previewView UIView from the PLCameraController and rendering that but have had no luck. Here is the code I used in that attempt:

Code:
	UIGraphicsBeginImageContext(cameraView.bounds.size);
	[cameraView.layer renderInContext:UIGraphicsGetCurrentContext()];
	UIImage *contextImage = UIGraphicsGetImageFromCurrentImageContext();
	UIGraphicsEndImageContext();
	[imageView setImage:contextImage];
Unfortunetly all this does is return a completely black image. I am not even sure if this is a valid path to take for finding a fix.

Anyone have any thoughts on possibly getting camera frames from rendering previewView as a UIImage? Possible? Crazy? Wild goose hunt?
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #45  
Old 08-25-2009, 02:48 PM
What's Jailbreak?
 
Join Date: Jul 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts

Hi natios,

Try releasing the coreSurfaceBuffer variable with CFRelease(coreSurfaceBuffer).

That's the only additional code I have.
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:13 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