Ask Your Question

fishy's profile - activity

2019-08-28 07:56:21 -0600 received badge  Enthusiast
2019-08-27 16:07:09 -0600 commented answer OpenCV 4.1.0 not changing brightness

The issue apparently was that VideoCapture was using the wrong backend. If I used cv2.VideoCapture(0, cv2.CAP_V4L) the c

2019-08-23 09:10:36 -0600 commented answer OpenCV 4.1.0 not changing brightness

Sure thing

2019-08-23 08:00:01 -0600 marked best answer OpenCV 4.1.0 not changing brightness

I made a program that can change the brightness/contrast of the camera by pressing the arrow keys, while showing a live feed of what the camera sees. Since I only used one camera, I initiated it using cv2.VideoCapture(-1), and it worked fine.

However, when I tried to add a second camera to the program, I ran into an issue. The two cameras can be found at /dev/video0 and /dev/video1. When I changed the first camera to use cv2.VideoCapture(0), the program stopped working. After further testing, whenever I try to change any setting on a camera initialized with a value other than -1, the property is set to zero. If I adjust a property twice (typically brightness or contrast) before taking a picture, I get an error (libv4l2: error setting pixformat: Device or resource busy). If I try to do anything with the camera after that, it fails entirely. Using cam.set() returns false no matter what property/value I provide.

These issues only show up using cv2.VideoCapture(0) and cv2.VideoCapture(1), but cv2.VideoCapture(-1) always works. I've tried keeping only one camera plugged in and using cv2.VideoCapture(0) and it still fails, and if I don't try to set any properties I can successfully take an image from both cameras, so I don't believe bandwidth is an issue.

Edit: I simplified the code to figure out what was causing the issue. This is what I am currently using:

import cv2

cam = cv2.VideoCapture(0)
r1 = cam.set(10,55)
ret0,img0 = cam.read()
r2 = cam.set(11,60)
ret1,img1 = cam.read()
r3 = cam.set(10,70)
print(r1,r2,r3)
print(ret0,ret1)

The output was as follows:

libv4l2: error setting pixformat: Device or resource busy
(True, True, False)
(True, False)

If I only took one picture, or only changed one setting, there was not an error.

2019-08-23 07:59:59 -0600 received badge  Self-Learner (source)
2019-08-22 12:11:04 -0600 commented question OpenCV 4.1.0 not changing brightness

I figured out how to get it to work (answer below). For what it's worth, though, adding a wait did not work. I tried add

2019-08-22 12:10:35 -0600 commented question OpenCV 4.1.0 not changing brightness

I figured out how to get it to work (answer below). For what it's worth, though, adding a wait did not work. I tried add

2019-08-22 12:08:48 -0600 answered a question OpenCV 4.1.0 not changing brightness

I changed how I initialized the camera and it works now. I'm not sure why this was able to fix the issue, but I thought

2019-08-22 09:34:16 -0600 commented question OpenCV 4.1.0 not changing brightness

Yes. Sorry, that was not my intention, and I thought I specified what parameters I was changing. If I used cv2.VideoCapt

2019-08-21 08:14:53 -0600 commented question OpenCV 4.1.0 not changing brightness

Do you mean using cv2.CAP_PROP_BRIGHTNESS instead of 10, and the same for contrast? It didn't make a difference

2019-08-20 13:39:18 -0600 commented question OpenCV 4.1.0 not changing brightness

At first, the USBs were in the same bus. Since I wasn't sure if that was causing the issue, I actually unplugged one. Ev

2019-08-20 13:37:53 -0600 received badge  Editor (source)
2019-08-20 13:37:53 -0600 edited question OpenCV 4.1.0 not changing brightness

OpenCV 4.1.0 not changing brightness I made a program that can change the brightness/contrast of the camera by pressing

2019-08-19 16:41:04 -0600 asked a question OpenCV 4.1.0 not changing brightness

OpenCV 4.1.0 not changing brightness I made a program that can change the brightness/contrast of the camera by pressing