Changes

Jump to navigation Jump to search
Line 4: Line 4:  
===概述===
 
===概述===
 
CS-MIPI-X 摄像头模组理论上支持树莓派的所有型号,出于性能最优考虑,建议使用树莓派3以后的版本。本篇文章以树莓派4为例讲解CS-MIPI-X系列摄像头模组接入树莓派的方法。此外介绍了接入树莓派Computer Module与树莓派Zero应用中的特殊之处。
 
CS-MIPI-X 摄像头模组理论上支持树莓派的所有型号,出于性能最优考虑,建议使用树莓派3以后的版本。本篇文章以树莓派4为例讲解CS-MIPI-X系列摄像头模组接入树莓派的方法。此外介绍了接入树莓派Computer Module与树莓派Zero应用中的特殊之处。
 +
 +
=== 关于piOS版本---Bullseye ===
 +
The latest system of Raspberry Pi - bullseye has removed the support of raspicam by default. But we still have 2 ways to use it.
 +
 +
最新版本的piOS——Bullseye默认去掉了raspicam的支持。但是我们依然有两种方法来使用。
 +
 +
* 1, 使用 legacy 版本的 piOS,也就是说,不升级到Bullseye。
 +
 +
https://www.raspberrypi.com/software/operating-systems/
 +
 +
* 2, 在Bullseye版本上,打开Open legacy camera的支持。我们已经升级了程序以适应这种应用。
 +
 +
<blockquote><u>If you want to add the legacy camera interfaces to Bullseye, please click your update icon in the taskbar to update. Then open a terminal (Ctrl-Alt-T) and type ‘sudo raspi-config’, go to ‘Interface Options’ and then ‘Legacy Camera’, and reboot. These camera interfaces are deprecated, and we are not supporting them going forwards.</u></blockquote>https://www.raspberrypi.com/news/new-old-functionality-with-raspberry-pi-os-legacy/
 +
 +
使用如下命令查看当前系统版本:
 +
 +
<code>lsb_release -a</code>
 
===硬件准备及安装===
 
===硬件准备及安装===
 
原材料:树莓派4,网线,Micro SD卡,树莓派电源线,HDMI显示器,FFC线,杜邦线,镜头,摄像头主板。
 
原材料:树莓派4,网线,Micro SD卡,树莓派电源线,HDMI显示器,FFC线,杜邦线,镜头,摄像头主板。
Line 10: Line 27:     
*树莓派接好摄像头模组后,将烧录好树莓派系统的MicroSD卡插入卡槽,网线插入网线接口,HDMI显示器接入树莓派,电源线插入power接口,为树莓派接通电源。
 
*树莓派接好摄像头模组后,将烧录好树莓派系统的MicroSD卡插入卡槽,网线插入网线接口,HDMI显示器接入树莓派,电源线插入power接口,为树莓派接通电源。
 +
*'''CS-MIPI-SC132、CS-MIPI-IMX307默认供电方式为FFC排线3.3V供电,无需插红黑电源线。'''
    
[[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树莓派连接图001.jpg|center|thumb|600x600px|connect CS-MIPI-X to Raspberry Pi 001 (CS-MIPI-IMX307 as an example)]]
Line 16: Line 34:  
[[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树莓派连接图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-X to Raspberry Pi 005 (CS-MIPI-IMX307 as an example)]]
 
[[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]]
 
<br />
 
<br />
    
===树莓派系统安装及配置===
 
