Changes

Jump to navigation Jump to search
Line 85: Line 85:  
===V4L2 mode manual===
 
===V4L2 mode manual===
 
We have saved the code for v4l2 mode in this [https://github.com/veyeimaging/raspberrypi_v4l2 github repository].
 
We have saved the code for v4l2 mode in this [https://github.com/veyeimaging/raspberrypi_v4l2 github repository].
 +
====Download the driver package====
 +
<code>wget <nowiki>https://github.com/veyeimaging/raspberrypi_v4l2/releases/latest/download/raspberrypi_v4l2.tgz</nowiki></code>
 +
====Install driver====
 +
<code>tar -xzvf raspberrypi_v4l2.tgz</code>
 +
 +
<code>cd raspberrypi_v4l2/release/</code>
 +
 +
<code>chmod +x *</code>
 +
 +
<code>sudo ./install_driver.sh veye_mvcam</code>
 +
 +
Then reboot Raspberry Pi.
 +
 +
Note: If you are prompted that the corresponding version of the driver cannot be found, it means that we do not provide a compiled driver corresponding to your piOS version. Please try to compile from the source code.
 +
 +
==== Uninstall the driver ====
 +
If you need to change to Legacy mode, or want to change to another camera module model driver, you must uninstall the current driver first.
 +
 +
<code>sudo ./uninstall_driver.sh veye_mvcam</code>
 +
 +
==== Check system status ====
 +
Take MV-MIPI-IMX178M as an example.
 +
 +
<code>dmesg | grep mvcam</code>
 +
 +
You can see the camera model and the version of the camera probed during the Linux boot phase.
 +
 +
<code>camera is: MV-MIPI-IMX178M</code>
 +
 +
<code>firmware version: 0x1080102</code>
 +
 +
And the /dev/video0 node exists, which proves that the camera status is normal.
 +
 +
==== v4l2-ctl application examples ====
 +
 +
=====Install v4l2-utils =====
 +
<code>sudo apt-get install v4l-utils</code>
 +
=====Install yavta=====
 +
<code>git clone <nowiki>git://git.ideasonboard.org/yavta.git</nowiki></code>
 +
 +
<code>cd yavta;make</code>
 +
 +
===== Configure parameters using v4l2-ctl =====
 +
 +
====== List the data formats supported by the camera ======
 +
<code>v4l2-ctl --list-formats-ext</code>
 +
 +
<small><code>ioctl: VIDIOC_ENUM_FMT</code></small>
 +
 +
<small><code>        Type: Video Capture</code></small>
 +
 +
<small><code>        [0]: 'GREY' (8-bit Greyscale)</code></small>
 +
 +
<small><code>                Size: Discrete 3088x2064</code></small>
 +
 +
<small><code>        [1]: 'Y10P' (10-bit Greyscale (MIPI Packed))</code></small>
 +
 +
<small><code>                Size: Discrete 3088x2064</code></small>
 +
 +
<small><code>        [2]: 'Y10 ' (10-bit Greyscale)</code></small>
 +
 +
<small><code>                Size: Discrete 3088x2064</code></small>
 +
 +
<small><code>        [3]: 'Y12P' (12-bit Greyscale (MIPI Packed))</code></small>
 +
 +
<small><code>                Size: Discrete 3088x2064</code></small>
 +
 +
<small><code>        [4]: 'Y12 ' (12-bit Greyscale)</code></small>
 +
 +
<small><code>                Size: Discrete 3088x2064</code></small>
 +
 +
<small><code>        [5]: 'UYVY' (UYVY 4:2:2)</code></small>
 +
 +
<small><code>                Size: Discrete 3088x2064</code></small>
 +
 +
Note: UYVY data format is for debugging use only.
 +
 +
====== List the configurable parameters of the camera implemented in the driver ======
 +
<code>v4l2-ctl -L</code>
 +
 +
<code><small>User Controls</small></code>
 +
 +
<code><small>                horizontal_flip 0x00980914 (bool)   : default=0 value=0</small></code>
 +
 +
<code><small>                  vertical_flip 0x00980915 (bool)   : default=0 value=0</small></code>
 +
 +
<code><small>                   trigger_mode 0x00981901 (int)    : min=0 max=2 step=1 default=0 value=0 flags=volatile</small></code>
 +
 +
<code><small>                    trigger_src 0x00981902 (int)    : min=0 max=1 step=1 default=1 value=1 flags=volatile</small></code>
 +
 +
<code><small>                    soft_trgone 0x00981903 (button) : flags=write-only, execute-on-write</small></code>
 +
 +
<code><small>                     frame_rate 0x00981904 (int)    : min=0 max=22 step=1 default=22 value=22 flags=volatile</small></code>
 +
 +
Parameters can be set and get using the following methods.
 +
 +
<code>v4l2-ctl --set-ctrl [ctrl_type]=[val]</code>
 +
 +
<code>v4l2-ctl --get-ctrl [ctrl_type]</code>
 +
 +
All the above functions can be implemented using [[Mv mipi i2c.sh user guide|mv_mipi_i2c.sh]].
 +
 +
None of the above parameters can be modified in the state when the image acquisition is started.
 +
 +
Each of them is described below:
 +
======horizontal and <small>vertical</small> flip======
 +
 +
*horizontal flip
 +
 +
<code>v4l2-ctl --set-ctrl horizontal_flip=1</code>
 +
 +
*<small>vertical flip</small>
 +
 +
<code>v4l2-ctl --set-ctrl <small>vertical_flip</small>=1</code>
 +
======Trigger Mode======
 +
<code>v4l2-ctl --set-ctrl <small>trigger_mode=[0-2]</small></code>
 +
 +
0:Video streaming mode
 +
 +
1:Normal trigger mode.
 +
 +
2:High-speed continuous trigger mode.
 +
 +
====== Trigger Source ======
 +
<code>v4l2-ctl --set-ctrl <small>trigger_src=[0-1]</small></code>
 +
 +
0: Software trigger mode.
 +
 +
1: Hardware trigger mode.
 +
 +
====== Software trigger command ======
 +
<code>v4l2-ctl --set-ctrl <small>soft_trgone=1</small></code>
 +
 +
====== Set frame rate ======
 +
<code>v4l2-ctl --set-ctrl frame_rate=[1-max]</code>
 +
 +
The maximum frame rate is automatically updated as the resolution changed.
 +
 +
====== Set ROI ======
 +
For example, for MV-MIPI-IMX178M:
 +
 +
<code>v4l2-ctl --set-selection=target=crop,top=32,left=64,width=2592,height=1944</code>
 +
 +
The maximum frame rate will be adjusted automatically after setting ROI.
 +
 +
==== Set ROI and save the image ====
 +
 +
===== Set ROI =====
 +
Take MV-MIPI-IMX178M, 3088*2064 as an example.
 +
 +
<code>v4l2-ctl --set-selection=target=crop,top=0,left=0,width=3088,height=2064</code>
 +
 +
In streaming mode, the following commands can be used for frame rate statistics.
 +
 +
<code>v4l2-ctl --set-fmt-video=width=3088,height=2064,pixelformat=GREY --stream-mmap --stream-count=-1 --stream-to=/dev/null</code>
 +
 +
===== Save image to file =====
 +
<code>v4l2-ctl --set-fmt-video=width=3088,height=2064,pixelformat=GREY --stream-mmap --stream-count=1 --stream-to=y8-3104x2064.yuv</code>
 +
 +
Or
 +
 +
<code>./yavta -c1 -Fy8-3104x2064.yuv --skip 0 -f Y8 -s 3088x2064 /dev/video0</code>
 +
 +
PS.This y8 file can be used with this player: [https://yuv-player-deluxe.software.informer.com/2.6/ YUV Displayer Deluxe].
 +
 +
Since the memory requested by Raspberry Pi for the image, the width is 32-align and the height is 16-align, the 3088*2064 image will be saved as 3104*2064 size.
 +
 +
 +
 +
<br />

Navigation menu