Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Buffer is of type CVImageBufferRef, which is what AVFoundation should be giving you
- //I assume it is BGRA or RGBA formatted, if it isn't, change CV_8UC4 to the appropriate format
- CVPixelBufferLockBaseAddress( Buffer, 0 );
- int bufferWidth = CVPixelBufferGetWidth(Buffer);
- int bufferHeight = CVPixelBufferGetHeight(Buffer);
- unsigned char *pixel = (unsigned char *)CVPixelBufferGetBaseAddress(Buffer);
- cv::Mat image = cv::Mat(bufferHeight,bufferWidth,CV_8UC4,pixel); //put buffer in open cv, no memory copied
- //Process image Here
- //End processing
- CVPixelBufferUnlockBaseAddress( pixelBuffer, 0 );
- for ( uint32_t y = 0; y < height; y++ )
- {
- for ( uint32_t x = 0; x < width; x++ )
- {
- bgraImage.at<cv::Vec<uint8_t,4> >(y,x)[1] = 0;
- }
- }
- cv::Mat bgraImage = cv::Mat( (int)height, (int)extendedWidth, CV_8UC4, base );
- cv::Mat grey = bgraImage.clone();
- cv::cvtColor(grey, grey, 44);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement