Changes

Jump to navigation Jump to search
Line 214: Line 214:     
Also, y8 file can be used with this player: [https://yuv-player-deluxe.software.informer.com/2.6/ YUV Displayer Deluxe].
 
Also, y8 file can be used with this player: [https://yuv-player-deluxe.software.informer.com/2.6/ YUV Displayer Deluxe].
 +
 +
=== Application examples ===
 +
 +
====Configuring  global variables====
 +
For the convenience of later descriptions, global variables are configured here according to the sensor size.
 +
 +
*MV-MIPI-IMX178M
 +
 +
<code>export WIDTH=3088</code>
 +
 +
<code>export HEIGHT=2064</code>
 +
 +
<code>export FPS=22</code>
 +
 +
*MV-MIPI-SC130M
 +
 +
<code>export WIDTH=1280</code>
 +
 +
<code>export HEIGHT=1024</code>
 +
 +
<code>export FPS=108</code>
 +
 +
*MV-MIPI-IMX296M
 +
 +
<code>export WIDTH=1456</code>
 +
 +
<code>export HEIGHT=1088</code>
 +
 +
<code>export FPS=60</code>
 +
 +
*MV-MIPI-IMX287M
 +
 +
<code>export WIDTH=704</code>
 +
 +
<code>export HEIGHT=544</code>
 +
 +
<code>export FPS=319</code>
 +
 +
*MV-MIPI-IMX265M
 +
 +
<code>export WIDTH=2048</code>
 +
 +
<code>export HEIGHT=1544</code>
 +
 +
<code>export FPS=45</code>
 +
 +
*MV-MIPI-IMX264M
 +
 +
<code>export WIDTH=2432</code>
 +
 +
<code>export HEIGHT=2056</code>
 +
 +
<code>export FPS=28</code>
 +
 +
*RAW-MIPI-SC132M
 +
 +
<code>export WIDTH=1080</code>
 +
 +
<code>export HEIGHT=1280</code>
 +
 +
<code>export FPS=120</code>
 +
 +
==== Configure parameters using v4l2-ctl ====
 +
<code>$ v4l2-ctl -d /dev/v4l-subdev2 -L</code>
 +
 +
<code>User Controls</code>
 +
 +
<code>                   trigger_mode 0x00981901 (int)    : min=0 max=2 step=1 default=0 value=0 flags=volatile, execute-on-write</code>
 +
 +
<code>                    trigger_src 0x00981902 (int)    : min=0 max=1 step=1 default=1 value=1 flags=volatile, execute-on-write</code>
 +
 +
<code>                    soft_trgone 0x00981903 (button) : flags=write-only, execute-on-write</code>
 +
 +
<code>                     frame_rate 0x00981904 (int)    : min=1 max=60 step=1 default=60 value=60 flags=volatile, execute-on-write</code>
 +
 +
<code>                          roi_x 0x00981905 (int)    : min=0 max=1376 step=8 default=0 value=0</code>
 +
 +
<code>                          roi_y 0x00981906 (int)    : min=0 max=1024 step=4 default=0 value=0</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]].
 +
 +
Note that the above parameters cannot be modified during the capture process.
 +
 +
The following is an explanation of each parameter:
 +
=====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 the starting position of the ROI =====
 +
<code>v4l2-ctl -d /dev/v4l-subdev2 --set-ctrl roi_x=0</code>
 +
 +
<code>v4l2-ctl -d /dev/v4l-subdev2 --set-ctrl roi_y=0</code>
 +
 +
After setting the ROI starting position, you need to complete the full ROI configuration using the <code>media-ctl</code> command.
 +
 +
Note that setting the ROI may affect the maximum frame rate, and the ROI parameters need to meet the requirements specified in the camera manual.
 +
 +
==== Set image format using media-ctl ====
 +
use the following command to configure the camera's data format, resolution, and frame rate using <code>media-ctl</code>:
 +
 +
<code>media-ctl -d /dev/media0 --set-v4l2 '"m00_b_mvcam 7-003b":0[fmt:Y8_1X8/'"$WIDTH"'x'"$HEIGHT"'@1/'"$FPS"']'</code>
 +
 +
Among them: <code>"m00_b_mvcam 7-003b"</code> refers to the complete name of the camera entity, <code>Y8_1X8</code> is the mbus-code, <code>'"$WIDTH"'x'"$HEIGHT"'</code> indicates the resolution, <code>1/'"$FPS"'</code> indicates the resolution frame rate.
 +
 +
The width and height here cooperate with the roi_x and roi_y of the v4l2-ctl command to form the ROI parameter.
 +
 +
For example, for MV-MIPI-IMX296M, the command after variable replacement would be:
 +
 +
<code>media-ctl -d /dev/media0 --set-v4l2 '"m00_b_mvcam 7-003b":0[fmt:Y8_1X8/1456x1088@1/60 field:none]'</code>
 +
 +
