Subversion Repositories seema-scanner

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 jakw 1
//
2
//  CameraQuickTime.cpp
3
//  cameraCapture
4
//
5
//  Created by Jakob Wilm on 04/04/13.
6
//  Copyright (c) 2013 Jakob Wilm. All rights reserved.
7
//
8
 
9
#include "CameraQuickTime.h"
10
#import <Foundation/Foundation.h>
11
#import <QTKit/QTKit.h>
12
 
13
static vector<CameraInfo> GetCameraList(){};
14
 
15
CameraQuickTime::CameraQuickTime(){
16
 
17
    QTCaptureDevice *video = [QTCaptureDevice defaultInputDeviceWithMediaType:QTMediaTypeVideo];
18
 
19
    NSError *error = nil;
20
    BOOL success = true;
21
 
22
    success = [video open:&error];
23
 
24
    // QTCaptureDeviceInput is the object that will use the
25
    // device as input, i.e. handle the photo-taking
26
    QTCaptureDeviceInput *input = [[QTCaptureDeviceInput alloc] initWithDevice:video];
27
 
28
    // Session handles the input and output of both objects
29
    QTCaptureSession *session = [[QTCaptureSession alloc] init];
30
 
31
    // Add our input object as input for this particular session
32
    // (the code is pretty self-explanatory)
33
    success = [session addInput:input error:&error];
34
 
35
//    // Create an object for outputing the video
36
//    // The input will tell the session object that it has taken
37
//    // some data, which will in turn send this to the output
38
//    // object, which has a delegate that you defined
39
//    output = [[QTCaptureDecompressedVideoOutput alloc] init];
40
//    
41
//    // This is the delegate. Note the
42
//    // captureOutput:didOutputVideoFrame...-method of this
43
//    // object. That is the method which will be called when
44
//    // a photo has been taken.
45
//    [output setDelegate:self];
46
 
47
    // Add the output-object for the session
48
    success = [session addOutput:output error:&error];
49
 
50
    if ( ! success || error )
51
    {
52
        NSLog(@"Did succeed in connecting output to session: %d", success);
53
        NSLog(@"Error: %@", [error localizedDescription]);
54
        return nil;
55
    }
56
 
57
    // Because the input stream is video we will be getting
58
    // many frames after each other, we take the first one
59
    // we get and store it, and don't accept any more after
60
    // we already have one
61
    currentImage = nil;
62
 
63
    [session startRunning];
64
 
65
}