We’re doing vision processing using a Raspberry Pi and opencv, but instead of using the Pi camera module, we’re using an off the shelf USB camera. (Specifically, a Play-Station Eye) We didn’t have to install anything special for the camera. Just plug and play.
Everything’s working fine…except.
We’re finding that we would like to change the settings of the camera. Specifically, we want to turn off auto-exposure, but we could change other settings as well, and we want to do it in Python. For the Pi camera module, we know how to do this using the picamera library, but has anyone done the same thing with a USB camera?
(Our immediate problem is that the autoexposure messes with the results of our hsv filtering. We need a consistent exposure setting.)
Instead of VideoCamera.setExposureManual, UsbCamera is a subclass of VideoCamera, so you would just do csccam.setExposureManual. I suppose it’s not very obvious from the documentation, I’ll see if I can address that.
Instead of using cv2.VideoCapture, you can use the cscore cvSource to retrieve images from a UsbCamera instance.
In case anyone is wanting to use v4l2ctrl to set the camera parameters, here is an example. We used v4l2ucp’s GUI to disable auto exposure and set a manual value, then we used v4l2ctrl -d /dev/video0 -s settings.conf. The vision program then ran v4l2ctrl -d /dev/video0 -l settings.conf every time it loaded.
umpy\core\include -IC:\Python35-32\include -IC:\Python35-32\include “-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE” “-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt” “-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\shared” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\um” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\winrt” /EHsc /Tpsrc/_cscore.cpp /Fobuild emp.win32-3.5\Release\src/_cscore.obj /EHsc /DVERSION_INFO=“2017.0.1”
_cscore.cpp
ntcore_src/wpiutil/include\llvm/Hashing.h(570): warning C4244: ‘argument’: conversion from ‘uint64_t’ to ‘std::size_t’, possible loss of data
ntcore_src/wpiutil/include\llvm/Hashing.h(582): warning C4244: ‘argument’: conversion from ‘uint64_t’ to ‘std::size_t’, possible loss of data
ntcore_src/wpiutil/include\llvm/Hashing.h(621): warning C4244: ‘argument’: conversion from ‘uint64_t’ to ‘std::size_t’, possible loss of data
src/_cscore.cpp(12): fatal error C1083: Cannot open include file: ‘opencv2/opencv.hpp’: No such file or directory
error: command ‘C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe’ failed with exit status 2
I’ll be honest, I haven’t tried robotpy-cscore on Windows… and I don’t think there’s a ‘global’ place to install built packages like OpenCV. I’m sure there’s a way to do it, and if you figure it out let me know and I’ll stick it in the documentation.
We went down this rabbit-hole last year. This year we are simply using shades ::safety:: . Seriously, they work. Don’t even bother with your exposure settings!