Ask Your Question
0

Maximum camera tablet resolution 1080p giving 640x480

asked 2019-10-14 08:50:25 -0600

updated 2019-10-14 10:49:06 -0600

Hello,

I have a tablet and the parameter of the flux video are : 1080p 16:9 30fps, that's mean the camera resolution is 1920x1080, but when i open the camera with opencv it give me always 640x480 this the code i used :

VideoCapture capq(0);
   if (!capq.isOpened())  // check if we succeeded
  { return -1;
}

Mat inputImage;
for (;;)
{
    capq >> inputImage; // get a new frame from camera
    if (waitKey(30) >= 0) break;
    while (inputImage.empty()) {
        std::cout << "Empty frame" << std::endl;
        continue;
    }
    namedWindow("Display window1", WINDOW_AUTOSIZE);
    imshow("Display window1", inputImage);
   }

I tried with this code to set the camera resolution but it's not working it's giving me 640x480

// deb set camera resolution
//cv::VideoCapture* camera, 
int max_width = 1080;
int max_height = 1920;


// Save current resolution
const int current_width = static_cast<int>(capq.get(CAP_PROP_FRAME_WIDTH));
const int current_height = static_cast<int>(capq.get(CAP_PROP_FRAME_HEIGHT));

// Get maximum resolution
capq.set(CAP_PROP_FRAME_WIDTH, 10000);
capq.set(CAP_PROP_FRAME_HEIGHT, 10000);
max_width = static_cast<int>(capq.get(CAP_PROP_FRAME_WIDTH));
max_height = static_cast<int>(capq.get(CAP_PROP_FRAME_HEIGHT));

// Restore resolution
capq.set(CAP_PROP_FRAME_WIDTH, current_width);
capq.set(CAP_PROP_FRAME_HEIGHT, current_height);

cout << "width maximale" << current_width << endl;
cout << "height maximale" << current_height << endl;

// fin  set camera resolution

Edit 1 : i used the code below, and it's working but it's giving me 1280x960 instead of 1920x1080

int max_width = 1080;
int max_height = 1920;


// Save current resolution
const int current_width = static_cast<int>(capq.get(CAP_PROP_FRAME_WIDTH));
const int current_height = static_cast<int>(capq.get(CAP_PROP_FRAME_HEIGHT));

// Get maximum resolution
capq.set(CAP_PROP_FRAME_WIDTH, 1080);
capq.set(CAP_PROP_FRAME_HEIGHT, 1920);
max_width = static_cast<int>(capq.get(CAP_PROP_FRAME_WIDTH));
max_height = static_cast<int>(capq.get(CAP_PROP_FRAME_HEIGHT));

// Restore resolution
capq.set(CAP_PROP_FRAME_WIDTH, max_width);
capq.set(CAP_PROP_FRAME_HEIGHT, max_height);

cout << "width maximale" << current_width << endl;
cout << "height maximale" << current_height << endl;

// fin  set camera resolution

I need your help and thank you.

edit retag flag offensive close merge delete

Comments

1

Yes, thank you that was the problem, now it's working.

Kitnos gravatar imageKitnos ( 2019-10-17 02:49:24 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2019-10-17 02:34:33 -0600

gino0717 gravatar image

no sure whether the problem or not but your width and height look inverse.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-10-14 08:50:25 -0600

Seen: 907 times

Last updated: Oct 14 '19