CvCamera2.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // CvCamera2.h
  3. //
  4. // Created by Giles Payne on 2020/03/11.
  5. //
  6. #import <UIKit/UIKit.h>
  7. #import <Accelerate/Accelerate.h>
  8. #import <AVFoundation/AVFoundation.h>
  9. #import <ImageIO/ImageIO.h>
  10. #import "CVObjcUtil.h"
  11. @class Mat;
  12. @class CvAbstractCamera2;
  13. CV_EXPORTS @interface CvAbstractCamera2 : NSObject
  14. @property UIDeviceOrientation currentDeviceOrientation;
  15. @property BOOL cameraAvailable;
  16. @property (nonatomic, strong) AVCaptureSession* captureSession;
  17. @property (nonatomic, strong) AVCaptureConnection* videoCaptureConnection;
  18. @property (nonatomic, readonly) BOOL running;
  19. @property (nonatomic, readonly) BOOL captureSessionLoaded;
  20. @property (nonatomic, assign) int defaultFPS;
  21. @property (nonatomic, readonly) AVCaptureVideoPreviewLayer *captureVideoPreviewLayer;
  22. @property (nonatomic, assign) AVCaptureDevicePosition defaultAVCaptureDevicePosition;
  23. @property (nonatomic, assign) AVCaptureVideoOrientation defaultAVCaptureVideoOrientation;
  24. @property (nonatomic, assign) BOOL useAVCaptureVideoPreviewLayer;
  25. @property (nonatomic, strong) NSString *const defaultAVCaptureSessionPreset;
  26. @property (nonatomic, assign) int imageWidth;
  27. @property (nonatomic, assign) int imageHeight;
  28. @property (nonatomic, strong) UIView* parentView;
  29. - (void)start;
  30. - (void)stop;
  31. - (void)switchCameras;
  32. - (id)initWithParentView:(UIView*)parent;
  33. - (void)createCaptureOutput;
  34. - (void)createVideoPreviewLayer;
  35. - (void)updateOrientation;
  36. - (void)lockFocus;
  37. - (void)unlockFocus;
  38. - (void)lockExposure;
  39. - (void)unlockExposure;
  40. - (void)lockBalance;
  41. - (void)unlockBalance;
  42. @end
  43. ///////////////////////////////// CvVideoCamera ///////////////////////////////////////////
  44. @class CvVideoCamera2;
  45. @protocol CvVideoCameraDelegate2 <NSObject>
  46. - (void)processImage:(Mat*)image;
  47. @end
  48. CV_EXPORTS @interface CvVideoCamera2 : CvAbstractCamera2<AVCaptureVideoDataOutputSampleBufferDelegate>
  49. @property (nonatomic, weak) id<CvVideoCameraDelegate2> delegate;
  50. @property (nonatomic, assign) BOOL grayscaleMode;
  51. @property (nonatomic, assign) BOOL recordVideo;
  52. @property (nonatomic, assign) BOOL rotateVideo;
  53. @property (nonatomic, strong) AVAssetWriterInput* recordAssetWriterInput;
  54. @property (nonatomic, strong) AVAssetWriterInputPixelBufferAdaptor* recordPixelBufferAdaptor;
  55. @property (nonatomic, strong) AVAssetWriter* recordAssetWriter;
  56. - (void)adjustLayoutToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
  57. - (void)layoutPreviewLayer;
  58. - (void)saveVideo;
  59. - (NSURL *)videoFileURL;
  60. - (NSString *)videoFileString;
  61. @end
  62. ///////////////////////////////// CvPhotoCamera ///////////////////////////////////////////
  63. @class CvPhotoCamera2;
  64. @protocol CvPhotoCameraDelegate2 <NSObject>
  65. - (void)photoCamera:(CvPhotoCamera2*)photoCamera capturedImage:(UIImage*)image;
  66. - (void)photoCameraCancel:(CvPhotoCamera2*)photoCamera;
  67. @end
  68. CV_EXPORTS @interface CvPhotoCamera2 : CvAbstractCamera2<AVCapturePhotoCaptureDelegate>
  69. @property (nonatomic, weak) id<CvPhotoCameraDelegate2> delegate;
  70. - (void)takePicture;
  71. @end