You can not only configure the data format, resolution, and frame rate in one command, but also modify them separately as needed.
 +
 +
==== Video Streaming mode ====
 +
 +
===== Set data format, resolution, frame rate =====
 +
<code>v4l2-ctl -d /dev/v4l-subdev2 --set-ctrl roi_x=0</code>
 +
 +
<code>v4l2-ctl -d /dev/v4l-subdev2 --set-ctrl roi_y=0</code>
 +
 +
<code>media-ctl -d /dev/media0 --set-v4l2 '"m00_b_mvcam 7-003b":0[fmt:Y8_1X8/'"$WIDTH"'x'"$HEIGHT"'@1/'"$FPS"']'</code>
 +
=====Frame rate statistics=====
 +
In streaming mode, the following commands can be used for frame rate statistics:
 +
 +
<code>v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=GREY --stream-mmap --stream-count=-1 --stream-to=/dev/null</code>
 +
 +
===== Save image to file =====
 +
 +
*raw8
 +
 +
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=GREY --stream-mmap --stream-count=1 --stream-to=y8-$WIDTHx$HEIGHT.raw</code>
 +
 +
*raw10
 +
 +
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat='Y10 ' --stream-mmap --stream-count=1 --stream-to=y10-$WIDTHx$HEIGHT.raw</code>
 +
 +
*raw12
 +
 +
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=$WIDTH,height=$HEIGHT,pixelformat='Y12 ' --stream-mmap --stream-count=1 --stream-to=y12-$WIDTHx$HEIGHT.raw</code>
 +
 +
Please refer to the description in the previous section for the image format.
 +
 +
===== Example of gstreamer application =====
 +
To facilitate installation and debugging, the MV series cameras provide UYVY mode, which supports a maximum width of 2880 and can be previewed in real time using the following command.
 +
 +
Note that the RAW series does not support the UYVY format.
 +
 +
We provide several gstreamer routines that implement the preview function. See the [https://github.com/veyeimaging/rk356x_firefly/tree/main/linux/examples examples] directory on github for details.
 +
 +
==== Trigger mode ====
 +
 +
===== Set data format, resolution, frame rate =====
 +
<code>v4l2-ctl -d /dev/v4l-subdev2 --set-ctrl roi_x=0</code>
 +
 +
<code>v4l2-ctl -d /dev/v4l-subdev2 --set-ctrl roi_y=0</code>
 +
 +
<code>media-ctl -d /dev/media0 --set-v4l2 '"m00_b_mvcam 7-003b":0[fmt:Y8_1X8/'"$WIDTH"'x'"$HEIGHT"'@1/'"$FPS"']'</code>
 +
=====Software trigger mode=====
 +
======Set mode======
 +
<code>v4l2-ctl -d /dev/v4l-subdev2 --set-ctrl <small>trigger_mode=1</small></code>
 +
 +
<code>v4l2-ctl -d /dev/v4l-subdev2 --set-ctrl <small>trigger_src=0</small></code>
 +
 +
====== Start acquisition ======
 +
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=GREY --stream-mmap --stream-count=1 --stream-to=y8-$WIDTHx$HEIGHT.raw</code>
 +
 +
======Perform soft trigger operation======
 +
In other shell terminals, you can execute the following command multiple times for multiple triggers.
 +
 +
<code>v4l2-ctl -d /dev/v4l-subdev2 --set-ctrl <small>soft_trgone=1</small></code>
 +
 +
===== Hardware trigger mode =====
 +
 +
====== Set mode ======
 +
<code>v4l2-ctl -d /dev/v4l-subdev2 --set-ctrl <small>trigger_mode=1</small></code>
 +
 +
<code>v4l2-ctl -d /dev/v4l-subdev2 --set-ctrl <small>trigger_src=1</small></code>
 +
 +
The [[Mv mipi i2c.sh user guide|mv_mipi_i2c.sh]] script can be used to set rich trigger parameters.
 +
 +
====== Start acquisition ======
 +
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=GREY --stream-mmap --stream-count=1 --stream-to=y8-$WIDTHx$HEIGHT.raw</code>
 +
 +
====== Perform hardware trigger operation ======
 +
Connect the appropriate trigger signal to the trigger pin of the camera and trigger it.
 +
 +
===i2c script for parameter configuration===
 +
We provide shell scripts to configure the parameters.
 +
 +
[[mv_mipi_i2c.sh user guide]]
 +
===References===
 +
 +
*ROC-RK3588S-PC Manual
 +
 +
https://wiki.t-firefly.com/en/ROC-RK3588S-PC/
 +
 +
*Firefly Linux User Guide
 +
 +
https://wiki.t-firefly.com/en/Firefly-Linux-Guide/index.html
 +
===Document History===
 +
 +
*2023-04-12
 +
 +
Release 1st version.
 +
<br />

Navigation menu