Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

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;

}