usbStream - plugin for usb Cameras
-
General Description
This is a simple video streamer for use with usb cameras. It streams video in jpg format from a url.It is particularly useful when you want the same camera to be consumed by more than one application. For example a timelapse application (e.g. DuetLapse3) and to also monitor in real time.
usbStream is available as a DWC plugin and as a standalone application.
Capabilities
The main capabilities include:- Automatically scans for available cameras and determines the resolutions it / they support.
- Supports USB cameras (most should work).
- Is light in its use of system resources
- Allows camera selection if more than one camera is available.
- Allows video size selections.
- Allows video rotation.
- Allows video format selection
- Allows exposure selection
Version 1.0.0
Initial version - tested on Raspberry Pi 3B+ with Debian BookwormVersion 1.0.1
Made the use of exposure control more flexibleVersion 1.2
- Added a logfile for easy monitoring
- restructured code and documentation for easier maintenance
Documentation and Code can be found here:
-
V1.0.1
Exposure control is notoriously hit-and-miss. I changed the handling of exposure control to log the values at startup so that the user has a known point from which to research.
Essentially there are two options (used together). The first switches the camera to manual control and the second sets the exposure. All this, provided the camera supports exposure control. Just what the required values are is undefined.Some cameras switch to manual when sent the value 0.25. Some require the value 1 to be sent, others ??
Exposure values are sometimes required to be between 0.0 and 1.0, sometimes negative numbers, sometime some other value (ms equivalent ?). It mainly depends on how the manufacturer set up the camera, the drivers used and even the OS.
In any case - if you need to adjust the exposure, there is going to be some trial and error.
For example, on one of my cameras, manual mode is set with 1 and usable exposure ranges are roughly in the range 75 to 200.
Good luck
The internet if full of opinions ...
-
Version 1.2
Added a logfile (accessible from DWC) to make monitoring easier.
I also restructure the code for easier maintenance and updated the documentation. -
undefined stuartofmt referenced this topic
-
@stuartofmt
This is great, thanks. But right now when I try to install the plugin I get the error:
"Failed to install package opencv-python, package manager exited with code 67"
Any guidance?Duet 3 MB6HC MB6HC 3.5.4
Duet 3 Expansion TOOL1RR TOOL1RR 3.5.4
Duet Software Framework DSF 3.5.4
Duet Web Control DWC 3.5.4Thanks
-
What OS and version are you using? A Pi? What type?
I seem to remember an issue that sometimes cropped up with that package and older Debian versions. It was mainly to do with previously installed alternate versions.
I will have to check my notes but Iβm away from my computer until Sunday β¦
In the meantime, whatβs the output frompip list
-
-
@stuartofmt Thanks for the reply.
I am using a pi 4 as my SBC. My board is Duet 3 MB6HC. I am running the standard distribution version 3.5.4.
pip list Package Version ------------------- ----------- attrs 22.2.0 av 12.3.0 certifi 2022.9.24 chardet 5.1.0 charset-normalizer 3.0.1 colorzero 2.0 dbus-python 1.3.2 distro 1.8.0 distro-info 1.5+deb12u1 gpiozero 2.0.1 idna 3.3 jsonpointer 2.3 jsonschema 4.10.3 lgpio 0.2.2.0 libarchive-c 2.9 numpy 1.24.2 olefile 0.46 pidng 4.0.9 piexif 1.1.3 pigpio 1.78 Pillow 9.4.0 pip 23.0.1 pycryptodomex 3.11.0 PyGObject 3.42.2 PyOpenGL 3.1.6 PyQt5 5.15.9 PyQt5-sip 12.11.1 pyrsistent 0.18.1 python-apt 2.6.0 python-prctl 1.8.1 requests 2.28.1 rfc3987 1.3.8 rpi-lgpio 0.6 setuptools 66.1.1 simplejpeg 1.8.1 six 1.16.0 smbus2 0.4.2 spidev 3.5 ssh-import-id 5.10 toml 0.10.2 tqdm 4.64.1 unattended-upgrades 0.1 uritemplate 4.1.1 urllib3 1.26.12 v4l2-python3 0.3.5 webcolors 1.11.1 wheel 0.38.4
sudo find / -name cv2
Yields nothing.
Thanks in advance for any insight.
-
Pi OS:
lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 12 (bookworm) Release: 12 Codename: bookworm
-
Ok! - I see the problem.
TLDR: You are using bookworm therefore you need to be on DSF 3.6.0 or higher.
Explanation
Bookworm does not want python packages to be installed using the standard python methods. Instead it requires the use of python virtual environments. A much better approach for many reasons.The python package installer in DSF 3.5.x does not create virtual environments. Hence the error.
The installer in 3.6.0 takes care of this.
Its a chicken and egg thing: without resorting to gymnastics - either downgrade the OS to bullseye or upgrade DSF.
Given that DSF 3.6.0 is at rc2 and will shortly become a full release - personally, I'd look at going that route (because its been very stable for me).
P.S. This will be the same issue you had with duetBackup
-
@stuartofmt
Great, thanks for the reply. I might wait for the release since I had some weirdness when I tried 3.6.0 rc2. I was messing with several things at the time so maybe it was unrelated. In the meantime I have been manually checking my config into github.Thanks again and I look forward to trying this out.