CameraCapture.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #pragma once
  2. #import <AVFoundation/AVFoundation.h>
  3. #if UNITY_HAS_IOSSDK_11_0
  4. #define UNITY_HAS_COLORANDDEPTH_CAMERA 1
  5. #else
  6. #define UNITY_HAS_COLORANDDEPTH_CAMERA 0
  7. #endif
  8. @interface CameraCaptureController : NSObject<AVCaptureVideoDataOutputSampleBufferDelegate
  9. #if UNITY_HAS_COLORANDDEPTH_CAMERA
  10. , AVCaptureDataOutputSynchronizerDelegate
  11. #endif
  12. >
  13. - (bool)initCapture:(AVCaptureDevice*)device;
  14. - (bool)initCapture:(AVCaptureDevice*)device preset:(NSString*)preset fps:(float)fps;
  15. - (void)setCaptureFPS:(float)fps;
  16. #if UNITY_HAS_COLORANDDEPTH_CAMERA
  17. - (bool)initColorAndDepthCameraCapture:(AVCaptureDevice*)device preset:(NSString*)preset fps:(float)fps isDepth:(bool)isDepth;
  18. - (void)initColorAndDepthCameraCaptureSession;
  19. - (void)clearColorAndDepthCameraCaptureSession;
  20. - (void)captureOutput:(AVCaptureOutput*)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection*)connection;
  21. - (void)depthDataOutput:(AVCaptureDepthDataOutput*)captureDepthOutput didOutputDepthData:(AVDepthData*)depthData timestamp:(CMTime)timestamp connection:(AVCaptureConnection*)connection;
  22. - (void)dataOutputSynchronizer:(AVCaptureDataOutputSynchronizer *)synchronizer didOutputSynchronizedDataCollection:(AVCaptureSynchronizedDataCollection *)synchronizedDataCollection;
  23. + (NSMutableArray<CameraCaptureController*>*)getActiveColorAndDepthCameraControllers;
  24. + (void)addColorAndDepthCameraController:(CameraCaptureController*)controller;
  25. + (void)removeColorAndDepthCameraController:(CameraCaptureController*)controller;
  26. + (void)clearColorAndDepthCameraControllers;
  27. + (CameraCaptureController*)findColorAndDepthCameraController:(AVCaptureDevice*)device isDepth:(bool)isDepth;
  28. #endif
  29. - (void)capturePixelBufferToMemBuffer:(uint8_t*)dst;
  30. - (int)isCVTextureFlipped;
  31. + (BOOL)focusPointSupported:(AVCaptureDevice*)captureDevice withFocusMode:(AVCaptureFocusMode)focusMode;
  32. - (int)setFocusPointWithX:(float)x Y:(float)y;
  33. - (int)setFocusPoint;
  34. - (void)start;
  35. - (void)pause;
  36. - (void)stop;
  37. @property (nonatomic, retain) AVCaptureDevice* captureDevice;
  38. @property (nonatomic, retain) AVCaptureSession* captureSession;
  39. @property (nonatomic, retain) AVCaptureDeviceInput* captureInput;
  40. @property (nonatomic, retain) AVCaptureVideoDataOutput* captureOutput;
  41. #if UNITY_HAS_COLORANDDEPTH_CAMERA
  42. @property (nonatomic, retain) AVCaptureDepthDataOutput* captureDepthOutput;
  43. @property (nonatomic, retain) AVCaptureDataOutputSynchronizer* captureSynchronizer;
  44. #endif
  45. - (float)pickAvailableFrameRate:(float)fps;
  46. @end
  47. enum WebCamKind
  48. {
  49. kWebCamWideAngle = 1,
  50. kWebCamTelephoto = 2,
  51. kWebCamColorAndDepth = 3,
  52. };
  53. @interface CameraCaptureDevice : NSObject
  54. - (bool)isColorAndDepthCaptureDevice;
  55. - (WebCamKind)getKind;
  56. - (void)fillCaptureDeviceResolutions;
  57. - (NSString*)pickPresetFromWidth:(int)w height:(int)h;
  58. - (bool)initCaptureForController:(CameraCaptureController*)controller width:(int)w height:(int)h fps:(float)fps isDepth:(bool)isDepth;
  59. + (bool)initialized;
  60. + (void)createCameraCaptureDevicesArray;
  61. + (void)addCameraCaptureDevice:(AVCaptureDevice*)device;
  62. @end