Here is an example with OpenCV:
#include <cv.h>
#include <highgui.h>
int
main(int argc, char **argv)
{
cv::VideoCapture capture(argv[1]);
if (capture.grab())
{
cv::Mat_<char> frame;
capture.retrieve(frame);
}
return 0;
}
It has not been tested, but I cannibalized it from some existing working code, so you do not need to wait long for it to work.
cv::Mat_<unsigned char>essentially a byte array. If you really need something explicitly type unsigned char *, then you can malloc the space of the appropriate size and iterate over the matrix with
You can convert cv::Matto an array of bytes using pixel positions ( cv::Mat_::at()) or iterators ( cv::Mat_::begin()and friends).
There are many reasons why libraries rarely provide image data as a simple pointer, for example:
- , . .
- ( - RGB-, ?) .
- ( ..).
, , .