===树莓派系统安装及配置===
具体安装树莓派系统方法请参考官方文档,详见:[https://www.raspberrypi.org/documentation/installation/ Install raspberrypi guide]
+
具体安装树莓派系统方法请参考官方文档,详见:[https://www.raspberrypi.org/documentation/installation/ Install raspberrypi guide]
    
接通电源后,树莓派系统启动,初始树莓派系统中Camera 和 I2C都处于未启用状态。开机后我们需要将其手动打开,执行命令
 
接通电源后,树莓派系统启动,初始树莓派系统中Camera 和 I2C都处于未启用状态。开机后我们需要将其手动打开,执行命令
Line 92: Line 111:     
=====veye_raspivid 录像=====
 
=====veye_raspivid 录像=====
<code>./veye_raspivid -t 5000 -md 1 -o ~/test.h264</code>
+
<code>./veye_raspivid -t 5000 -w 1280 -h 720 -fps 60 -stm -o ~/test.h264</code>
    
实现录像5s,码流模式为720p@60, 录像文件保存到~/test.h264。可以自行调节t的大小来选择录制时间的长短。
 
实现录像5s,码流模式为720p@60, 录像文件保存到~/test.h264。可以自行调节t的大小来选择录制时间的长短。
Line 151: Line 170:     
=====veye_raspistill 抓拍(JPG,bmp)=====
 
=====veye_raspistill 抓拍(JPG,bmp)=====
<code>./veye_raspistill -md 1 -o ~/test.jpg</code>
+
<code>./veye_raspistill -md 0 -o ~/test.jpg</code>
   −
实现抓拍一张图片,图片为1280*720,并保存,文件格式为jpg。
+
实现抓拍一张图片,图片为1920*1080,并保存,文件格式为jpg。
    
<code>./veye_raspistill -e bmp -tl 50 -t 1000  -o /dev/shm/test%d.bmp</code>
 
<code>./veye_raspistill -e bmp -tl 50 -t 1000  -o /dev/shm/test%d.bmp</code>
Line 166: Line 185:     
====D-SDK软件包====
 
====D-SDK软件包====
[[VEYE-MIPI-290/327 for Raspberry Pi#D-SDK Toolkits Manual|请参考VEYE-MIP-327 D-SDK part]]
+
提供了一个C语言的SDK库libdmipicam.so,以及基于这个库的C语言sample和python语言sample。
 +
=====安装底层支持库=====
 +
<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>
   −
<br />
+
=====分辨率模式说明=====
 +
D-SDK并不对模组做任何参数配置,对模组的参数配置参考:Video Control Toolkits Manual : [[CS-MIPI-X i2c]]。
 +
 
 +
D_init_camera_ex 函数的pvideofmt参数需要与当前模组分辨率模式一致。
 +
 
 +
<code>./cs_mipi_i2c.sh -r -f videofmt</code>
 +
 
 +
=====SDK=====
 +
 
 +
*接口:
 +
 
 +
开放源码,详见D_mipicam.h
 +
 
 +
*编译:
 +
 
 +
<code>./buildme</code>
 +
 
 +
*安装:
 +
 
 +
<code>sudo install -m 644 ./libdmipicam.so /usr/lib/</code>
 +
=====C sample=====
 +
 
 +
*preview
 +
 
 +
实现实时视频预览
 +
 
 +
*preview-dualcam
 +
 
 +
实现两路摄像头同时视频预览(RPI CM)
 +
 
 +
*video
 +
 
 +
视频压缩为H.264并保存为文件
 +
 
 +
*capture
 +
 
 +
抓拍一张jpeg图片
 +
 
 +
*video2stdout
 +
 
 +
视频压缩并输出到stdout为管道应用服务,如下命令,可达到与veye_raspivid命令类似的效果。
 +
 
 +
<code>./video2stdout | nc -l -p 5000</code>
 +
 
 +
*capture_yuv
 +
 
 +
抓拍一张YUV图片
 +
 
 +
*capture-dualcam
 +
 
 +
两路摄像头同时抓拍jpeg图片
 +
 
 +
*yuv_stream
 +
 
 +
导出yuv格式的原始数据
 +
 
 +
*capture2opencv
 +
 
 +
连续获取YUV数据并转为opencv格式,显示。
 +
 
 +
*qrcode_detection
 +
 
 +
连续抓拍YUV数据并转为opencv格式,显示,并进行二维码检测。
 +
=====Python sample=====
 +
 
 +
*preview.py
 +
 
 +
实现实时视频预览
 +
 
 +
*capture.py
 +
 
 +
抓拍一张jpeg图片
 +
 
 +
*capture_yuv.py
 +
 
 +
抓拍一张yuv图片
 +
 
 +
*video.py
 +
 
 +
视频压缩为H.264并保存为文件
 +
 
 +
*capture2opencv.py
 +
 
 +
连续获取YUV数据并转为opencv格式,显示。
 
===视频控制软件包使用===
 
===视频控制软件包使用===
由于树莓派的I2C-0作为GPU所用,为了避免冲突,我们使用I2C-1作为控制总线。我们提供了一个脚本camera_i2c_config进行总线的管脚复用配置。
+
视频控制软件包实际上是一个i2c命令的shell脚本,在i2c_cmd目录下。
 +
 
 +
对于树莓派,我们使用I2C-0作为控制总线。我们提供了一个脚本camera_i2c_config进行总线的管脚复用配置。
    
具体使用说明请见:[[CS-MIPI-X i2c/zh|I2C脚本使用说明]]
 
具体使用说明请见:[[CS-MIPI-X i2c/zh|I2C脚本使用说明]]
   −
<br />
+
PS:新版本PiOS需要使用i2c-10,如果i2c-0不通,请尝试 -b 10。
   −
=== 关于树莓派Computer Module 和树莓派Zero使用的补充说明 ===
+
===关于树莓派Computer Module 和树莓派Zero使用的补充说明===
 
请参考[[VEYE MIPI 290/327 for Raspberry Pi/zh#.E5.85.B3.E4.BA.8E.E6.A0.91.E8.8E.93.E6.B4.BEComputer Module .E5.92.8C.E6.A0.91.E8.8E.93.E6.B4.BEZero.E4.BD.BF.E7.94.A8.E7.9A.84.E8.A1.A5.E5.85.85.E8.AF.B4.E6.98.8E|关于树莓派Computer Module 和树莓派Zero使用的补充说明]]<br />
 
请参考[[VEYE MIPI 290/327 for Raspberry Pi/zh#.E5.85.B3.E4.BA.8E.E6.A0.91.E8.8E.93.E6.B4.BEComputer Module .E5.92.8C.E6.A0.91.E8.8E.93.E6.B4.BEZero.E4.BD.BF.E7.94.A8.E7.9A.84.E8.A1.A5.E5.85.85.E8.AF.B4.E6.98.8E|关于树莓派Computer Module 和树莓派Zero使用的补充说明]]<br />

Navigation menu