Changes

Jump to navigation Jump to search
Line 3: Line 3:  
'''<big><big><big><big>How to Use CS-MIPI-X Mipi Camera with Raspberry Pi</big></big></big></big>'''
 
'''<big><big><big><big>How to Use CS-MIPI-X Mipi Camera with Raspberry Pi</big></big></big></big>'''
 
===Introduction===
 
===Introduction===
CS-MIPI-307 is a is a special camera module which is compatible with RASPBERRY PI. It use SONY STARVIS sensor——IMX307 and has excellent ISP functions build-in.The output format is stanard UYVY stream. It is very easy to use it with RASPBERRY PI.Of course, she also has some subtle differences with the official version. She support 1080p@30,720p@60 resolution,and i2c cmd is different.
+
CS-MIPI-X is a is a series of mipi camera module which is compatible with RASPBERRY PI. The output format is stanard UYVY stream. It is very easy to use it with RASPBERRY PI.Of course, she also has some subtle differences with the official version,i2c cmd is different.
   −
Theoretically,VEYE Camera Modules support all Raspberry Pi. For performance reasons, I recommend you use 3,3+,4 version.  This article uses Raspberry Pi 4 as an example to explain how the CS-MIPI-307 camera module working with  Raspberry Pi.  It also explain the specials  of RPI Computer Module and Zero using VEYE Camera Module.  
+
Theoretically,VEYE Camera Modules support all Raspberry Pi. For performance reasons, I recommend you use 3,3+,4 version.  This article uses Raspberry Pi 4 as an example to explain how the CS-MIPI-X camera module working with  Raspberry Pi.  It also explain the specials  of RPI Computer Module and Zero using VEYE Camera Module.  
 
===Hardware Setup===
 
===Hardware Setup===
 
'''Essentials You Need:'''
 
'''Essentials You Need:'''
    
*Raspberry PI Items : RPI, Network, MicroSD Card, Power, Monitor
 
*Raspberry PI Items : RPI, Network, MicroSD Card, Power, Monitor
*Camera Module Items : CS-MIPI-307,FFC,Dupont Wire,Lens.
+
*Camera Module Items : CS-MIPI-X,FFC,Dupont Wire,Lens.
    
'''Setup guide'''
 
'''Setup guide'''
   −
*Connect the VEYE Camera Module the CSI-2 port using FFC Cable('''type B''').
+
*Connect the CS-MIPI-X Camera Module the CSI-2 port using FFC Cable('''type B''').
*Connect Dupont Wire as shown below. CS-MIPI-307 need an addtional power.
+
*Connect Dupont Wire as shown below. CS-MIPI-X need an addtional power.
 
*Startup RaspberryPi.
 
*Startup RaspberryPi.
 +
*'''The default power supply mode of CS-MIPI-SC132 is 3.3V via FFC cable, and there is no need to plug in red and black power cable.'''
   −
[[File:CS-MIPI-IMX307树莓派连接图001.jpg|center|thumb|600x600px|connect CS-MIPI-IMX307 to Raspberry Pi 001]]
+
[[File:CS-MIPI-IMX307树莓派连接图001.jpg|center|thumb|600x600px|connect CS-MIPI-X to Raspberry Pi 001(CS-MIPI-IMX307 as an example)]]
[[File:CS-MIPI-IMX307树莓派连接图002.jpg|center|thumb|600x600px|connect CS-MIPI-IMX307 to Raspberry Pi 002]]
+
[[File:CS-MIPI-IMX307树莓派连接图002.jpg|center|thumb|600x600px|connect CS-MIPI-X to Raspberry Pi 002(CS-MIPI-IMX307 as an example)]]
 
<br />
 
<br />
[[File:CS-MIPI-IMX307树莓派连接图003.jpg|center|thumb|600x600px|connect CS-MIPI-IMX307 to Raspberry Pi 003]]
+
[[File:CS-MIPI-IMX307树莓派连接图003.jpg|center|thumb|600x600px|connect CS-MIPI-X to Raspberry Pi 003(CS-MIPI-IMX307 as an example)]]
[[File:CS-MIPI-IMX307树莓派连接图004.jpg|center|thumb|600x600px|connect CS-MIPI-IMX307 to Raspberry Pi 004]]
+
[[File:CS-MIPI-IMX307树莓派连接图004.jpg|center|thumb|600x600px|connect CS-MIPI-X to Raspberry Pi 004(CS-MIPI-IMX307 as an example)]]
[[File:CS-MIPI-IMX307树莓派连接图005.jpg|center|thumb|600x600px|connect CS-MIPI-IMX307 to Raspberry Pi 005]]
+
[[File:CS-MIPI-IMX307树莓派连接图005.jpg|center|thumb|600x600px|connect CS-MIPI-X to Raspberry Pi 005(CS-MIPI-IMX307 as an example)]]
 +
