Difference between revisions of "CS-MIPI-X i2c/zh"
Line 95: | Line 95: | ||
<code>./cs_mipi_i2c.sh -r -f productmodel</code> | <code>./cs_mipi_i2c.sh -r -f productmodel</code> | ||
− | 获取产品型号,如:CS-MIPI- | + | 获取产品型号,如:CS-MIPI-IMX307,CS-MIPI-SC132 |
=====camcap===== | =====camcap===== | ||
Line 144: | Line 144: | ||
如果摄像机模组支持'''连续帧率可调功能''': | 如果摄像机模组支持'''连续帧率可调功能''': | ||
− | + | CS-MIPI-IMX307帧率有效范围: [1,maxframerate] | |
+ | |||
+ | CS-MIPI-SC132帧率有效范围: [2,maxframerate] | ||
注:sync模式不支持连续帧率可调。 | 注:sync模式不支持连续帧率可调。 | ||
Line 211: | Line 213: | ||
|1 | |1 | ||
|sync mode | |sync mode | ||
+ | |- | ||
+ | |2 | ||
+ | |Hardware Trigger | ||
+ | |- | ||
+ | |3 | ||
+ | |Software Trigger | ||
|} | |} | ||
+ | CS-MIPI-IMX307 support 0,1. | ||
+ | |||
+ | CS-MIPI-SC132 support 0,2,3. | ||
+ | |||
+ | <code>./cs_mipi_i2c.sh -r -f streammode</code> | ||
+ | |||
+ | 读取当前的码流模式和主从模式 | ||
+ | |||
+ | * freerunning模式 | ||
+ | |||
+ | <code>./cs_mipi_i2c.sh -w -f streammode -p1 0</code> | ||
+ | |||
+ | 配置摄像头为freerunning模式 | ||
+ | |||
+ | * sync模式 | ||
+ | |||
+ | slave mode(sync stream mode) | ||
{| class="wikitable" | {| class="wikitable" | ||
− | |||
!value | !value | ||
!description | !description | ||
Line 223: | Line 247: | ||
|slave | |slave | ||
|} | |} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<code>./cs_mipi_i2c.sh -w -f streammode -p1 1 -p2 0</code> | <code>./cs_mipi_i2c.sh -w -f streammode -p1 1 -p2 0</code> | ||
Line 242: | Line 258: | ||
Note: only supported on camcap bit 0 is 1. | Note: only supported on camcap bit 0 is 1. | ||
+ | |||
+ | * Trigger 模式 | ||
+ | |||
+ | <code>./cs_mipi_i2c.sh -w -f streammode -p1 2</code> | ||
+ | |||
+ | 配置摄像头为硬触发模式 | ||
+ | |||
+ | <code>./cs_mipi_i2c.sh -w -f streammode -p1 3</code> | ||
+ | |||
+ | 配置摄像头为软触发模式 | ||
=====daynightmode===== | =====daynightmode===== | ||
<code>./cs_mipi_i2c.sh -r -f daynightmode</code> | <code>./cs_mipi_i2c.sh -r -f daynightmode</code> |
Revision as of 14:03, 18 June 2020
cs_mipi_i2c.sh 参数配置脚本使用说明
1 介绍
cs_mipi_i2c.sh 脚本为通过I2C协议对CS-MIPI-X系列的摄像头进行配置的工具集。
目录下总共4个文件,camera_i2c_config、i2c_read、i2c_write、cs_mipi_i2c.sh。
2 树莓派配置管脚,非树莓派忽略此步
你需要先运行
./enable_i2c_vc.sh
./camera_i2c_config
配置管脚,然后执行cs_mipi_i2c.sh
2.1 camera_i2c_config 使用说明
连接树莓派Computer Module情况下,运行
./camera_i2c_config [cameranum]
cameranum | description |
---|---|
0 | CAM0 |
1 | CAM1 |
连接树莓派经典版型情况下,直接运行
./camera_i2c_config
3 cs_mipi_i2c.sh 使用说明
./cs_mipi_i2c.sh
this shell scripts should be used for CS-MIPI-IMX307!
Usage: ./cs_mipi_i2c.sh [-r/w] [-f] function name -p1 param1 -p2 param2 -p3 param3 -b bus
options:
-r read
-w write
-f [function name] function name
-p1 [param1] param1 of each function
-p2 [param1] param2 of each function
-p3 [param1] param3 of each function
-b [i2c bus num] i2c bus number
-d [i2c addr] i2c addr if not default 0x3b
support functions: devid,hdver,camcap,firmwarever,productmodel,videofmtcap,videofmt,ispcap,i2caddr,streammode,powerhz,
daynightmode ,hue ,contrast , satu , expostate , wbstate ,aemode , aetarget, aetime,aeagc,metime ,meagain , medgain , awbmode , mwbcolortemp , mwbgain,imagedir,sreg,striggerone,triggeredge,autotgcnt,tgdebncr,tgdly,pickmode,discardfrm,pickone,mipistatus,sysreboot,sysreset,paramsave
对于树莓派Pi3B / Pi3B+ / 3A / 4B(1G/2G/4G),使用i2c0, 对于Compute Module/ CM3,使用i2c1,请添加-b1 选项。
3.1 使用详解
3.1.1 devid
./cs_mipi_i2c.sh -r -f devid
0x02 | 2 lan mipi |
3.1.2 hdver
./veye_mipi_i2c.sh -r -f hdver
获取逻辑固件版本号
value | description |
---|---|
0xXY | Version X.Y |
for example:
0x22 means V2.2
3.1.3 firmwarever
./cs_mipi_i2c.sh -r -f firmwarever
获取固件版本号,一般为X.Y格式,如1.0
3.1.4 productmodel
./cs_mipi_i2c.sh -r -f productmodel
获取产品型号,如:CS-MIPI-IMX307,CS-MIPI-SC132
3.1.5 camcap
./cs_mipi_i2c.sh -r -f camcap
获取摄像头额外能力集,每一个bit代表一个能力,1有效。
bit | description |
---|---|
0 | sync stream mode |
1 | trigger mode |
2 | pick mode |
3.1.6 videofmtcap
./cs_mipi_i2c.sh -r -f videofmtcap
获取摄像头支持的视频码流格式,如:
1920*1080@max 30fps
1280*720@max60fps
3.1.7 videofmt
./cs_mipi_i2c.sh -r -f videofmt
./cs_mipi_i2c.sh -w -f videofmt -p1 1920 -p2 1080 -p3 10
./cs_mipi_i2c.sh -w -f videofmt -p1 1280 -p2 720 -p3 60
./cs_mipi_i2c.sh -w -f videofmt -p1 640 -p2 480 -p3 130
获取和设置摄像头当前的视频码流格式,如:
1920*1080@10fps
1280*720@60fps
640*480@130fps
如果摄像机模组支持连续帧率可调功能:
CS-MIPI-IMX307帧率有效范围: [1,maxframerate]
CS-MIPI-SC132帧率有效范围: [2,maxframerate]
注:sync模式不支持连续帧率可调。
3.1.8 ispcap
./cs_mipi_i2c.sh -r -f ispcap
获取当前模组支持的isp配置能力集。
bit0 : CSC hue,contrast,saturation
bit1 : AE auto exposure 自动曝光配置
bit2 : ME manual exposure 手动曝光配置
bit3 : AWB auto white balance 自动白平衡配置
bit4 : MWB manual white balance 手动白平衡配置
3.1.9 powerhz
./cs_mipi_i2c.sh -r -f powerhz
./cs_mipi_i2c.sh -w -f powerhz -p1 50
./cs_mipi_i2c.sh -w -f powerhz -p1 60
value | description |
---|---|
50 | 工频为50Hz |
60 | 工频为60Hz |
配置当前模组使用环境的工频频率。50Hz环境对应帧率为25、50、100,60Hz环境对应帧率为30、60、120。
3.1.10 i2caddr
./cs_mipi_i2c.sh -r -f i2caddr -d i2caddrnow
./cs_mipi_i2c.sh -w -f i2caddr -p1 newi2caddr -d oldi2caddr
本模组支持修改i2c地址,范围[0x3,0x77]。
Note: only supported on firmware version >= 1.05
3.1.11 paramsave
./cs_mipi_i2c.sh -w -f paramsave
将已经配置的参数写入到flash。断电保存。
3.1.12 sysreset
./cs_mipi_i2c.sh -w -f sysreset
摄像头恢复出厂默认参数。
3.1.13 streammode
value | description |
---|---|
0 | free running |
1 | sync mode |
2 | Hardware Trigger |
3 | Software Trigger |
CS-MIPI-IMX307 support 0,1.
CS-MIPI-SC132 support 0,2,3.
./cs_mipi_i2c.sh -r -f streammode
读取当前的码流模式和主从模式
- freerunning模式
./cs_mipi_i2c.sh -w -f streammode -p1 0
配置摄像头为freerunning模式
- sync模式
slave mode(sync stream mode)
value | description |
---|---|
0 | master |
1 | slave |
./cs_mipi_i2c.sh -w -f streammode -p1 1 -p2 0
配置摄像头为sync模式,且为主
./cs_mipi_i2c.sh -w -f streammode -p1 1 -p2 1
配置摄像头为sync模式,且为从
sync模式详见:摄像头模组码流模式说明
Note: only supported on camcap bit 0 is 1.
- Trigger 模式
./cs_mipi_i2c.sh -w -f streammode -p1 2
配置摄像头为硬触发模式
./cs_mipi_i2c.sh -w -f streammode -p1 3
配置摄像头为软触发模式
3.1.14 daynightmode
./cs_mipi_i2c.sh -r -f daynightmode
./cs_mipi_i2c.sh -w -f daynightmode -p1 [value]
value | description |
---|---|
0x1 | Color Mode |
0x2 | Black&White Mode |
0x0 | Trigger Mode |
0x3 | IR-CUT day, Image Black&White mode |
0x4 | IR-CUT night, Image Color mode |
IR-CUT (Infrared cut-off filter) is a mechanical shutter design. It is placed between the lens and the image sensor, and is controlled by a motor or an electromagnet.
IR-CUT has two status: Block or Deliver the infrared.
- Color Mode
Image is Color Mode and IR_CUT status Block infrared.
- Black&White Mode
Image is Black&White Mode and IR_CUT status Deliver infrared.
- Trigger Mode
Trigger pin : J4 pin1.
Trigger pin High(3.3~12V),Image is Black&White Mode and IR-CUT status Deliver infrared.
Trigger pin Low(GND),Image is Color Mode and IR-CUT status Bolck infrared.
- IR-CUT day, Image black&white mode
Image is Black&White Mode and IR_CUT status Block infrared.
- IR-CUT night, Image color mode
Image is Color Mode and IR_CUT status Deliver infrared.
3.1.15 hue
./cs_mipi_i2c.sh -r -f hue
./cs_mipi_i2c.sh -w -f hue -p1 50
hue,range [0,100].
3.1.16 contrast
./cs_mipi_i2c.sh -r -f contrast
./cs_mipi_i2c.sh -w -f contrast-p1 50
contrast,range [0,100].
3.1.17 satu
./cs_mipi_i2c.sh -r -f satu
./cs_mipi_i2c.sh -w -f satu-p1 50
saturation,range [0,100].
3.1.18 aemode
./cs_mipi_i2c.sh -r -f aemode
./cs_mipi_i2c.sh -w -f aemode -p1 0
0 : 自动曝光
1: 手动曝光
3.1.19 aetarget
./cs_mipi_i2c.sh -r -f aetarget
./cs_mipi_i2c.sh -w -f aetarget -p1 0x40
自动曝光模式下目标亮度,需aemode为自动模式下生效。默认值不同型号会略有不同。
range:[0,255]
3.1.20 aetime
./cs_mipi_i2c.sh -r -f aetime
./cs_mipi_i2c.sh -w -f aetime -p1 0x400000
AE最长曝光时间,单位us。需aemode为自动模式下生效。
range:(100,1/framerate],如帧率为30,则范围是(100,33333].
特殊值:0xFFFFFFFF=1/framerate,自动根据camera工作模式调整。
3.1.21 aeagc
./cs_mipi_i2c.sh -w -f aeagc-p1 X -p2 Y
./cs_mipi_i2c.sh -r -f aeagc
自动曝光模式下,最大系统总增益,单位dB,需aemode为自动模式下生效。
agc组成部分为Again+Dgain+ISPGain。
X is the integer part and Y is the decimal part, for example X is 2 and Y is 3 means 2.3dB.
X range: depending on sensor.
Y range: [0-9].
IMX307,again range is[0,135]dB, step 0.3dB.
3.1.22 metime
./cs_mipi_i2c.sh -r -f metime
./cs_mipi_i2c.sh -w -f metime -p1 10000
手动曝光时间,需aemode为手动模式下生效, us.
range:[0-1000000/framerate]
3.1.23 meagain
./cs_mipi_i2c.sh -w -f meagain -p1 X -p2 Y
./cs_mipi_i2c.sh -r -f meagain
手动模拟增益,单位dB,需aemode为手动模式下生效。
X is the integer part and Y is the decimal part, for example X is 2 and Y is 3 means 2.3dB.
X range: depending on sensor.
Y range: [0-9].
IMX307,agc range is[0,27]dB, step 0.3dB.
3.1.24 medgain
./cs_mipi_i2c.sh -w -f medgain -p1 X -p2 Y
./cs_mipi_i2c.sh -r -f medgain
手动数字增益,单位dB,需aemode为手动模式下生效。
X is the integer part and Y is the decimal part, for example X is 2 and Y is 3 means 2.3dB.
X range: depending on sensor.
Y range: [0-9].
IMX307,dgain range is[0,42]dB, step 0.3dB.
3.1.25 awbmode
./cs_mipi_i2c.sh -r -f awbmode
./cs_mipi_i2c.sh -w -f awbmode -p1 0
0 : auto white balance
1: manual white balance, gain mode
2: manual white balance, color temperature mode
3.1.26 mwbgain
./cs_mipi_i2c.sh -w -f mwbgain -p1 RGAIN -p2 BGAIN
./cs_mipi_i2c.sh -r -f mwbgain
manual white balance mode, set rgain and dgain manually, ggain is always 1.
GAIN is 4-bit decimal precision, for example: 0x23 means 2+3/16=2.19.
3.1.27 mwbcolortemp
./cs_mipi_i2c.sh -w -f mwbcolortemp -p1 3200
./cs_mipi_i2c.sh -r -f mwbcolortemp
手动白平衡,色温模式。 color tempture,range [1500,15000]
3.1.28 expostate
./cs_mipi_i2c.sh -r -f expostate
readonly, get the current exposure state. exposure time, again and dgain.
3.1.29 wbstate
./cs_mipi_i2c.sh -r -f wbstate
readonly, get the current white balance state. rgain, bgain and color tempture.
3.1.30 imagedir
./cs_mipi_i2c.sh -w -f imagedir -p1 0
./cs_mipi_i2c.sh -r -f imagedir
设置图像的方向
value | description |
---|---|
0 | normal |
1 | 左右翻转 |
2 | 上下翻转 |
3 | 上下+左右翻转 |
3.1.31 sreg
./cs_mipi_i2c.sh -r -f sreg -p1 SensorAddr
对sensor寄存器的间接访问。
例如,对于CS-MIPI-IMX307
./cs_mipi_i2c.sh -r -f sreg -p1 0x300A
r sensor addr 0x300a value 0x3c