OpenCV - changing camera resolution in Java

camera, java, opencv, resolution

Solution

You need to open the camera first then set it. I tried it before camera.open(0) and it just returns to standard settings, but when try setting after camera.open(0) it works.

so do this in your code

v.open(1)
boolean wset = v.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, 1280);
boolean hset = v.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, 800);

Problem

It seems that the standard method for setting the resolution on a webcam in Java opencv doesn't work. I do the following: ``` VideoCapture v = new VideoCapture(); boolean wset = v.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, 1280); boolean hset = v.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, 800); System.out.println(wset); System.out.println(hset); v.open(1); ``` Which prints: ``` > false > false ``` ...and doesn't change the camera resolution. It appears to be stuck at 640x480. I know that the camera is not at fault because I can successfully set the resolution to 1280x800 using the C++ bindings. Also - `v.getSupportedPreviewSizes()` doesn't work. It returns an error: ``` HIGHGUI ERROR: V4L2: getting property #1025 is not supported ``` Any thoughts?

Original source

Related problems