Git Product home page Git Product logo

m021v4l2's Introduction

M021V4L2: Capture images from Leopard Imaging LI-USB30-M021 camera on Linux in C++ and Python3

The LI-USB30-M021 camera from Leopard Imaging is a fast (up to 90 frames per second) global-shutter CMOS camera that captures images over USB 3.0. Because the camera serves up raw image bytes, getting it to work on Linux using V4L2 (Video For Linux 2) requires a bit of extra format-conversion work. With some help from the folks at Leopard Imaging, I was able to write a few simple APIs for the camera for people who want to use it on Linux without doing the conversion themselves.

The C++ and Python3 APIs are intended for OpenCV users who want to be able to capture images as a Mat object (C++) or NumPy array (Python3). Because the M021 camera supports three frame sizes (1280 x 720 at 60 FPS; 800 x 460 at 90 FPS; 640x480 at 30 FPS), I've provided a class for each frame size. The capture runs on its own automatically-launched thread. As the code fragment below shows, the classes are extremely simple to use:

    cap = Capture800x460()

    while True:

        ret, frame = cap.read()

        cv2.imshow('LI-USB30-M021',frame)

        if cv2.waitKey(1) & 0xFF == 27:
            break
 

To run the Python3 demo program, cd to opencv/python and do

  % sudo python3 setup.py install
  % make cap

If you get errors about OpenCV or NumPy not being installed, you should make sure that they're installed now:

  % sudo pip3 install numpy
  % sudo pip3 install opencv-python

Because Python2 will not be supported much longer, I've switched to Python3 for this project, and will not be supporting Python2.

To run the C++ OpenCV capture demo, cd to opencv/cpp and type make cap.

Both of these programs do some post-capture color balancing to compensate for the slightly dimmed / green appearance of the image from the camera.

I've also provided a C API (which is used by the C++ and Python3 code) for capturing images in YUYV format, along with a demo program (a cut-down version of Guvcview) that displays the images using GTK and SDL. To run the GTK/SDL demo, cd to gtksdl and type make run.

Known Issues

  • Programs will occasionally seg-fault on exit.

  • On ODROID XU4, Python3 version is much slower than C++ version.

  • On desktop Ubuntu 16.04, an Unable to dequeue buffer error occurs in the OpenCV C++ examples, and no image is displayed.

m021v4l2's People

Contributors

simondlevy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

m021v4l2's Issues

Changing the exposure

Is there a way in the python code to change the exposure (or set on/off auto-exposure)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.