Last active
June 8, 2019 19:38
-
-
Save jebai/8108287 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) parseBuffer:(CMSampleBufferRef) sampleBuffer | |
{ | |
CVImageBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); | |
CVPixelBufferLockBaseAddress( pixelBuffer, 0 ); | |
//Processing here | |
int bufferWidth = CVPixelBufferGetWidth(pixelBuffer); | |
int bufferHeight = CVPixelBufferGetHeight(pixelBuffer); | |
unsigned char *pixel = (unsigned char *)CVPixelBufferGetBaseAddress(pixelBuffer); | |
// put buffer in open cv, no memory copied | |
cv::Mat mat = cv::Mat(bufferHeight,bufferWidth,CV_8UC4,pixel); | |
//End processing | |
CVPixelBufferUnlockBaseAddress( pixelBuffer, 0 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What encoding is this for? YUV?