Cannot read a 10-bit, 3-channel encoded video file as 10-bit
Hello all,
I'm running into a problem reading a 10-bit, 3-channel encoded video that was saved from a high definition camera we have. I checked the file using GSpot, and it is encoded using the "Optibase VideoPump 10-bit 4:2:2 Component Y'CbCr" codec (v210).
I can read in frames using OpenCV's VideoCapture class from the file. I can even display the frames just fine using OpenCV's imshow function. Unfortunately, the cv::Mat object that the frames are saved into is of an 8-bit type (CV_8UC3).
Here is the code that I am using to read the video file:
std::cout<< "Attempting to open file: "<< filename<< std::endl;
cv::VideoCapture videoIn;
videoIn.open( filename);
if( !videoIn.isOpened())
throw "Error when reading stream!";
if( !videoIn.read( frame))
return 0;
int type= frame.type(); // Returns 16 (CV_8UC3)
Like I said earlier, frames are being read and displayed, but when I check frame.type(), it returns 16 (CV_8UC3). Since I am trying to get the extra precision by using 10-bits, this is suboptimal.
Does anyone know how to actually read the frames at 10-bit?
Thanks!
-Nate
What about using:
CV_16UC3
It is 16 bits big or 6 bit bigger than 10, and it is 3 channels.
Thanks for the feedback keghn! I would love for it to read in as CV_16UC3. At 10 bit, that's actually what I would expect. Unfortunately, there does not seem to be a way to instruct the VideoCapture object to do that. At least not that I have found.
You would like to have an option like the CV_RETRIEVE_ANY_DEPTH option in the imread fuction... Doesn't the source code of the VideoCapture interface uses the imread function on a certain moment? You might be able to change it there and rebuilt it yourself.
Thanks for the suggestion StevenPuttemans! I've not dug into the inner workings of OpenCV before. I'll have to download the source code and have a look at the internals of VideoCapture later today.
Well, I downloaded the OpenCV source code and tried to figure out if there was some internal setting for VideoCapture that I could set to get it to read 10-bit video files. I couldn't find any reference to a "CV_RETRIEVE_ANY_DEPTH" setting, but the OpenCV source does have CV_LOAD_IMAGE_ANYDEPTH and IMREAD_ANYDEPTH preprocessor directives. Unfortunately, I could not track down where, if at all, these preprocessor directives might be used in VideoCapture. VideoCapture seems like it is a wrapper on top of IPL calls. Quite frankly, without a detailed system architecture diagram and writeup for OpenCV's video processing system, figuring this out is quite beyond me. At this point, I have to conclude OpenCV is not the right tool for reading and processing high-bitrate video files.
Of course, if anyone has any alternative tools to OpenCV that might be viable, please post and let me know!
Yeah digging into this is indead quite hard. You could however add a feature request on the development forum of openCV. It might encourage someone who has an idea to implement this feature.