Hardware:
1. Raspberry Pi 2
2. Raspberry Pi Camera
Software:
1. OpenCV 2.4.11
2. Programming with C++
I've the following trivial code that capture video from camera and displays it within window.
The frame size is always 640 x 480, trying to change the frame width and height (as shown in the remarked lines) doesn't help and it stays 640 x 480.
I'm looking for a way to change the frame width and height to 1920 x 1080 from my code (and not with the shell).
If it can be done from OpenCV or V4l2 driver it would be great
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char* argv[]) {
int rc = 0 ;
int device = 0 ;
Mat frame;
namedWindow( "Video", CV_WINDOW_AUTOSIZE ) ;
VideoCapture capture( device ) ;
if( capture.isOpened()) {
cout << "Frame size : " << capture.get(CV_CAP_PROP_FRAME_WIDTH) << " x " << capture.get(CV_CAP_PROP_FRAME_HEIGHT) << endl ;
//capture.set( CV_CAP_PROP_FRAME_WIDTH, 1920 ) ;
//capture.set( CV_CAP_PROP_FRAME_HEIGHT, 1080 ) ;
//capture.set( CV_CAP_PROP_FOURCC, CV_PROP('H','2','6','4')) ;
//capture.set( CV_CAP_PROP_FOURCC, CV_PROP('M','J','P','G')) ;
//capture.set( CV_CAP_PROP_FPS, 10 );
for( ; ; ) {
if( capture.read( frame )) {
imshow( "Video", frame );
if( waitKey( 1 ) == 27 ) {
cout << "Esc key pressed by the user" << endl ;
break ;
}
}
else {
rc = -1 ;
cout << "Cannot read frame from video stream" << endl ;
break ;
}
}
}
else {
rc = -1 ;
cout << "Cannot open the video device " << device << endl ;
}
return( rc ) ;
}