Ask Your Question
0

How to display full Basler USB camera view within customized window size

asked 2018-11-09 17:03:39 -0600

UT_Doug gravatar image

Hi, all, I am new to VS and OpenCV. But I think I have tried a lot to find answer to my question and ended up nothing. So I am trying to connect a Basler USB camera to computer and use visual studio and OpenCV to display the camera view. My ultimate goal is able to create a program to display the view, click capture, and then the code would capture the image and automatically do image processing on it. Now I am stuck at displaying the full field view of the camera. The default only gives me a small portion of the top left part of the full 27483840 pixel view. But if I set the window to the size 27483840, it would be too big. Do someone know how to make the window smaller, but still displays the full field view of the camera?

Thank you very much! My code:

include <iostream>

include "opencv2\opencv.hpp"

include <stdint.h>

using namespace cv; using namespace std;

int main(int, char**) { VideoCapture cap(0); if (!cap.isOpened()) { return -1; }

cap.set(CAP_PROP_FRAME_WIDTH, 3840);
cap.set(CAP_PROP_FRAME_HEIGHT, 2748);

while(1)
{
    Mat frame;
    cap >> frame;
    imshow("Webcam", frame);
    if (waitKey(30) >= 0) break;
}
return 0;

}

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-11-09 22:54:41 -0600

berak gravatar image

by default, imshow() fits the window to the image size (WINDOW_AUTOSIZE), you probably want the opposite:

namedWindow("Webcam", WINDOW_NORMAL);
while(1)
{
    Mat frame;
    cap >> frame;
    imshow("Webcam", frame);
    if (waitKey(30) >= 0) break;
}
edit flag offensive delete link more

Comments

Hi, thanks for your answer. I tried, now I can resize the window, but still it only gives me the 640480 portion of the whole camera field, which is supposed to be 38402748.

UT_Doug gravatar imageUT_Doug ( 2018-11-17 14:25:04 -0600 )edit

Hi, I have fixed by using window_normal and stating that width and height to be full resolution. Thanks a lot!

UT_Doug gravatar imageUT_Doug ( 2018-11-17 16:27:43 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-11-09 17:03:39 -0600

Seen: 668 times

Last updated: Nov 09 '18