Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    usbStream - plugin for usb Cameras

    Scheduled Pinned Locked Moved
    Plugins for DWC and DSF
    2
    10
    342
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • stuartofmtundefined
      stuartofmt
      last edited by stuartofmt

      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:

      1. Automatically scans for available cameras and determines the resolutions it / they support.
      2. Supports USB cameras (most should work).
      3. Is light in its use of system resources
      4. Allows camera selection if more than one camera is available.
      5. Allows video size selections.
      6. Allows video rotation.
      7. Allows video format selection
      8. Allows exposure selection

      Version 1.0.0
      Initial version - tested on Raspberry Pi 3B+ with Debian Bookworm

      Version 1.0.1
      Made the use of exposure control more flexible

      Version 1.2

      • Added a logfile for easy monitoring
      • restructured code and documentation for easier maintenance

      Documentation and Code can be found here:

      https://github.com/stuartofmt/usbStream

      1 Reply Last reply Reply Quote 7
      • stuartofmtundefined
        stuartofmt
        last edited by

        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 ...

        stuartofmtundefined 1 Reply Last reply Reply Quote 1
        • stuartofmtundefined
          stuartofmt @stuartofmt
          last edited by

          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.

          jonsteinmetzundefined 1 Reply Last reply Reply Quote 1
          • stuartofmtundefined stuartofmt referenced this topic
          • jonsteinmetzundefined
            jonsteinmetz @stuartofmt
            last edited by

            @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.4

            Thanks

            stuartofmtundefined 1 Reply Last reply Reply Quote 0
            • stuartofmtundefined
              stuartofmt @jonsteinmetz
              last edited by

              @jonsteinmetz

              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 from

              pip list
              
              stuartofmtundefined jonsteinmetzundefined 2 Replies Last reply Reply Quote 0
              • stuartofmtundefined
                stuartofmt @stuartofmt
                last edited by

                @jonsteinmetz

                Also does this return any results?

                
                sudo find / -name cv2
                
                
                1 Reply Last reply Reply Quote 0
                • jonsteinmetzundefined
                  jonsteinmetz @stuartofmt
                  last edited by

                  @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.

                  jonsteinmetzundefined 1 Reply Last reply Reply Quote 0
                  • jonsteinmetzundefined
                    jonsteinmetz @jonsteinmetz
                    last edited by

                    Pi OS:

                    lsb_release -a
                    No LSB modules are available.
                    Distributor ID:	Debian
                    Description:	Debian GNU/Linux 12 (bookworm)
                    Release:	12
                    Codename:	bookworm
                    
                    stuartofmtundefined 1 Reply Last reply Reply Quote 0
                    • stuartofmtundefined
                      stuartofmt @jonsteinmetz
                      last edited by stuartofmt

                      @jonsteinmetz

                      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 😞

                      jonsteinmetzundefined 1 Reply Last reply Reply Quote 0
                      • jonsteinmetzundefined
                        jonsteinmetz @stuartofmt
                        last edited by

                        @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.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Unless otherwise noted, all forum content is licensed under CC-BY-SA