Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #import <UIKit/UIKit.h>
00032 #import <Accelerate/Accelerate.h>
00033 #import <AVFoundation/AVFoundation.h>
00034 #import <ImageIO/ImageIO.h>
00035 #include "opencv2/core/core.hpp"
00036
00038
00039 @class CvAbstractCamera;
00040
00041 @interface CvAbstractCamera : NSObject
00042 {
00043 AVCaptureSession* captureSession;
00044 AVCaptureConnection* videoCaptureConnection;
00045 AVCaptureVideoPreviewLayer *captureVideoPreviewLayer;
00046
00047 UIDeviceOrientation currentDeviceOrientation;
00048
00049 BOOL cameraAvailable;
00050 BOOL captureSessionLoaded;
00051 BOOL running;
00052 BOOL useAVCaptureVideoPreviewLayer;
00053
00054 AVCaptureDevicePosition defaultAVCaptureDevicePosition;
00055 AVCaptureVideoOrientation defaultAVCaptureVideoOrientation;
00056 NSString *const defaultAVCaptureSessionPreset;
00057
00058 int defaultFPS;
00059
00060 UIView* parentView;
00061
00062 int imageWidth;
00063 int imageHeight;
00064 }
00065
00066 @property (nonatomic, retain) AVCaptureSession* captureSession;
00067 @property (nonatomic, retain) AVCaptureConnection* videoCaptureConnection;
00068
00069 @property (nonatomic, readonly) BOOL running;
00070 @property (nonatomic, readonly) BOOL captureSessionLoaded;
00071
00072 @property (nonatomic, assign) int defaultFPS;
00073 @property (nonatomic, assign) AVCaptureDevicePosition defaultAVCaptureDevicePosition;
00074 @property (nonatomic, assign) AVCaptureVideoOrientation defaultAVCaptureVideoOrientation;
00075 @property (nonatomic, assign) BOOL useAVCaptureVideoPreviewLayer;
00076 @property (nonatomic, strong) NSString *const defaultAVCaptureSessionPreset;
00077
00078 @property (nonatomic, assign) int imageWidth;
00079 @property (nonatomic, assign) int imageHeight;
00080
00081 @property (nonatomic, retain) UIView* parentView;
00082
00083 - (void)start;
00084 - (void)stop;
00085 - (void)switchCameras;
00086
00087 - (id)initWithParentView:(UIView*)parent;
00088
00089 - (void)createCaptureOutput;
00090 - (void)createVideoPreviewLayer;
00091 - (void)updateOrientation;
00092
00093
00094 @end
00095
00097
00098 @class CvVideoCamera;
00099
00100 @protocol CvVideoCameraDelegate <NSObject>
00101
00102 #ifdef __cplusplus
00103
00104 - (void)processImage:(cv::Mat&)image;
00105 #endif
00106
00107 @end
00108
00109 @interface CvVideoCamera : CvAbstractCamera<AVCaptureVideoDataOutputSampleBufferDelegate>
00110 {
00111 AVCaptureVideoDataOutput *videoDataOutput;
00112
00113 dispatch_queue_t videoDataOutputQueue;
00114 CALayer *customPreviewLayer;
00115
00116 BOOL grayscaleMode;
00117
00118 BOOL recordVideo;
00119 AVAssetWriterInput* recordAssetWriterInput;
00120 AVAssetWriterInputPixelBufferAdaptor* recordPixelBufferAdaptor;
00121 AVAssetWriter* recordAssetWriter;
00122
00123 CMTime lastSampleTime;
00124
00125 }
00126
00127 @property (nonatomic, assign) id<CvVideoCameraDelegate> delegate;
00128 @property (nonatomic, assign) BOOL grayscaleMode;
00129
00130 @property (nonatomic, assign) BOOL recordVideo;
00131 @property (nonatomic, retain) AVAssetWriterInput* recordAssetWriterInput;
00132 @property (nonatomic, retain) AVAssetWriterInputPixelBufferAdaptor* recordPixelBufferAdaptor;
00133 @property (nonatomic, retain) AVAssetWriter* recordAssetWriter;
00134
00135 - (void)adjustLayoutToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
00136 - (void)layoutPreviewLayer;
00137 - (void)saveVideo;
00138 - (NSURL *)videoFileURL;
00139
00140
00141 @end
00142
00144
00145 @class CvPhotoCamera;
00146
00147 @protocol CvPhotoCameraDelegate <NSObject>
00148
00149 - (void)photoCamera:(CvPhotoCamera*)photoCamera capturedImage:(UIImage *)image;
00150 - (void)photoCameraCancel:(CvPhotoCamera*)photoCamera;
00151
00152 @end
00153
00154 @interface CvPhotoCamera : CvAbstractCamera
00155 {
00156 AVCaptureStillImageOutput *stillImageOutput;
00157 }
00158
00159 @property (nonatomic, assign) id<CvPhotoCameraDelegate> delegate;
00160
00161 - (void)takePicture;
00162
00163 @end