[[File:CS-MIPI-SC132-N005.jpg|alt=connect CS-MIPI-SC132 to Raspberry Pi|center|thumb|600x600px|connect CS-MIPI-SC132 to Raspberry Pi]]
      Line 31: Line 33:  
*Go to the main menu and open the Raspberry Pi Configuration tool. Enable ''Camera'' and ''I2C'' interface.
 
*Go to the main menu and open the Raspberry Pi Configuration tool. Enable ''Camera'' and ''I2C'' interface.
   −
<code>sudo raspi-config</code>[[File:Veye-Raspi-config.png|center|thumb|600x600px|link=http://wiki.veye.cc/index.php/File:Veye-Raspi-config.png]]
+
<code>sudo raspi-config</code>[[File:Veye-Raspi-config.png|center|thumb|600x600px]]
    
*Enable SSH  and Samba services.
 
*Enable SSH  and Samba services.
    
<br />
 
<br />
 +
 
===Sofware Toolkits Install===
 
===Sofware Toolkits Install===
 
====Toolkits downloading====
 
====Toolkits downloading====
Line 47: Line 50:     
====Toolkits Overview====
 
====Toolkits Overview====
[[File:Rpi github overview.jpg|alt=|center|thumb|600x600px|Software Tookits on github|link=http://wiki.veye.cc/index.php/File:Rpi_github_overview.jpg]]Software toolkits contains threeparts. ''veye_raspcam'' is raspcam alike Video Stream Toolkits, D_mipi_rpi is D-SDK Video Stream Toolkits, ''i2c_cmd'' is Video Control Toolkits.
+
[[File:Rpi github overview.jpg|alt=|center|thumb|600x600px|Software Tookits on github]]Software toolkits contains threeparts. ''veye_raspcam'' is raspcam alike Video Stream Toolkits, D_mipi_rpi is D-SDK Video Stream Toolkits, ''i2c_cmd'' is Video Control Toolkits.
    
*Video Stream Tookkits provides real-time display, capture, video recording, etc.
 
*Video Stream Tookkits provides real-time display, capture, video recording, etc.
 
*Video Control Toolkits is a shell script which provides ISP parameters configuration capbility.
 
*Video Control Toolkits is a shell script which provides ISP parameters configuration capbility.
 
*Both is Open Source.
 
*Both is Open Source.
  −
'''Note: D-SDK do not support 720p@60 now! will upgrade soon!'''
      
===Video Stream Toolkits Manual===
 
===Video Stream Toolkits Manual===
Line 59: Line 60:  
veye type like Video Stream Toolkits support multiple video formats,such as 1080p@30fps,720p@60fps etc..  
 
veye type like Video Stream Toolkits support multiple video formats,such as 1080p@30fps,720p@60fps etc..  
    +
Please use [[CS-MIPI-X i2c/zh#videofmt|cs_mipi_i2c.sh]] cmd ''videofmtcap,videofmt'' to query and set the video format before using Video Stream Toolkits.
 +
 +
======mode 1 :use -md option======
 
-md option indicat which format to use,default 0。
 
-md option indicat which format to use,default 0。
  −
Please [[CS-MIPI-X i2c#videofmt|set the video format]] before using Video Stream Toolkits.
   
{| class="wikitable"
 
{| class="wikitable"
 
|+Video Formats
 
|+Video Formats
!Value
+
!md Value
 
!Video Format
 
!Video Format
 
|-
 
|-
Line 76: Line 78:  
|VGA@130fps
 
|VGA@130fps
 
|}
 
|}
 +
 +
======mode 2 :use -w and -h option======
 +
-w option indicat width of current video width, -h option indicat height of current video width.
 +
 
====veye_raspcam: raspcam alike toolkits====
 
====veye_raspcam: raspcam alike toolkits====
 
<code>cd raspberrypi/veye_raspcam/bin/</code>
 
<code>cd raspberrypi/veye_raspcam/bin/</code>
Line 83: Line 89:  
VS toolkits provides several ELF file.
 
VS toolkits provides several ELF file.
   −
*veye_raspipreview
+
=====veye_raspipreview (realtime preview)=====
 
   
<code>./veye_raspipreview -md 1 -t 20000 -p '0,0,1280,720'</code>
 
<code>./veye_raspipreview -md 1 -t 20000 -p '0,0,1280,720'</code>
   Line 93: Line 98:  
If t is -1, Show continuous Real-time display to HDMI output,full screen.
 
If t is -1, Show continuous Real-time display to HDMI output,full screen.
   −
*veye_raspivid
+
=====veye_raspivid (video encoding and record)=====
 
+
<code>./veye_raspivid -t 5000 -w 1280 -h 720 -fps 60 -stm -o ~/test.h264</code>
<code>./veye_raspivid -md 1 -t 5000 -o ~/test.h264</code>
      
Implement H.264 format encoding(720p@60) and record for 5 seconds,Record the stream data to file ~/test.h264.
 
Implement H.264 format encoding(720p@60) and record for 5 seconds,Record the stream data to file ~/test.h264.
Line 101: Line 105:  
At the same time,Dispaly real-time video to HDMI output.(use ''-n'' if you do not want preview)
 
At the same time,Dispaly real-time video to HDMI output.(use ''-n'' if you do not want preview)
   −
*veye_raspivid (direct tcp stream with '''netcat,gstreamer''' etc..)
+
=====veye_raspivid (stream over tcp using gstreamer,recommended)=====
 +
'''''RPI side'''''
 +
 
 +
<code>./veye_raspivid -b 4000000 -t 0 -o -  | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=x.x.x.x port=5000</code>
    +
H.264 encoding on bitrate 4Mbps,forever,listen on TCP port 5000.
 +
 +
'''''PC side,using gstreamer(Powershell recommended)'''''
 +
 +
<code>gst-launch-1.0 -v tcpclientsrc host=x.x.x.x port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! autovideosink sync=false</code>
 +
 +
x.x.x.x is RPI IP address
 +
 +
'''''gstreamer''''' windows version [https://gstreamer.freedesktop.org/documentation/installing/on-windows.html?gi-language=c download].
 +
 +
=====veye_raspivid (direct tcp stream with '''netcat,gstreamer''' etc..)=====
 
'''''RPI side'''''
 
'''''RPI side'''''
   Line 125: Line 143:  
mplayer for windows [http://mplayerwin.sourceforge.net/downloads.html download]
 
mplayer for windows [http://mplayerwin.sourceforge.net/downloads.html download]
   −
*veye_raspividyuv
+
=====veye_raspividyuv (YUV image record)=====
 
   
<code>./veye_raspividyuv -t 200 -o /dev/shm/test.yuv</code>
 
<code>./veye_raspividyuv -t 200 -o /dev/shm/test.yuv</code>
    
Record UYVY data to file /dev/shm/  directory(which is in DDR), time is 200ms.
 
Record UYVY data to file /dev/shm/  directory(which is in DDR), time is 200ms.
   −
*veye_raspiraw
+
=====veye_raspiraw (record 1 YUV image)=====
 
   
<code>./veye_raspiraw -md 2 -t 200 -o /dev/shm/out.%04d.yuv</code>
 
<code>./veye_raspiraw -md 2 -t 200 -o /dev/shm/out.%04d.yuv</code>
    
Record one UYVY data to file /dev/shm/  directory(which is in DDR).
 
Record one UYVY data to file /dev/shm/  directory(which is in DDR).
   −
*veye_raspstillyuv
+
=====veye_raspstillyuv(record YUV image)=====
 
   
<code>./veye_raspistillyuv -md 1 -o /dev/shm/test.yuv</code>
 
<code>./veye_raspistillyuv -md 1 -o /dev/shm/test.yuv</code>
   Line 147: Line 162:  
Capturing one image every 50 milliseconds and save to /dev/shm directory(which is in DDR).1920*1080 YUV420 I420 format.
 
Capturing one image every 50 milliseconds and save to /dev/shm directory(which is in DDR).1920*1080 YUV420 I420 format.
   −
*veye_raspistill
+
=====veye_raspistill(record JPG,BMP image)=====
 
   
<code>./veye_raspistill -md 1 -o ~/test.jpg</code>
 
<code>./veye_raspistill -md 1 -o ~/test.jpg</code>
   Line 162: Line 176:     
veye_raspistill support preview,-n will not preview.
 
veye_raspistill support preview,-n will not preview.
<br />
      
====D-SDK Toolkits Manual====
 
====D-SDK Toolkits Manual====
[[VEYE-MIPI-290/327 for Raspberry Pi#D-SDK Toolkits Manual|Please refer VEYE-MIP-327 D-SDK part]]
+
It contains three parts: C language SDK(libdmipicam.so),C language sample,Python language sample.
 +
=====Install support package=====
 +
<code>sudo apt-get update && sudo apt-get install libopencv-dev</code>
 +
 
 +
<code>sudo apt-get install python-opencv</code>
 +
 
 +
<code>sudo apt-get install libzbar-dev</code>
 +
 
 +
=====Video Format Description=====
 +
D-SDK does not configure any parameters for the module. To config the module, please refer to: Video Control Toolkits Manual : [[CS-MIPI-X i2c]]。
 +
 
 +
The ''pvideofmt'' parameter of the ''D_init_camera_ex'' function needs to be consistent with the current module resolution mode.
 +
 
 +
<code>./cs_mipi_i2c.sh -r -f videofmt</code>
 +
 
 +
=====D-SDK=====
 +
 
 +
*interface:
 +
 
 +
opensource,D_mipicam.h
 +
 
 +
*compile:
 +
 
 +
<code>./buildme</code>
 +
 
 +
*install:
 +
 
 +
<code>sudo install -m 644 ./libdmipicam.so /usr/lib/</code>
 +
=====C sample=====
 +
 
 +
*preview
 +
 
 +
Dispaly real-time video to HDMI output
 +
 
 +
*preview-dualcam
 +
 
 +
Dispaly real-time video to HDMI output for dual cameras(RPI CM)
 +
 
 +
*video
 +
 
 +
H.264 format encoding and record to file.
 +
 
 +
*capture
 +
 
 +
Capture one jpeg image.
 +
 
 +
*video2stdout
 +
 
 +
H.264 format encoding and send to stdout,which could be used by pipe. It's like <code>veye_raspivid -o -</code>.
 +
 
 +
<code>./video2stdout | nc -l -p 5000</code>
 +
 
 +
*capture_yuv
 +
 
 +
Capture one yuv image.
 +
 
 +
*capture-dualcam
 +
 
 +
Capture jpeg images for dual cameras.
 +
 
 +
*yuv_stream
 +
 
 +
Shows how to get yuv stream.
 +
 
 +
*capture2opencv
 +
 
 +
Shows how to get yuv stream,transfer to opencv format and display it.
 +
 
 +
*qrcode_detection
 +
 
 +
Shows how to get yuv stream,transfer to opencv format and display it and detect QR code.
 +
=====Python sample=====
 +
 
 +
*preview.py
 +
 
 +
Dispaly real-time video to HDMI output
 +
 
 +
*capture.py
 +
 
 +
Capture one jpeg image.
 +
 
 +
*capture_yuv.py
 +
 
 +
capture_yuv
 +
 
 +
*video.py
 +
 
 +
H.264 format encoding and record to file.
 +
 
 +
*capture2opencv.py
 +
 
 +
Shows how to get yuv stream,transfer to opencv format and display it.
 
===Video Control Toolkits Manual===
 
===Video Control Toolkits Manual===
 
On Raspberry Pi, We use I2C-0 as control bus for VEYE Camera Module. We provide a Shell Script — camera_i2c_config— to config pin usage.
 
On Raspberry Pi, We use I2C-0 as control bus for VEYE Camera Module. We provide a Shell Script — camera_i2c_config— to config pin usage.
    
Video Control Toolkits Manual : [[CS-MIPI-X i2c]]
 
Video Control Toolkits Manual : [[CS-MIPI-X i2c]]
 +
 +
The new version of PiOS use i2c-10. If i2c-0 doesn't work, try -b 10.
 +
 +
===RPI Computer Module and RPI Zero Additional Info===
 +
Please refer to : [[VEYE-MIPI-290/327 for Raspberry Pi#RPI Computer Module and RPI Zero Additional Info|RPI Computer Module and RPI Zero Additional Info]].

Navigation menu