iOS GPUImageビデオキャプチャGPUImageVideoCamera

1.色変換マトリックス
  • 標準定義:
    extern const GLfloat kColorConversion601 [];
  • フルカラー:
    extern const GLfloat kColorConversion601FullRange [];
  • 高解像度:
    extern const GLfloat kColorConversion709 [];
次に、フラグメントシェーダー
  • extern NSString * const kGPUImageYUVVideoRangeConversionForRGFragmentShaderString;
  • extern NSString * const kGPUImageYUVFullRangeConversionForLAFragmentShaderString;
  • extern NSString * const kGPUImageYUVVideoRangeConversionForLAFragmentShaderString;
3、代理店

出力するSampleBuffer

@protocol GPUImageVideoCameraDelegate <NSObject>
@optional
-(void)willOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer;
@end
第四に、拡張分析
	// 已采集的帧数
	NSUInteger numberOfFramesCaptured;
	// 采集的总帧数
    CGFloat totalFrameTimeDuringCapture;
    // 采集会话层
    AVCaptureSession *_captureSession;
	// 视频输入设备
    AVCaptureDevice *_inputCamera;
    // 音频输入设备
    AVCaptureDevice *_microphone;
    // 视频输入
    AVCaptureDeviceInput *videoInput;
    // 视频数据输出
    AVCaptureVideoDataOutput *videoOutput;

	// 停止采集
    BOOL capturePaused;
    // 输入和输出旋转方式
    GPUImageRotationMode outputRotation, internalRotation;
    // 帧渲染信号量
    dispatch_semaphore_t frameRenderingSemaphore;
        
    // yuv格式采集
    BOOL captureAsYUV;
    // 亮度纹理、色度纹理
    GLuint luminanceTexture, chrominanceTexture;
    
    // 摄像头采集协议
    __unsafe_unretained id<GPUImageVideoCameraDelegate> _delegate;
5、属性分析
	// 会话层
 	@property(readonly, retain, nonatomic) AVCaptureSession *captureSession;
 	// 采集分辨率
    @property (readwrite, nonatomic, copy) NSString *captureSessionPreset;
    // 帧率
    @property (readwrite) int32_t frameRate;
    // 前置摄像头
    @property (readonly, getter = isFrontFacingCameraPresent) BOOL frontFacingCameraPresent;
    // 后置摄像头
    @property (readonly, getter = isBackFacingCameraPresent) BOOL backFacingCameraPresent;
    // 基准
    @property(readwrite, nonatomic) BOOL runBenchmark;
    // 输入摄像头
    @property(readonly) AVCaptureDevice *inputCamera;
    // 摄像头朝向
    @property(readwrite, nonatomic) UIInterfaceOrientation outputImageOrientation;
    // 前者摄像头水平镜像,后置摄像头水平镜像
    @property(readwrite, nonatomic) BOOL horizontallyMirrorFrontFacingCamera, horizontallyMirrorRearFacingCamera;
    // 摄像头代理
    @property(nonatomic, assign) id<GPUImageVideoCameraDelegate> delegate;
6、メソッドの説明
	// 根据分辨率、摄像头朝向初始化摄像头
	-(id)initWithSessionPreset:(NSString *)sessionPreset cameraPosition:(AVCaptureDevicePosition)cameraPosition;
	// 添加音频的输入和输出
    -(BOOL)addAudioInputsAndOutputs;
    // 移除音频的输入和输出
    -(BOOL)removeAudioInputsAndOutputs;
    // 移除输入和输出设备
    -(void)removeInputsAndOutputs;
    // 开始采集
    -(void)startCameraCapture;
    // 停止采集
    -(void)stopCameraCapture;
    // 暂停采集
    -(void)pauseCameraCapture;
    // 恢复采集
    -(void)resumeCameraCapture;
    // 处理视频数据
    -(void)processVideoSampleBuffer:(CMSampleBufferRef)sampleBuffer;
    // 处理音频数据
    -(void)processAudioSampleBuffer:(CMSampleBufferRef)sampleBuffer;
    // 摄像头位置(前置/后置)
    -(AVCaptureDevicePosition)cameraPosition;
    // 视频连接
    -(AVCaptureConnection *)videoCaptureConnection;
    // 转换摄像头
    -(void)rotateCamera;
    // 平均帧时长
    -(CGFloat)averageFrameDurationDuringCapture;
    - (void)resetBenchmarkAverage;
    + (BOOL)isBackFacingCameraPresent;
    + (BOOL)isFrontFacingCameraPresent;

おすすめ

転載: blog.csdn.net/Forever_wj/article/details/108318985
おすすめ