Using Camera in Linux

Using Camera in Linux

Seco offers different Camera options to use with their modules.
Options are: USB-camera, PAL-Camera and a Raspberry-Pi camera-connector (MIPI-CSI), which is found on many Baseboards.
We can supply an OV5640 camera-board.

How the camera is used may differ between Linux distributions.
On Debian & Android, different Apps are available, to allow simple testing.

On Linux Yocto you can use GStreamer to test the camera.
See GStreamer documentation and the NXP 'Linux User Guide' for details and examples.

Example: i.MX 8M Mini; Output OV5640 camera to wayland desktop:

gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480,framerate=30/1 ! waylandsink -v

Example: capture a single image and write it to a JPEG file:

gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=1 ! video/x-raw,width=1280,height=720 ! jpegenc ! filesink location=test.jpeg

 

On MediaTek platforms things are a bit more complicated:

1st you have to link the components together like already done by the ports-subnodes in the device tree:

media-ctl -d /dev/media1 -l "'seninf-0':1 -> 'mtk-cam camsv-0':0 [5]" media-ctl -d /dev/media1 -l "'ov5640 5-003c':0 -> 'seninf-0':0 [1]"

This links the sensor-interface to the camera and the sensor to the sensor-interface.

Than you have to assign the desired pixelformat and resolution to every link:

media-ctl -d /dev/media1 -V "'ov5640 5-003c':0 [fmt:UYVY8_1X16/1920x1080 field:none]" media-ctl -d /dev/media1 -V "'seninf-0':1 [fmt:UYVY8_1X16/1920x1080 field:none]" media-ctl -d /dev/media1 -V "'mtk-cam camsv-0':0 [fmt:UYVY8_1X16/1920x1080 field:none]"

To find out which video-device you actualy configured use

media-ctl -d /dev/media1 --entity "mtk-cam camsv-0 main-stream"

When this is done you can use v4l2-ctl to capture a stream

v4l2-ctl -d /dev/video51 --stream-mmap --stream-count=10 --stream-to=/tmp/test.raw --verbose

or a gstreamer pipeline to capture a single frame and convert it to jpeg

gst-launch-1.0 v4l2src device=/dev/video51 num-buffers=1 ! video/x-raw,width=1920,height=1080,format=UYVY ! jpegenc ! filesink location=test.jpeg

Note that the width, height and format parameters must match those you assigned to the link nodes.