Raspiraw: An example app that receives data directly from CSI sensors
on the Raspberry Pi.
The register sets for OV5647 and IMX219 are often under NDA, which means
that support can not be offered over their contents without breaking
those NDAs. Anything added here by RPF/RPT has to be demonstrable as
already being in the public domain, or from 3rd parties having
reverse engineered how the firmware is working (eg by listening to the
I2C communications).
The raw Bayer format frames captured by **raspiraw** can be converted to .ppm images by modified **dcraw** image processing app: [https://github.com/6by9/dcraw](https://github.com/6by9/dcraw)
Supported sensors:
adv7282m
imx219
ov5647
## raspiraw command line options
Table of contents:
$ raspiraw
raspiraw Camera App 0.0.1
-?, --help : This help information
-md, --mode : Set sensor mode <mode>
-hf, --hflip : Set horizontal flip
-vf, --vflip : Set vertical flip
-e, --ss : Set the sensor exposure time (not calibrated units)
-g, --gain : Set the sensor gain code (not calibrated units)
-o, --output : Set the output filename
-hd, --header : Write the BRCM header to the output file
-t, --timeout : Time (in ms) before shutting down (if not specified, set to 5s)
-sr, --saverate : Save every Nth frame
-b, --bitdepth : Set output raw bit depth (8, 10, 12 or 16, if not specified, set to sensor native)
-c, --cameranum : Set camera number to use (0=CAM0, 1=CAM1).
-eus, --expus : Set the sensor exposure time in micro seconds.
-y, --i2c : Set the I2C bus to use.
-r, --regs : Change (current mode) regs
-hi, --hinc : Set horizontal odd/even inc reg
-vi, --vinc : Set vertical odd/even inc reg
-f, --fps : Set framerate regs
-w, --width : Set current mode width
-h, --height : Set current mode height
-tp, --top : Set current mode top
-hd0, --header0 : Sets filename to write the BRCM header to
-ts, --tstamps : Sets filename to write timestamps to
-emp, --empty : Write empty output files
$
## base options
...
-md, --mode : Set sensor mode <mode>
Range is 1-7.
...
-o, --output : Set the output filename
For recording more than one frame specify "C printf integer format strings" as part of the filename.
Example: ... -o /dev/shm/out.%04d.raw ...
-hd, --header : Write the BRCM header to the output file
If selected, this prepeneds each stored frame with a 32KB header (needed for **dcraw** being able to process the raw frame). An alternative (needed for high framerate capturing) is option -hd0 (see below section), which allows **dcraw** to process the captured frames later as well.
...
-sr, --saverate : Save every Nth frame
Per default this is 20, allowing to capture frames to slow SD cards. In high framerate section, storing on (fast) ramdisk allows to use "-sr 1" (store all frames).
...
-y, --i2c : Set the I2C bus to use.
Range is 0-2.
## high frame rate options
Lookup ov5647, imx219 or adv7282m data sheets for register details.
#### I2C register setting options
-r, --regs : Change (current mode) regs
Allows to change sensor regs in selected sensor mode. Format is a semicolon separated string of assignments.
An assignment consists of a 4 hex digits register address, followed by a comma and one or more 2 hex digit byte values.
Restriction: Only registers present in selected sensor mode can be modified. Example argument: "380A,003C;3802,78;3806,05FB".
In case more than one byte appears after the comma, the byte values get written to next addresses.
-hi, --hinc : Set horizontal odd/even inc reg
Sets the horizontal odd and even increment numbers. Argument is a 2 hex digits byte. "-hi xy" is convenience shortcut for "3814,xy" in --regs for ov5647 sensor. Lookup the sensor mode registers for your sensor header file for default values. TODO: Needs to be extended to deal with the other sensors as well.
-vi, --vinc : Set vertical odd/even inc reg
Sets the vertical odd and even increment numbers. Argument is a 2 hex digits byte. "-vi xy" is convenience shortcut for "3815,xy" in --regs for ov5647 sensor. TODO: Needs to be extended to deal with the other sensors as well.
-f, --fps : Set frame rate regs
Sets the requested frame rate; argument is a floating point number. All sensors but adv7282m sensor are supported.
#### Sensor mode setting options
The following options allow to overwrite some sensor mode settings for current sensor mode.
-w, --width : Set current mode width
Sets the width value of current mode.
-h, --height : Set current mode height
Sets the height value of current mode, and sensor mode regs.
-tp, --top : Set current mode top
Sets top line in case --vinc setting jumps two or more lines. The tools *_B* modes make use of it to capture bottom half of fov.
#### File output settings
-hd0, --header0 : Write the BRCM header to output file
For high frame rate modes writing BRCM header to each file is a bottleneck.
So this option is a replacement for "--header"/"-hd" option.
Instead of writing header to each frame file, it is written to specified output file only.
For decoding ith frame with **dcraw** later, you need to concatenate specified output file and frame i and store somewhere, then **dcraw** that file.
-ts, --tstamps : Write timestamps to output file
With this option timestamps for the captured frames get written to specified output file.
This happens after video has been captured, so does not negatively affect capture frame rate.
Format: "delta,index,timestamp\n"
Timestamp distribution analysis can be easily done this way:
$ cut -f1 -d, tstamps.csv | sort -n | uniq -c
1
13 1499
17 1500
31 1501
147 1502
376 1503
22 1504
33 1505
14 1506
3 1507
1 3005
2 3006
$
This shows that frame deltas are 1503µs ± 4µs, which corresponds to 1,000,000/1503=665.3fps.
Three frame skips happened during recording, and their indices can be easily determined by:
$ grep "^3" tstamps.csv
3006,2,6027843627
3005,85,6027969857
3006,554,6028676146
$
So we know that frames 0085-0553 have no frame skips. All tools do this timestamp analysis for you.
-emp, --empty : Write empty output files
This option allows to determine the maximal frame rate **raspiraw** callback will be triggered. Only empty files will be written for the frames, but the filenames allow to count how many. This would be an example use:
raspiraw -md 7 -t 3000 -emp {some options from this section} -sr 1 -o /dev/shm/out.%04d.raw 2>/dev/null
Using **/dev/shm** ramdisk for storage is essential for high frame rates. You precede this command by "rm /dev/shm/out.*.raw" and do "ls -l /dev/shm/out.*.raw | wc --lines" afterwards to determine the number of frames written ("-sr 1" means saverate 1 or writing all frames received from camera). "--empty" option allows to determine upper bounds for the absolute maximal frame rate achievable for a given set of high frame rate options.
#### Examples:
This is an example making use of most high frame rate command line options:
$ rm /dev/shm/out.*.raw
$ raspiraw -md 7 -t 1000 -ts tstamps.csv -hd0 hd0.32k -h 64 --vinc 1F --fps 660 -r "380A,0040;3802,78;3806,0603" -sr 1 -o /dev/shm/out.%04d.raw 2>/dev/null
Using i2C device /dev/i2c-0
$ ls -l /dev/shm/out.*.raw | wc --lines
660
$
This command captures video from ov5647 camera on CSI-2 interface:
* based on 640x480 mode (-md 7)
* captures for 1s (-t 1000)
* stores µs timestamps in file tstamps.csv (-ts)
* stores BCRM header needed for **dcraw** only once in file hd0.32k (-hd0)
* sets frame capture height to 64 (-h 64)
* increases line skipping to 1 and 15 instead of 3 and 5. Results in doubling vertical covered area (--vinc 1F, sum 8 vs 16). 1F shows colors (see below), 3D result is pale
* asks for 660 fps (--fps 660)
* sets some ov5647 registers (380A,0040;3802,78;3806,0603)
* sets saverate to 1 (save all frames)
* outputs in "/dev/shm" ramdisk files starting with "out.0001.raw"
* r
没有合适的资源?快使用搜索试试~ 我知道了~
直接从 CSI2传感器接收原始数据的示例应用_C语言_代码_相关文件_下载
共46个文件
h:6个
png:4个
c:3个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 12 浏览量
2022-07-13
21:59:36
上传
评论
收藏 2.88MB ZIP 举报
温馨提示
Raspiraw:直接从 Raspberry Pi 上的 CSI 传感器接收数据的示例应用程序。 OV5647 和 IMX219 的寄存器集通常处于 NDA 之下,这意味着在不破坏这些 NDA 的情况下无法对其内容提供支持。RPF/RPT 在此处添加的任何内容都必须可以证明已经在公共领域,或者来自对固件的工作方式进行逆向工程的第 3 方(例如,通过侦听 I2C 通信)。 raspiraw捕获的原始 Bayer 格式帧可以通过修改后的dcraw图像处理应用程序转换为 .ppm 图像 支持的传感器: adv7282m imx219 ov5647 更多详情、使用方法,请下载后细读README.md文件
资源推荐
资源详情
资源评论
收起资源包目录
raspiraw-master.zip (46个子文件)
raspiraw-master
raw_header.h 2KB
adv7282m_modes.h 12KB
ov5647_modes.h 22KB
res
out.3000.ppm.d.png 33KB
out.1000.ppm.d.png 69KB
out.0123.ppm.d.png 64KB
Screenshot179.png 461KB
out.360fps.25xSlower.2.anim.gif 2.23MB
imx219_modes.h 17KB
tools
1296x730_s 884B
raw2ogg2anim 1KB
1296x720_S 891B
640x416_s 891B
640x128_s 971B
1640x1232 877B
640x64_s 1KB
640x240_s 886B
320x240 922B
640x64 1KB
2592x1944_s 890B
640x400_s 891B
1920x1080 879B
640x32 1KB
gifenc.sh 360B
640x128 888B
1640x922 876B
640x480 1011B
double.c 806B
double 8KB
640x240_B_s 887B
640x480_s 891B
1280x720 874B
3280x2464 881B
640x240_B 893B
640x240 892B
LICENCE 1KB
raspiraw.c 63KB
camera_i2c 6KB
RaspiCLI.c 4KB
.clang-format 305B
imx477_modes.h 19KB
.gitignore 35B
Makefile 436B
rpi3-gpiovirtbuf 9KB
README.md 13KB
RaspiCLI.h 2KB
共 46 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9154
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功