Line 16:
Line 16:
|MV series
|MV series
|MV-MIPI-IMX178M
|MV-MIPI-IMX178M
+
|Done
+
|-
+
|MV series
+
|MV-MIPI-SC130M
+
|Done
+
|-
+
|MV series
+
|MV-MIPI-IMX296M
+
|Done
+
|-
+
|MV series
+
|MV-MIPI-IMX287M
+
|Done
+
|-
+
|MV series
+
|MV-MIPI-IMX265M
+
|Done
+
|-
+
|MV series
+
|MV-MIPI-IMX264M
+
|Done
+
|-
+
|MV series
+
|MV-MIPI-GMAX4002M
+
|Done
+
|-
+
|RAW series
+
|RAW-MIPI-SC132M
+
|Done
+
|-
+
|RAW series
+
|RAW-MIPI-IMX462M
+
|Done
+
|-
+
|RAW series
+
|RAW-MIPI-AR0234M
+
|Done
+
|-
+
|RAW series
+
|RAW-MIPI-SC535M
|Done
|Done
|}
|}
+
<br />
=== Hardware Setup ===
=== Hardware Setup ===
+
+
==== MV series cameras use the ADP-MV1 connection ====
MV series cameras need to use ADP-MV1 adapter board in order to connect to Raspberry Pi.
MV series cameras need to use ADP-MV1 adapter board in order to connect to Raspberry Pi.
−
We take MV-MIPI-IMX178M as an example to introduce the hardware installation method.
+
===== Connection of MV series camera and ADP-MV1 =====
+
The two are connected using 0.5 mm pitch*30P FFC cable with opposite-side contacts. The cable must be inserted with the silver contacts facing outside.
+
{| class="wikitable"
+
!TOP
+
!BOTTOM
+
|-
+
|[[File:ADP-MV1-MV-MIPI-X 01.jpg|center|thumb|600x600px|ADP-MV1 to MV-MIPI-X|alt=]]
+
|[[File:ADP-MV1-MV-MIPI-X 02.jpg|alt=|center|thumb|600x600px|ADP-MV1 to MV-MIPI-X]]
+
|}
−
==== Connection of MV-MIPI-IMX178M and ADP-MV1 ====
+
===== Power supply =====
−
The two are connected using 0.5 mm pitch*30P FFC cable with opposite direction. The cable must be inserted with the silver contacts facing outside.[[File:ADP-MV1-MV-MIPI-X 01.jpg|center|thumb|800x800px|ADP-MV1 to MV-MIPI-X|link=http://wiki.veye.cc/index.php/File:ADP-MV1-MV-MIPI-X_01.jpg]]
−
==== Connection of ADP-MV1 to Raspberry Pi ====
−
===== Power supply =====
The ADP-MV1 requires a separate 5V power supply and can be powered directly from the Raspberry Pi motherboard using a Dupont cable.[[File:ADP-MV1-MV-MIPI-X 07.jpg|center|thumb|800x800px|ADP-MV1 power supply|link=http://wiki.veye.cc/index.php/File:ADP-MV1-MV-MIPI-X_07.jpg]]
The ADP-MV1 requires a separate 5V power supply and can be powered directly from the Raspberry Pi motherboard using a Dupont cable.[[File:ADP-MV1-MV-MIPI-X 07.jpg|center|thumb|800x800px|ADP-MV1 power supply|link=http://wiki.veye.cc/index.php/File:ADP-MV1-MV-MIPI-X_07.jpg]]
+
+
===== Raspberry Pi 5 =====
+
The two are connected using 15Pto22P FFC cable with Same-side contacts. Pay attention to the silver contacts facing side.
+
{| class="wikitable"
+
|-
+
|[[File:ADP-MV1 to RPI5.jpg|link=http://wiki.veye.cc/index.php/File:ADP-MV1%20to%20RPI5.jpg|center|thumb|600x600px|ADP-MV1 to RPI5]]
+
|[[File:ADP-MV1 to RPI5 2.jpg|link=http://wiki.veye.cc/index.php/File:ADP-MV1%20to%20RPI5%202.jpg|alt=|center|thumb|600x600px|ADP-MV1 to RPI5_2]]
+
|}
===== Raspberry Pi Model B and B+ =====
===== Raspberry Pi Model B and B+ =====
−
The two are connected using 1.0 mm pitch*15P FFC cable with opposite direction. Pay attention to the silver contacts facing side.[[File:MV-MIPI-X-RPI B 01.jpg|alt=MV camera and RPI connection|center|thumb|800x800px|MV camera and RPI connection|link=http://wiki.veye.cc/index.php/File:MV-MIPI-X-RPI_B_01.jpg]]
+
The two are connected using 1.0 mm pitch*15P FFC cable with opposite-side contacts. Pay attention to the silver contacts facing side.[[File:MV-MIPI-X-RPI B 01.jpg|alt=MV camera and RPI connection|center|thumb|800x800px|MV camera and RPI connection|link=http://wiki.veye.cc/index.php/File:MV-MIPI-X-RPI_B_01.jpg]]
===== Raspberry Pi Zero, Zero W and Computer Module =====
===== Raspberry Pi Zero, Zero W and Computer Module =====
−
The two are connected using 15Pto22P FFC cable with same direction. Pay attention to the silver contacts facing side.[[File:MV-MIPI-X-RPI Z 01.jpg|center|thumb|800x800px|MV camera and Raspberry Pi zero connection|link=http://wiki.veye.cc/index.php/File:MV-MIPI-X-RPI_Z_01.jpg]]
+
The two are connected using 15Pto22P FFC cable with Same-side contacts. Pay attention to the silver contacts facing side.[[File:MV-MIPI-X-RPI Z 01.jpg|center|thumb|800x800px|MV camera and Raspberry Pi zero connection|link=http://wiki.veye.cc/index.php/File:MV-MIPI-X-RPI_Z_01.jpg]]<br />
+
[[File:CM5-MV-connect.jpg|link=http://wiki.veye.cc/index.php/File:CM5-MV-connect.jpg|center|thumb|800x800px|MV camera connect to CM5]]
+
+
====RAW series cameras directly connected to Raspberrypi====
+
+
===== Raspberry Pi 5 =====
+
The RAW-MIPI-SC132M use a 15-to-22-pin same-side FFC cable, while other RAW series cameras use a 22-pin opposite-side FFC cable.
+
[[File:RAW CAM to RPI5.jpg|link=http://wiki.veye.cc/index.php/File:RAW%20CAM%20to%20RPI5.jpg|center|thumb|800x800px|RAW CAM to RPI5]]
+
+
=====Raspberry Pi Model B and B+=====
+
The RAW-MIPI-SC132M use a 15-pin opposite-side FFC cable, while other RAW series cameras use a 15-to-22-pin same-side FFC cable.[[File:RAW-MIPI-AR0234-RPI4.jpg|center|thumb|800x800px|RAW series camera and RPI connection|link=http://wiki.veye.cc/index.php/File:RAW-MIPI-AR0234-RPI4.jpg]]
+
=====Raspberry Pi Zero, Zero W and Computer Module=====
+
The RAW-MIPI-SC132M use a 15-to-22-pin same-side FFC cable, while other RAW series cameras use a 22-pin opposite-side FFC cable.[[File:RAW-MIPI-AR0234-RPI ZERO.jpg|center|thumb|800x800px|RAW-MIPI-AR0234-RPI ZERO|link=http://wiki.veye.cc/index.php/File:RAW-MIPI-AR0234-RPI_ZERO.jpg]]
+
[[File:CM5-RAW-connect.jpg|link=http://wiki.veye.cc/index.php/File:CM5-RAW-connect.jpg|center|thumb|800x800px|RAW-MIPI-SC535M connect to CM5]]
+
=== piOS Configuration ===
=== piOS Configuration ===
For details on how to install the Raspberry Pi system, please refer to the official documentation at [https://www.raspberrypi.org/documentation/installation/ Install raspberry pi guide].
For details on how to install the Raspberry Pi system, please refer to the official documentation at [https://www.raspberrypi.org/documentation/installation/ Install raspberry pi guide].
Line 43:
Line 113:
It is recommended to enable the ssh service and samba service of Raspberry Pi system, here we will not go into the details of how to enable ssh and samba service of Raspberry Pi system.
It is recommended to enable the ssh service and samba service of Raspberry Pi system, here we will not go into the details of how to enable ssh and samba service of Raspberry Pi system.
−
=== Legacy mode and V4L2 mode introduction ===
+
=== V4L2 mode and Legacy mode introduction ===
−
The difference between these two modes is described in detail on the [https://www.raspberrypi.com/documentation/accessories/camera.html#libcamera-and-the-legacy-raspicam-camera-stack Raspberry Pi website.] The libcamera-stack mode mentioned on the Raspberry Pi website is architecturally identical to the V4L2 mode we are talking about.
+
In the latest Raspberry Pi Bookworm system, support for Legacy mode has been removed. It is recommended for customers to use the V4L2 mode.
+
+
==== libcamera and V4L2 mode ====
+
Now piOS has switched to libcamera-stack mode.
+
+
Libcamera is essentially centered on implementing isp functionality, something that is not needed for the MV series cameras. Therefore, we have adopted the V4L2 mode instead of using libcamera-stack.
+
As with libcamera-stack, our V4L2 model implements the standard V4L2 driver for the linux driver layer too. Based on this driver, the application layer can directly develop programs to acquire images and perform further processing.
==== Legacy mode ====
==== Legacy mode ====
Traditional mode, relying on Broadcom's GPU for image processing. The traditional raspicam software set uses this model.
Traditional mode, relying on Broadcom's GPU for image processing. The traditional raspicam software set uses this model.
Line 63:
Line 139:
Since the two modes cannot co-exist, Legacy mode needs to be turned off when using V4L2 mode.
Since the two modes cannot co-exist, Legacy mode needs to be turned off when using V4L2 mode.
−
−
==== libcamera and V4L2 mode ====
−
Now piOS has switched to libcamera-stack mode.
−
−
Libcamera is essentially centered on implementing isp functionality, something that is not needed for the MV series cameras. Therefore, we have adopted the V4L2 mode instead of using libcamera-stack.
−
−
As with libcamera-stack, our V4L2 model implements the standard V4L2 driver for the linux driver layer too. Based on this driver, the application layer can directly develop programs to acquire images and perform further processing.
−
===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].
Line 81:
Line 149:
<code>chmod +x *</code>
<code>chmod +x *</code>
+
+
* For Raspberry Pi 5
+
+
<code>sudo ./install_driver_rpi5.sh veye_mvcam</code>
+
+
It will install both CAM1 and CAM0 overlays in /boot/config.txt.
+
+
* For other Raspberry Pi
<code>sudo ./install_driver.sh veye_mvcam</code>
<code>sudo ./install_driver.sh veye_mvcam</code>
Line 87:
Line 163:
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.
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.
+
+
===== Use 4-lane mode of mvcam =====
+
For the mvcam, the default dtbo is for the 2-lane mode. If you need to use the 4-lane mode, please first confirm that both your Raspberry Pi and the camera support the 4-lane mode.
+
+
Then, after the driver is installed, please additionally execute the following command:
+
+
<code>sudo cp driver_bin/$(uname -r)/veye_mvcam_4lane.dtbo /boot/overlays/veye_mvcam.dtbo</code>
==== Uninstall the driver ====
==== Uninstall the driver ====
Line 105:
Line 188:
And the /dev/video0 node exists, which proves that the camera status is normal.
And the /dev/video0 node exists, which proves that the camera status is normal.
+
+
==== '''State Detection and Environment Variable Configuration''' ====
+
[https://github.com/veyeimaging/raspberrypi_v4l2/tree/main/mv_tools_rpi Here], we provide an <code>mv_probe.sh</code> script that automatically detects the connected camera and configures environment variables with its default model, width, height, frame rate, and other information.
+
+
Usage:
+
+
<code>source ./mv_probe.sh</code>
+
+
A typical output:
+
+
<code>$ source ./mv_probe.sh</code>
+
+
<code>The mvcam driver is loaded on i2c-10, but the camera is not detected!</code>
+
+
<code>Found veye_mvcam camera on i2c-11.</code>
+
+
<code>Setenv CAMERAMODEL = RAW-MIPI-SC535M</code>
+
+
<code>Setenv FPS = 49</code>
+
+
<code>Setenv HEIGHT = 2048</code>
+
+
<code>Setenv WIDTH = 2432</code>
+
+
You can verify the environment variable output using:
+
+
<code>echo $CAMERAMODEL</code>
+
+
Note that these environment variables are only valid for the current session.
+
+
'''Important Notes:'''
+
+
* This script requires the <code>mvcam</code> driver version '''1.1.06 or later'''.
+
* If your driver version is '''earlier than 1.1.06''' or you need to use different width, height, or frame rate values, refer to the camera module manual and manually configure the following environment variables. Otherwise, subsequent programs may not function correctly.
+
+
Example:
+
+
<code>export WIDTH=2432</code>
+
+
<code>export HEIGHT=2048</code>
+
+
<code>export FPS=50</code>
+
+
==== Raspberry Pi 5 Setting ====
+
On Raspberry Pi 5,the drivers now use the media controller API, and we must setup the media graph correctly first. This includes setting up the media pad formats correctly and correctly linking them together.
+
+
We provide a series of scripts to implement this functionality, saved in the rpi5_scripts directory.
+
+
* ./find_entity.sh
+
+
<code>$ ./find_entity.sh</code>
+
+
<code>Found mvcam @ i2c-4 entity on /dev/media3</code>
+
+
<code>Plese get frame from /dev/video0 and use /dev/v4l-subdev2 for camera setting.</code>
+
+
<code>Found mvcam @ i2c-6 entity on /dev/media0</code>
+
+
<code>Plese get frame from /dev/video8 and use /dev/v4l-subdev5 for camera setting.</code><br />After a reboot of Raspberry Pi 5, the media node and video node of the camera may change. Therefore, it is recommended to execute <code>./find_entity.sh</code> before performing subsequent operations to identify the device nodes.
+
+
The above prompt shows that the system has detected two cameras and their corresponding device nodes.
+
+
<code>i2c-4</code> corresponds to the CAM1 port on the board, and <code>i2c-6</code> corresponds to the CAM0 port on the board.
+
+
* media_setting_rpi5.sh
+
+
<code>./media_setting_rpi5.sh</code>
+
+
<code>This is a Raspberry Pi 5.</code>
+
+
<code>Kernel version is 6.6.51, do not support unpacked format.</code>
+
+
<code>Usage: ./media_setting_rpi5.sh veyecam2m/csimx307/cssc132/mvcam -fmt [UYVY/RAW8/RAW10/RAW12] -x [roi_x] -y [roi_y] -w [width] -h [height] -c [cam 0|1]</code>
+
+
<code>This shell script is designed to detect the connection of a camera on Raspberry Pi 5.</code>
+
+
<code> It utilizes media-ctl and v4l2-ctl commands to configure the linking relationships and data formats of the media pad.</code>
+
+
<code> Once completed, you can directly use /dev/video0 or /dev/video8 to obtain image data.</code>
+
+
Before proceeding with further operations, it is '''necessary''' to execute this script to complete the configuration of parameters.
+
+
For instance,RAW-MIPI-AR0234M:
+
+
<code>./media_setting_rpi5.sh mvcam -fmt RAW8 -w 1920 -h 1200</code>
==== v4l2-ctl application examples ====
==== v4l2-ctl application examples ====
Line 144:
Line 312:
<small><code> Size: Discrete 3088x2064</code></small>
<small><code> Size: Discrete 3088x2064</code></small>
−
<small><code> [5]: 'UYVY' (UYVY 4:2:2)</code></small>
+
<br />On Raspberry Pi 5, the actual supported image formats depend on the capabilities of the camera, not the list provided here.
−
−
<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 ======
====== List the configurable parameters of the camera implemented in the driver ======
<code>v4l2-ctl -L</code>
<code>v4l2-ctl -L</code>
−
<code><small>User Controls</small></code>
+
<code>User Controls</code>
−
<code><small> horizontal_flip 0x00980914 (bool) : default=0 value=0</small></code>
+
<code> trigger_mode 0x00981901 (int) : min=0 max=2 step=1 default=0 value=0 flags=volatile, execute-on-write</code>
−
<code><small> vertical_flip 0x00980915 (bool) : default=0 value=0</small></code>
+
<code> trigger_src 0x00981902 (int) : min=0 max=1 step=1 default=1 value=1 flags=volatile, execute-on-write</code>
−
<code><small> trigger_mode 0x00981901 (int) : min=0 max=2 step=1 default=0 value=0 flags=volatile</small></code>
+
<code> soft_trgone 0x00981903 (button) : flags=write-only, execute-on-write</code>
−
<code><small> trigger_src 0x00981902 (int) : min=0 max=1 step=1 default=1 value=1 flags=volatile</small></code>
+
<code> frame_rate 0x00981904 (int) : min=1 max=60 step=1 default=30 value=30 flags=volatile, execute-on-write</code>
−
<code><small> soft_trgone 0x00981903 (button) : flags=write-only, execute-on-write</small></code>
+
<code> roi_x 0x00981905 (int) : min=0 max=1376 step=8 default=0 value=0</code>
−
<code><small> frame_rate 0x00981904 (int) : min=0 max=22 step=1 default=22 value=22 flags=volatile</small></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.
Parameters can be set and get using the following methods.
Line 173:
Line 337:
<code>v4l2-ctl --get-ctrl [ctrl_type]</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:
+
Note: For Raspberry Pi 5, the -d parameter needs to be added to all commands in this section to specify the subdev used for configuring parameters.
−
======horizontal and <small>vertical</small> flip======
−
*horizontal flip
+
For example, if executing ./media_setting_rpi5.sh or ./find_entity.sh prompts the use of /dev/v4l-subdev2 for parameter configuration, then <code>v4l2-ctl -L</code> should be changed to <code>v4l2-ctl -L -d /dev/v4l-subdev2</code>.
−
<code>v4l2-ctl --set-ctrl horizontal_flip=1</code>
+
All the above functions can be implemented using [[Mv mipi i2c.sh user guide|mv_mipi_i2c.sh]].
−
*<small>vertical flip</small>
+
None of the above parameters can be modified in the state when the image acquisition is started.
−
<code>v4l2-ctl --set-ctrl <small>vertical_flip</small>=1</code>
+
Each of them is described below:
======Trigger Mode======
======Trigger Mode======
<code>v4l2-ctl --set-ctrl <small>trigger_mode=[0-2]</small></code>
<code>v4l2-ctl --set-ctrl <small>trigger_mode=[0-2]</small></code>
Line 212:
Line 373:
====== Set ROI ======
====== Set ROI ======
−
For example, for MV-MIPI-IMX178M:
−
<code>v4l2-ctl --set-selection=target=crop,top=32,left=64,width=2592,height=1944</code>
+
*method 1,use selection
+
+
<code>v4l2-ctl --set-selection=target=crop,top=0,left=0,width=$WIDTH,height=$HEIGHT</code>
+
+
Note: This method is not applicable to Raspberry Pi 5.
The maximum frame rate will be adjusted automatically after setting ROI.
The maximum frame rate will be adjusted automatically after setting ROI.
−
==== Set ROI and save the image ====
+
*method 2,use user definedroi_x,roi_y and <code>--set-fmt-video</code>
+
+
<code>v4l2-ctl --set-ctrl roi_x=0</code>
+
+
<code>v4l2-ctl --set-ctrl roi_y=0</code>
+
+
<code>v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT</code>
+
+
Note: For Raspberry Pi 5, you can directly use the media_setting_rpi5.sh script to complete the roi configuration, as the media_setting_rpi5.sh script already contains the roi configuration.
+
==== Video Streaming mode ====
===== Set ROI =====
===== Set ROI =====
−
Take MV-MIPI-IMX178M, 3088*2064 as an example.
+
<code>v4l2-ctl --set-ctrl roi_x=0</code>
+
+
<code>v4l2-ctl --set-ctrl roi_y=0</code>
+
+
<code>v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT</code>
−
<code>v4l2-ctl --set-selection=target=crop,top=0,left=0,width=3088,height=2064</code>
+
===== Set Framerate =====
+
<code>v4l2-ctl --set-ctrl frame_rate=$FPS</code>
===== Frame rate statistics =====
===== Frame rate statistics =====
In streaming mode, the following commands can be used for frame rate statistics.
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>
+
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=GREY --stream-mmap --stream-count=-1 --stream-to=/dev/null</code>
===== Save image to file =====
===== 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
+
*raw8
+
+
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=GREY --stream-mmap --stream-count=1 --stream-to="y8-${WIDTH}x${HEIGHT}.raw"</code>
+
+
or
+
+
<code>./yavta -c1 -F"y8-${WIDTH}x${HEIGHT}.raw" --skip 0 -f Y8 -s "${WIDTH}x${HEIGHT}" /dev/video0</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-${WIDTH}x${HEIGHT}.raw"</code>
+
+
*raw12
+
+
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat='Y12 ' --stream-mmap --stream-count=1 --stream-to="y12-${WIDTH}x${HEIGHT}.raw"</code>
+
+
−
<code>./yavta -c1 -Fy8-3104x2064.yuv --skip 0 -f Y8 -s 3088x2064 /dev/video0</code>
+
Note: 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.
PS. This y8 file can be used with this player: [https://yuv-player-deluxe.software.informer.com/2.6/ YUV Displayer Deluxe].
PS. This y8 file can be used with this player: [https://yuv-player-deluxe.software.informer.com/2.6/ YUV Displayer Deluxe].
+
=====Preview=====
+
In the latest version of Raspberry Pi OS, there is currently an issue with VLC for playback, and it cannot be used. Please use `qv4l2` as an alternative.
+
+
======Preview using VLC======
+
1. Open VLC with command line <code>vlc</code> , or click the icon to launch.
+
+
2. Hit the <code>▶</code>(Play) button to call the open media window.
+
+
3. In <code>Capture Device</code> >> <code>Device Selection</code> >> <code>Video device name</code>, select the camera video node.
+
+
4. Hit <code>Advanced Options...</code> button
−
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.
+
5. Type in the <code>width</code> and <code>height</code>, for example, 1280 and 1024.
+
+
6. Hit <code>OK</code> to save the settings and see the video feed.
+
<br />[[File:Mvcam via VLC.png|center|thumb|800x800px|Play mv camera using VLC on RPI|link=http://wiki.veye.cc/index.php/File:Mvcam_via_VLC.png]]<br />
+
======Preview using qv4l2======
+
Install qv4l2,
+
+
<code>sudo apt install qv4l2</code>
+
+
1. Open VLC with command line <code>vlc</code> to launch.
+
+
2. Hit the <code>▶</code>(Play) button to call the open media window.[[File:Mvcam via qv4l2.png|center|thumb|800x800px|Play mv camera using qv4l2 on RPI|link=http://wiki.veye.cc/index.php/File:Mvcam_via_qv4l2.png]]<br />
+
====== Preview GREY format images using Opencv ======
+
+
* install opencv
+
+
<code>pip uninstall opencv-python</code>
+
+
<code>sudo apt install python3-opencv</code>
+
+
* Preview using this [https://github.com/veyeimaging/raspberrypi_v4l2/tree/main/samples/opencv/raw_camera sample]:
+
+
<code>python ./v4l2dev_2_opencv_show_grey.py --width 640 --height 480 --fps 30</code>
+
+
On Raspberry Pi 5, you need to add a <code>--ctldev /dev/v4l-subdev*</code> parameter to specify the subdev for configuring parameters.
+
+
====== Preview GREY format images using gstreamer ======
+
<code>export DISPLAY=:0</code>
+
+
<code>gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format=GRAY8,width=$WIDTH,height=$HEIGHT,framerate=$FPS/1 ! videoconvert ! autovideosink</code>
==== Trigger mode ====
==== Trigger mode ====
+
This section takes IMX178 as an example to show the configuration and use of trigger mode. For other cameras, just refer to the width and height of the stream mode.
−
===== Set ROI =====
+
===== Set ROI and Framerate =====
−
Take MV-MIPI-IMX178M, 3088*2064 as an example.
+
<code>v4l2-ctl --set-ctrl roi_x=0</code>
+
+
<code>v4l2-ctl --set-ctrl roi_y=0</code>
−
<code>v4l2-ctl --set-selection=target=crop,top=0,left=0,width=3088,height=2064</code>
+
<code>v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT</code>
+
<code>v4l2-ctl --set-ctrl frame_rate=$FPS</code>
===== Software trigger mode =====
===== Software trigger mode =====
Line 256:
Line 493:
====== Start acquisition ======
====== Start acquisition ======
−
<code>v4l2-ctl --set-fmt-video=width=3088,height=2064,pixelformat=GREY --stream-mmap --stream-count=5 --stream-to=y8-3104x2064.yuv</code>
+
<code>v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=GREY --stream-mmap --stream-count=5 --stream-to="y8-${WIDTH}x${HEIGHT}.raw"</code>
====== Perform soft trigger operation ======
====== Perform soft trigger operation ======
Line 262:
Line 499:
<code>v4l2-ctl --set-ctrl <small>soft_trgone=1</small></code>
<code>v4l2-ctl --set-ctrl <small>soft_trgone=1</small></code>
−
−
Notes: The first image triggered in this way cannot be output and saved. ''I haven't found out why.''
===== Hardware trigger mode =====
===== Hardware trigger mode =====
Line 278:
Line 513:
====== Start acquisition ======
====== Start acquisition ======
−
<code>v4l2-ctl --set-fmt-video=width=3088,height=2064,pixelformat=GREY --stream-mmap --stream-count=5 --stream-to=y8-3104x2064.yuv</code>
+
<code>v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=GREY --stream-mmap --stream-count=5 --stream-to="y8-${WIDTH}x${HEIGHT}.raw"</code>
====== Perform hardware trigger operation ======
====== Perform hardware trigger operation ======
Line 284:
Line 519:
Note: script [https://github.com/veyeimaging/mvcam_raspberrypi/tree/main/mv_tools_rpi link].
Note: script [https://github.com/veyeimaging/mvcam_raspberrypi/tree/main/mv_tools_rpi link].
+
====Notes for CM4 ====
+
Cm4 supports the use of two cameras at the same time. Following above steps will only be able to use CAM1. To use two cameras, follow the following steps:
+
+
===== Hardware Connection =====
+
Refer to [https://www.raspberrypi.com/documentation/computers/compute-module.html this Raspberry Pi instruction] , add jumper to J6.
+
+
===== Upgrade dt-blob.bin=====
+
<code>sudo wget <nowiki>https://datasheets.raspberrypi.com/cmio/dt-blob-dualcam.bin</nowiki> -O /boot/dt-blob.bin</code>
+
=====For Buster OS(kernel5.10)=====
+
Upgrade dual camera version dtbo file, use mvcam as an example:
+
+
<code>sudo cp raspberrypi_v4l2/release/driver_bin/$(uname -r)/veye_mvcam-cm4.dtbo /boot/overlays/veye_mvcam.dtbo</code>
+
+
<code>sudo reboot</code>
+
=====For Bullseye OS(kernel5.15) =====
+
Edit file<code>/boot/config.txt</code>,Add one line<code>dtoverlay=[camera],cam0</code>.
+
+
Take veye_mvcam as an example.
+
+
<code>[all]</code>
+
+
<code>dtparam=i2c_vc=on</code>
+
+
<code>dtoverlay=veye_mvcam</code>
+
+
<code>dtoverlay=veye_mvcam,cam0</code>
+
===== Device node description=====
+
The CM4 module uses two I2C channels to communicate with the two cameras respectively.
+
{| class="wikitable"
+
!description
+
!i2c bus num
+
!lane num
+
!video node
+
|-
+
|CAM0
+
|0
+
|2lane
+
|video0
+
|-
+
|CAM1
+
|10
+
|2lane or 4lane
+
|video2(Buster),video1(Bullseye)
+
|}Note: If there is only one camera, video node is always video0.
====Compiling drivers from source code====
====Compiling drivers from source code====
Please refer to: [http://wiki.veye.cc/index.php/Build_drivers_from_source_for_rpi Build drivers from source for rpi].
Please refer to: [http://wiki.veye.cc/index.php/Build_drivers_from_source_for_rpi Build drivers from source for rpi].
Line 392:
Line 671:
Set rising edge trigger
Set rising edge trigger
−
<code>./mv_mipi_i2c.sh -w -f trgedge -p1</code>
+
<code>./mv_mipi_i2c.sh -w -f trgedge -p1 0</code>
In addition, rich trigger attributes can be set for hard triggering, such as trigger delay, signal filtering, etc.
In addition, rich trigger attributes can be set for hard triggering, such as trigger delay, signal filtering, etc.
Line 401:
Line 680:
<code>python gpio_trigger.py</code>
<code>python gpio_trigger.py</code>
−
Note: script [https://github.com/veyeimaging/mvcam_raspberrypi/tree/main/mv_tools_rpi link].
+
Note: script [https://github.com/veyeimaging/mvcam_raspberrypi/tree/main/mv_tools_rpi link].<br />
+
====Notes for CM4====
+
Regarding the descriptions of hardware connections, dtbo, and i2cbus, please refer to the previous sections.
+
+
As for accessing two cameras separately using 'mv_raspicam,' the methods are as follows:
+
+
* Preview CAM0
+
+
<code>./mv_raspicam -t -1 -c 0 -y 0</code>
+
+
* Preview CAM1
−
==== Raw data picture format ====
+
<code>./mv_raspicam -t -1 -c 1 -y 10</code>
+
=== Raw data format ===
==== Unpacked image format(padded) ====
==== Unpacked image format(padded) ====
−
For 10bit depth and 12bit depth pixel data, two bytes are always used to store one pixel. The V4L2 standard 'Y10 ', 'Y12 ' formats are stored in this way.
+
For 10bit depth and 12bit depth pixel data, two bytes are always used to store one pixel. The V4L2 standard 'Y10 ' (10-bit Greyscale),'Y12 ' (12-bit Greyscale)formats are stored in this way.
This storage method is convenient for software processing, but has the disadvantage of taking up more space.
This storage method is convenient for software processing, but has the disadvantage of taking up more space.
Line 412:
Line 702:
==== Packed image format ====
==== Packed image format ====
The data format saved by mv_raspicam is the data format on the MIPS bus, with no empty bit padding between pixels.
The data format saved by mv_raspicam is the data format on the MIPS bus, with no empty bit padding between pixels.
+
+
The V4L2 standard'Y10P' (10-bit Greyscale (MIPI Packed)),'Y12P' (12-bit Greyscale (MIPI Packed))formats are stored in this way.
[[File:Packed raw data layer.png|center|thumb|1200x1200px|Packed raw data layer]]
[[File:Packed raw data layer.png|center|thumb|1200x1200px|Packed raw data layer]]
<br />
<br />
Line 427:
Line 719:
For example, the following command converts a packed raw10 image of 3088 width to an unpacked raw10.
For example, the following command converts a packed raw10 image of 3088 width to an unpacked raw10.
−
<code>. /pixel_layer_convert -I Y10P -i y10-3088x2064_0001.raw -o y10-3088x2064_0001_new.raw -w 3088</code>
+
<code>./pixel_layer_convert -I Y10P -i y10-3088x2064_0001.raw -o y10-3088x2064_0001_new.raw -w 3088</code>
==== Raw data image player ====
==== Raw data image player ====
Line 435:
Line 727:
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.
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.
−
===Shell script for parameter configuration===
+
+
==== Explanation from the Raspberry Pi official document ====
+
+
===== Packed format details =====
+
The packed format uses less storage for pixel data.
+
+
''On Raspberry Pi 4 and earlier devices'', the packed format packs pixels using the MIPI CSI-2 standard. This means:
+
+
* 10-bit camera modes pack 4 pixels into 5 bytes. The first 4 bytes contain the 8 most significant bits (MSBs) of each pixel, and the final byte contains the 4 pairs of least significant bits (LSBs).
+
* 12-bit camera modes pack 2 pixels into 3 bytes. The first 2 bytes contain the 8 most significant bits (MSBs) of each pixel, and the final byte contains the 4 least significant bits (LSBs) of both pixels.
+
+
''On Raspberry Pi 5 and later devices'', the packed format compresses pixel values with a visually lossless compression scheme into 8 bits (1 byte) per pixel.
+
+
===== Unpacked format details =====
+
The unpacked format provides pixel values that are much easier to manually manipulate, at the expense of using more storage for pixel data.
+
+
On all devices, the unpacked format uses 2 bytes per pixel.
+
+
''On Raspberry Pi 4 and earlier devices'', applications apply zero padding at the '''most significant end'''. In the unpacked format, a pixel from a 10-bit camera mode cannot exceed the value 1023.
+
+
''On Raspberry Pi 5 and later devices'', applications apply zero padding at the '''least significant end''', so images use the full 16-bit dynamic range of the pixel depth delivered by the sensor.
+
+
===i2c script for parameter configuration===
We provide shell scripts to configure the parameters.
We provide shell scripts to configure the parameters.
+
+
https://github.com/veyeimaging/raspberrypi_v4l2/tree/main/mv_tools_rpi
[http://wiki.veye.cc/index.php/Mv_mipi_i2c.sh_user_guide mv_mipi_i2c.sh user guide]
[http://wiki.veye.cc/index.php/Mv_mipi_i2c.sh_user_guide mv_mipi_i2c.sh user guide]
Line 445:
Line 761:
=== Document History ===
=== Document History ===
+
+
* 2025-03-21
+
+
Add support for MV-MIPI-GMAX4002M.
+
+
Add description of mv_probe.sh.
+
+
Remove the description about using Gstreamer to preview the UYVY format.
+
+
*2024-07-08
+
+
Add support for RAW-MIPI-SC535M.
+
+
* 2024-01-01
+
+
Add support for Raspberrypi 5.
+
+
*2023-08-16
+
+
Add support for RAW-MIPI-IMX462M and RAW-MIPI-AR0234M.
+
+
* 2023-06-07
+
+
Add preview method using qv4l2 and VLC.
+
+
* 2023-04-14
+
+
With the new version of the driver, the flip operation has been removed, and a new ROI configuration method has been added.
+
+
* 2023-03-29
+
+
Add opencv samples.
+
+
*2023-03-26
+
+
Add support for MV-MIPI-IMX287M.
+
+
*2023-03-04
+
+
Add the instructions related to CM4 in Bullseye system.
+
+
* 2023-02-10
+
+
Add note for CM4.
+
+
* 2022-12-08
+
+
Add support for the new MV-MIPI-IMX264M camera model.
+
+
* 2022-11-02
+
+
Add support for the new IMX265 and SC132 models.
* 2022-05-16
* 2022-05-16