CameraCapture.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. kWebCamUltraWideAngle = 4,
  53. };
  54. @interface CameraCaptureDevice : NSObject
  55. - (bool)isColorAndDepthCaptureDevice;
  56. - (WebCamKind)getKind;
  57. - (void)fillCaptureDeviceResolutions;
  58. - (NSString*)pickPresetFromWidth:(int)w height:(int)h;
  59. - (bool)initCaptureForController:(CameraCaptureController*)controller width:(int)w height:(int)h fps:(float)fps isDepth:(bool)isDepth;
  60. + (bool)initialized;
  61. + (void)createCameraCaptureDevicesArray;
  62. + (void)addCameraCaptureDevice:(AVCaptureDevice*)device;
  63. @end