Ask Your Question
0

iOS video processing tutorial problem

asked 2013-01-10 11:15:24 -0600

MrTJ gravatar image

I followed the iOS video processing tutorial and managed to compile and install it on the device. However when I click on the "Start" button, nothing visible happens. Apparently neither my - (void)processImage:(Mat&)image callback is never called. Could you give me some hints what could be the problem?

Some things I checked:

  • actionStart is called, and both log lines prints YES
  • the self object is valid when assigned to self.videoCamera.delegate
  • imageView is valid and visible on the screen
  • videoCamera is initialized when its start method is called

Here is the full source of my ViewController.mm:

@implementation ViewController

@synthesize videoCamera;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    self.videoCamera = [[CvVideoCamera alloc] initWithParentView:imageView];
    self.videoCamera.delegate = self;

    self.videoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionFront;
    self.videoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPreset352x288;
    self.videoCamera.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationPortrait;
    self.videoCamera.defaultFPS = 30;
    self.videoCamera.grayscaleMode = NO;

}

#pragma mark - UI Actions

- (IBAction)actionStart:(id)sender;
{
    [self.videoCamera start];
    NSLog(@"video camera running: %d", [self.videoCamera running]);
    NSLog(@"capture session loaded: %d", [self.videoCamera captureSessionLoaded]);
}

#pragma mark - Protocol CvVideoCameraDelegate

- (void)processImage:(cv::Mat&)image
{
    // Do some OpenCV stuff with the image
    cv::Mat image_copy;
    cvtColor(image, image_copy, CV_BGRA2BGR);

    // invert image
    bitwise_not(image_copy, image_copy);
    cvtColor(image_copy, image, CV_BGR2BGRA);
}

@end
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2013-01-26 16:21:48 -0600

What device are you running this on? I ran into the same problem when running it on my iPhone 3GS. I believe the problem is that it's trying to access the "front" camera when my phone doesn't have one. So this line:

self.videoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionFront;

Needs to change to:

self.videoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionBack;

And if that doesn't help, try changing the session preset to something more generic, like AVCaptureSessionPresetMedium.

HTH!

edit flag offensive delete link more
0

answered 2013-03-13 23:52:09 -0600

Hi- I get the same problem when running on a 3rd gen iPad. I've tried the two suggestions above with no luck, has anyone had this issue and solved it? It would be great to be able to download the full solution, to rule out the code.

Thanks! -Dave

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-01-10 11:15:24 -0600

Seen: 1,355 times

Last updated: Mar 13 '13