I am using new logitech camera c920 for my project to do object recognition .
My camera can support H264 codec and can display H264 HD output.
But How I can set CODEC type as H264 in my below code to get out put as H264 DECODED STREAM
by using OpenCV instruction .
I am capturing video by using below logic : ref:this link
#include "opencv2/opencv.hpp"
using namespace cv;
int main(int, char**)
{
VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) // check if we succeeded
return -1;
for(;;)
{
Mat frame;
cap >> frame; // get a new frame from camera
imshow("display", frame);
if(waitKey(30) >= 0) break;
}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;
}
imencode
to encode to memory or create aVideoWriter
class with a FOURCC code. But many precompiled openCV distributions dont support H.264 encoding as far as I know, so you might have to compile it on your own with x264 libs enabled. – Mickacap >> frame
already delivers DECODED images. Do you want to encode it or do you want to get the encoded stream directly from camera? I dont think that is possible with openCV functions, maybe your camera drivers give you fitting methods?!? – Micka