CMSampleBufferRef
画像を特定のサイズにトリミングしようとしています。私は5つのステップを作っています - 1. 2から取得PixelBuffer
. 3にSampleBuffer
変換. これまでのところ、ステップ4で問題が発生しています-画像をレンダリングして戻します(この時点を超えてチェックできません)バッファには何もレンダリングされません(同じものを使用してチェックし、戻り値としてNULLを取得します)。ヒントや助けをいただければ幸いです。PixelBuffer
CIImage
CIImage
CIImage
PixelBuffer
PixelBuffer
SampleBuffer
PixelBuffer
CIImage imageWithCVPixelBuffer
CGRect cropRect = CGRectMake(0, 0, 640, 480);
CIImage *ciImage = [CIImage imageWithCVPixelBuffer:(CVPixelBufferRef)CMSampleBufferGetImageBuffer(sampleBuffer)]; //options: [NSDictionary dictionaryWithObjectsAndKeys:[NSNull null], kCIImageColorSpace, nil]];
ciImage = [ciImage imageByCroppingToRect:cropRect];
CVPixelBufferRef pixelBuffer;
CVPixelBufferCreate(kCFAllocatorSystemDefault, 640, 480, kCVPixelFormatType_32BGRA, NULL, &pixelBuffer);
CVPixelBufferLockBaseAddress( pixelBuffer, 0 );
CIContext * ciContext = [CIContext contextWithOptions: nil];
[ciContext render:ciImage toCVPixelBuffer:pixelBuffer];
CVPixelBufferUnlockBaseAddress( pixelBuffer, 0 );
CMSampleTimingInfo sampleTime = {
.duration = CMSampleBufferGetDuration(sampleBuffer),
.presentationTimeStamp = CMSampleBufferGetPresentationTimeStamp(sampleBuffer),
.decodeTimeStamp = CMSampleBufferGetDecodeTimeStamp(sampleBuffer)
};
CMVideoFormatDescriptionRef videoInfo = NULL;
CMVideoFormatDescriptionCreateForImageBuffer(kCFAllocatorDefault, pixelBuffer, &videoInfo);
CMSampleBufferRef oBuf;
CMSampleBufferCreateForImageBuffer(kCFAllocatorDefault, pixelBuffer, true, NULL, NULL, videoInfo, &sampleTime, &oBuf);