Giter Club home page Giter Club logo

source_code_example_python's Introduction

The purpose of this code is to provide a simple example of using the V4L2 driver of the Topaz module in python.

These codes are only examples, a better implementation is probably possible.

API

api.py provide an example of driver control by automatically retrieving the driver controls produced by the v4l2-ctl -l command. It can be used as an api to simplify your acces to the sensor controls in C.

This api provides several functions:

  • initialize(v4l2_device, sensor_mode) start the driver with a configurable sensor mode. (Initialization is necessary before using any other function)

  • close() closes the access to the driver, must be used last, no other function must be called after this one (except if you want to do an initialization again)

  • get_device() return the device

  • get_device_controls() return all names of controls in an array

  • get_control_info() return all information about control example (min, max, default value ...) in a dict.

  • set_controls() use a dictionary to set list of controls to values

  • get_controls_info() return the dictionary with all controls informations

  • get_control_value(control_name): Allows to retrieve the whole value of a control from its name.

  • set_control_value(control_name,value) : Allows to assign a value to a control from its name.

GPIO

GPIO_example.py brings an example of control of the pins of the nano jetson allowing with an adjustment of the frequency. This is using RPi to control GPIO. See the code for more information.

Image Capture

Install V4L2 tools

sudo apt install v4l-utils

Install pip for python2 package installation

sudo apt update
sudo apt install python-pip

Install v4l2 package for python2

pip install v4l2

Run script

python image_capture_example.py

image_capture_example.py provides an example of taking a sequence of images by changing some sensor parameters between each image. In this file you can also find functions to drive the sensor which are different from the api (less complex, address of the controls defined in static). The program will take a sequence of RAW images and customize the controls applied to each image as you wish. It is also possible to change the format to take picture in Y10 or GRAY8. Y10 images will be saved in 16bit GRAY raw image.

Video display with matplolib

video_flux_and_capture_numpy_matplotlib.py provides an example of streaming the video flux using matplotlib, you can also see in the code how to put the images in a numpy array. This codes provides really bad streaming performances with a maxmum of 5/10 fps this is due to the usage of matplotlib, it hasn't been develop for video streaming, we are using it only to show how to use the driver with numpy.

Prerequies:

sudo apt-get install libfreetype6-dev pkg-config libpng-dev pkg-config
pip install numpy
pip install matplotlib

Start the example:

python video_flux_and_capture_numpy_matplotlib.py

source_code_example_python's People

Contributors

lchevallier-teledyne avatar rguiguet-teledyne avatar

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.