Changes

Jump to navigation Jump to search
Line 40: Line 40:  
|RAW series
 
|RAW series
 
|RAW-MIPI-SC132M
 
|RAW-MIPI-SC132M
 +
|Done
 +
|-
 +
|RAW series
 +
|RAW-MIPI-IMX462M
 +
|Done
 +
|-
 +
|RAW series
 +
|RAW-MIPI-AR0234M
 
|Done
 
|Done
 
|}
 
|}
    
=== 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.
==== Connection of MV-MIPI-IMX178M and ADP-MV1 ====
  −
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.
   
{| class="wikitable"
 
{| class="wikitable"
 
!TOP
 
!TOP
Line 58: Line 66:  
|}
 
|}
   −
==== Connection of ADP-MV1 to Raspberry Pi ====
+
===== Power supply =====
   −
===== 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 />
 +
====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]]
 
=== 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 75: Line 100:  
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 95: Line 126:     
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.
   
===Configuring  global variables===
 
===Configuring  global variables===
 
For the convenience of later descriptions, global variables are configured here according to the sensor size.
 
For the convenience of later descriptions, global variables are configured here according to the sensor size.
Line 155: Line 179:  
*RAW-MIPI-SC132M
 
*RAW-MIPI-SC132M
   −
<code>export WIDTH=1080</code>
+
<code>export WIDTH=1024</code>
    
<code>export HEIGHT=1280</code>
 
<code>export HEIGHT=1280</code>
    
<code>export FPS=120</code>
 
<code>export FPS=120</code>
 +
 +
*RAW-MIPI-IMX462M
 +
 +
<code>export WIDTH=1920</code>
 +
 +
<code>export HEIGHT=1088</code>
 +
 +
* <code>export FPS=60</code>
 +
 +
*RAW-MIPI-AR0234M
 +
 +
<code>export WIDTH=1920</code>
 +
 +
<code>export HEIGHT=1200</code>
 +
 +
<code>export FPS=60</code>
 
===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 170: Line 210:     
<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 194: Line 242:     
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.
 +
 +
==== 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>Usage: ./media_setting_rpi5.sh veyecam2m/csimx307/cssc132/mvcam -fmt [UYVY/RAW8/RAW10/RAW12] -w [width] -h [height]</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 233: Line 320:  
<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 ======
Line 261: Line 344:     
<code>v4l2-ctl --get-ctrl [ctrl_type]</code>
 
<code>v4l2-ctl --get-ctrl [ctrl_type]</code>
 +
 +
 +
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.
 +
 +
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>.
    
All the above functions can be implemented using [[Mv mipi i2c.sh user guide|mv_mipi_i2c.sh]].
 
All the above functions can be implemented using [[Mv mipi i2c.sh user guide|mv_mipi_i2c.sh]].
Line 296: Line 384:     
<code>v4l2-ctl --set-selection=target=crop,top=0,left=0,width=$WIDTH,height=$HEIGHT</code>
 
<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.
Line 309: Line 399:     
===== Set ROI =====
 
===== Set ROI =====
<code>v4l2-ctl --set-selection=target=crop,top=0,left=0,width=$WIDTH,height=$HEIGHT</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>
    
===== Set Framerate =====
 
===== Set Framerate =====
Line 317: Line 411:  
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=$WIDTH,height=$HEIGHT,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 =====
Line 387: Line 481:  
* raw8
 
* raw8
   −
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=1080,height=1280,pixelformat=GREY --stream-mmap --stream-count=1 --stream-to=y8-1088x1280.raw</code>
+
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=1024,height=1280,pixelformat=GREY --stream-mmap --stream-count=1 --stream-to=y8-1024x1280.raw</code>
    
*raw10
 
*raw10
   −
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=1080,height=1280,pixelformat='Y10 ' --stream-mmap --stream-count=1 --stream-to=y10-1088x1280.raw</code>
+
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=1024,height=1280,pixelformat='Y10 ' --stream-mmap --stream-count=1 --stream-to=y10-1024x1280.raw</code>
 
======MV-MIPI-IMX287M======
 
======MV-MIPI-IMX287M======
   Line 405: Line 499:     
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=704,height=544,pixelformat='Y12 ' --stream-mmap --stream-count=1 --stream-to=y12-704x544.raw</code>
 
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=704,height=544,pixelformat='Y12 ' --stream-mmap --stream-count=1 --stream-to=y12-704x544.raw</code>
 +
====== RAW-MIPI-IMX462M======
 +
 +
*raw10
 +
 +
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1088,pixelformat='Y10 ' --stream-mmap --stream-count=1 --stream-to=y10-1920x1088.raw</code>
 +
 +
*raw12
 +
 +
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1088,pixelformat='Y12 ' --stream-mmap --stream-count=1 --stream-to=y12-1920x1088.raw</code>
 +
====== RAW-MIPI-AR0234M======
 +
 +
*raw8格式
 +
 +
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1200,pixelformat=GREY --stream-mmap --stream-count=1 --stream-to=y8-1920x1200.raw</code>
 +
 +
*raw10格式
 +
 +
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1200,pixelformat='Y10 ' --stream-mmap --stream-count=1 --stream-to=y10-1920x1200.raw</code>
    
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=====
 
=====Preview=====
 +
On a raspberry pi 5, VLC for preview is now having problems and not working.
 +
 
======Preview using VLC======
 
======Preview using VLC======
 
1. Open VLC with command line <code>vlc</code> , or click the icon to launch.
 
1. Open VLC with command line <code>vlc</code> , or click the icon to launch.
Line 472: Line 586:     
<code>python ./v4l2dev_2_opencv_show_grey.py --width 640 --height 480 --fps 30</code>
 
<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.
    
==== Trigger mode ====
 
==== Trigger mode ====
Line 477: Line 593:     
===== Set ROI and Framerate =====
 
===== Set ROI and Framerate =====
<code>v4l2-ctl --set-selection=target=crop,top=0,left=0,width=$WIDTH,height=$HEIGHT</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>
    
<code>v4l2-ctl --set-ctrl frame_rate=$FPS</code>
 
<code>v4l2-ctl --set-ctrl frame_rate=$FPS</code>
Line 724: Line 844:  
===i2c script for parameter configuration===
 
===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 732: Line 854:     
=== Document History ===
 
=== Document History ===
 +
 +
* 2024-01-01
 +
 +
Add support for Raspberrypi 5.
 +
 +
*2023-08-16
 +
 +
Add support for RAW-MIPI-IMX462M and RAW-MIPI-AR0234M.
    
* 2023-06-07
 
* 2023-06-07

Navigation menu