Joe Verbout
/
main
opencv on mbed
Embed:
(wiki syntax)
Show/hide line numbers
cap_ios.h
00001 /* For iOS video I/O 00002 * by Eduard Feicho on 29/07/12 00003 * Copyright 2012. All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright notice, 00009 * this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright notice, 00011 * this list of conditions and the following disclaimer in the documentation 00012 * and/or other materials provided with the distribution. 00013 * 3. The name of the author may not be used to endorse or promote products 00014 * derived from this software without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED 00017 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00018 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 00019 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00020 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00021 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00022 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00023 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 00024 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 00025 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 * 00027 */ 00028 00029 #import <UIKit/UIKit.h> 00030 #import <Accelerate/Accelerate.h> 00031 #import <AVFoundation/AVFoundation.h> 00032 #import <ImageIO/ImageIO.h> 00033 #include "opencv2/core.hpp" 00034 00035 //! @addtogroup videoio_ios 00036 //! @{ 00037 00038 /////////////////////////////////////// CvAbstractCamera ///////////////////////////////////// 00039 00040 @class CvAbstractCamera; 00041 00042 @interface CvAbstractCamera : NSObject 00043 { 00044 AVCaptureSession* captureSession; 00045 AVCaptureConnection* videoCaptureConnection; 00046 AVCaptureVideoPreviewLayer *captureVideoPreviewLayer; 00047 00048 UIDeviceOrientation currentDeviceOrientation; 00049 00050 BOOL cameraAvailable; 00051 BOOL captureSessionLoaded; 00052 BOOL running; 00053 BOOL useAVCaptureVideoPreviewLayer; 00054 00055 AVCaptureDevicePosition defaultAVCaptureDevicePosition; 00056 AVCaptureVideoOrientation defaultAVCaptureVideoOrientation; 00057 NSString *const defaultAVCaptureSessionPreset; 00058 00059 int defaultFPS; 00060 00061 UIView* parentView; 00062 00063 int imageWidth; 00064 int imageHeight; 00065 } 00066 00067 @property (nonatomic, retain) AVCaptureSession* captureSession; 00068 @property (nonatomic, retain) AVCaptureConnection* videoCaptureConnection; 00069 00070 @property (nonatomic, readonly) BOOL running; 00071 @property (nonatomic, readonly) BOOL captureSessionLoaded; 00072 00073 @property (nonatomic, assign) int defaultFPS; 00074 @property (nonatomic, readonly) AVCaptureVideoPreviewLayer *captureVideoPreviewLayer; 00075 @property (nonatomic, assign) AVCaptureDevicePosition defaultAVCaptureDevicePosition; 00076 @property (nonatomic, assign) AVCaptureVideoOrientation defaultAVCaptureVideoOrientation; 00077 @property (nonatomic, assign) BOOL useAVCaptureVideoPreviewLayer; 00078 @property (nonatomic, strong) NSString *const defaultAVCaptureSessionPreset; 00079 00080 @property (nonatomic, assign) int imageWidth; 00081 @property (nonatomic, assign) int imageHeight; 00082 00083 @property (nonatomic, retain) UIView* parentView; 00084 00085 - (void)start; 00086 - (void)stop; 00087 - (void)switchCameras; 00088 00089 - (id)initWithParentView:(UIView*)parent; 00090 00091 - (void)createCaptureOutput; 00092 - (void)createVideoPreviewLayer; 00093 - (void)updateOrientation; 00094 00095 - (void)lockFocus; 00096 - (void)unlockFocus; 00097 - (void)lockExposure; 00098 - (void)unlockExposure; 00099 - (void)lockBalance; 00100 - (void)unlockBalance; 00101 00102 @end 00103 00104 ///////////////////////////////// CvVideoCamera /////////////////////////////////////////// 00105 00106 @class CvVideoCamera; 00107 00108 @protocol CvVideoCameraDelegate <NSObject> 00109 00110 #ifdef __cplusplus 00111 // delegate method for processing image frames 00112 - (void)processImage:(cv::Mat&)image; 00113 #endif 00114 00115 @end 00116 00117 @interface CvVideoCamera : CvAbstractCamera<AVCaptureVideoDataOutputSampleBufferDelegate> 00118 { 00119 AVCaptureVideoDataOutput *videoDataOutput; 00120 00121 dispatch_queue_t videoDataOutputQueue; 00122 CALayer *customPreviewLayer; 00123 00124 BOOL grayscaleMode; 00125 00126 BOOL recordVideo; 00127 BOOL rotateVideo; 00128 AVAssetWriterInput* recordAssetWriterInput; 00129 AVAssetWriterInputPixelBufferAdaptor* recordPixelBufferAdaptor; 00130 AVAssetWriter* recordAssetWriter; 00131 00132 CMTime lastSampleTime; 00133 00134 } 00135 00136 @property (nonatomic, assign) id<CvVideoCameraDelegate> delegate; 00137 @property (nonatomic, assign) BOOL grayscaleMode; 00138 00139 @property (nonatomic, assign) BOOL recordVideo; 00140 @property (nonatomic, assign) BOOL rotateVideo; 00141 @property (nonatomic, retain) AVAssetWriterInput* recordAssetWriterInput; 00142 @property (nonatomic, retain) AVAssetWriterInputPixelBufferAdaptor* recordPixelBufferAdaptor; 00143 @property (nonatomic, retain) AVAssetWriter* recordAssetWriter; 00144 00145 - (void)adjustLayoutToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation; 00146 - (void)layoutPreviewLayer; 00147 - (void)saveVideo; 00148 - (NSURL *)videoFileURL; 00149 - (NSString *)videoFileString; 00150 00151 00152 @end 00153 00154 ///////////////////////////////// CvPhotoCamera /////////////////////////////////////////// 00155 00156 @class CvPhotoCamera; 00157 00158 @protocol CvPhotoCameraDelegate <NSObject> 00159 00160 - (void)photoCamera:(CvPhotoCamera*)photoCamera capturedImage:(UIImage *)image; 00161 - (void)photoCameraCancel:(CvPhotoCamera*)photoCamera; 00162 00163 @end 00164 00165 @interface CvPhotoCamera : CvAbstractCamera 00166 { 00167 AVCaptureStillImageOutput *stillImageOutput; 00168 } 00169 00170 @property (nonatomic, assign) id<CvPhotoCameraDelegate> delegate; 00171 00172 - (void)takePicture; 00173 00174 @end 00175 00176 //! @} videoio_ios 00177
Generated on Tue Jul 12 2022 16:42:37 by 1.7.2