
0x0155 enables DPCM 10 to 8 compression which is not what you want - see Annex E "Data Compression for RAW Data Types" in the CSI2 spec for details of what that is doing. The hardware supports unpacking that back out to 10bpp data, but that doesn't really help you.AlexEts wrote: ↑Thu Dec 07, 2017 5:46 amI tried to go along the 1st way by setting following IMX219 registers: 0x0155 COMP_ENABLE_A(compression 10 to 8 mode), 0x018C 0x018D CSI_DATA_FORMAT_A6by9 wrote: ↑Wed Nov 29, 2017 1:01 pm....
To get 8 bit data through you need to either set the sensor to produce only 8 bits (and reset rawcam etc to expect the new data type value and packing), or you could run 10 bit and then set expsoure time and/or analogue gain to result in only the bottom 8 bits being used (likely to give worse image quality as all the analogue stages are then closer to the noise floor).+Code: Select all
{0x0155, 0x01} {0x018C, 0x08} {0x018D, 0x08}
rx_cfg.unpack = MMAL_CAMERA_RX_CONFIG_UNPACK_NONE;
rx_cfg.pack = MMAL_CAMERA_RX_CONFIG_PACK_NONE;
output->format->encoding = MMAL_ENCODING_BAYER_SBGGR8
But no luck. Output data is little bit messy and it looks like pixels were shifted. I suspect that it is due to different output method used by the sensor for 8 bit mode
rawcam is just programming up the hardware (it doesn't touch the pixel data itself) and it's the hardware that isn't shifting the data up and down as I was expecting.AlexEts wrote:Is there any chance 8 bit mode will be correctly supported by the rawcam? ignoring 5th byte of RGRGrgrgr sequence will be perfect, as well as clipping last last 2 bits instead of top 2 of 10 bit data? (Sorry for the naive question, not sure how the vc.ril.rawcam component handles the data internally)
Last time I looked the unpacking to 16 bit mode was correct, although it is leaving the 10 bits of data in the least significant bits of the 16 bit word.AlexEts wrote:I trying to process rawcam's output in OpenGL as fast as I can, but 10->8 bit conversion on CPU side takes tooo long which slows down overall performance.
rawcam in 16 bit mode seems to have the same clipping problem. I think 10 bit data get clipped to last 8 bits and then get promoted to 16 bit. At least this is what I see from the raw output.
Playing with exposure and gain is not an option for me as quality of the image will be poor(((

HermannSW wrote: ↑Thu Dec 07, 2017 11:42 amI don't know, it is not an effect of animated .gif creation, because you can see that on the youtube video as well.
I was told as child not to take photos direction of sun, maybe this can be an explanation (flame == sun)?
I took another 600fps video, intentionally "into another sun"![]()
In Germany we have 50Hz power network, wich should have a repeating pattern all 600/(50*2)=6 frames in 600fps video.
And it has!
I modified the conversion script to only take the last 24 frames, and to create a video with display framerate of 1fps for easy inspection:
(I did capture with "-t 120" only 120ms of video, and got 71 frames at 600fps. Then I did set index=48 in modified conversion script)
![]()
Code: Select all
$ mplayer -loop 0 -nolirc -vo fbdev2:/dev/fb0 bulb.600fps.1ps.ogg


Code: Select all
$ bc -ql
1/(17/(56/0.1))*60
1976.47058823529411783260
1/(16/(56/0.1))*60
2100.00000000000000063000Code: Select all
...
mal: Buffer 0x7a12a0 returned, filled 51200, timestamp 8943100358, flags 0084
mmal: Buffer 0x7a0d18 returned, filled 51200, timestamp 8943102009, flags 0004
mmal: Buffer 0x7a0ef0 returned, filled 51200, timestamp 8943102009, flags 0084
mmal: Buffer 0x7a10c8 returned, filled 51200, timestamp 8943103660, flags 0004
mmal: Buffer 0x7a12a0 returned, filled 51200, timestamp 8943103660, flags 0084
mmal: Buffer 0x7a0d18 returned, filled 51200, timestamp 8943105311, flags 0004
...Code: Select all
$ bc -ql
1000000/(8943102009-8943100358)
605.69351907934585099939
1000000/(8943103660-8943102009)
605.69351907934585099939
1000000/(8943105311-8943103660)
605.69351907934585099939

My previous response that I tested that and it makes no difference was based on modes with 180fps or 360fps. For these modes the statement remains true.
Code: Select all
$ rm /dev/shm/out*raw
$ time ( raspiraw -hd -md 9 -t 1000 -sr 1 -o /dev/shm/out.%04d.raw 2>err >/dev/null )
real 0m1.091s
user 0m0.090s
sys 0m0.470s
$ ll /dev/shm/out*raw | wc --lines
463
$ Code: Select all
$ rm /dev/shm/out*raw
$ time ( raspiraw -hd -md 9 -t 1000 -sr 1 -o /dev/shm/out.%04d.raw 2>/dev/shm/err >/dev/null )
real 0m1.082s
user 0m0.140s
sys 0m0.480s
$ ll /dev/shm/out*raw | wc --lines
589
$ Code: Select all
$ rm /dev/shm/out*raw
$ time ( raspiraw -hd -md 9 -t 1000 -sr 1 -o /dev/shm/out.%04d.raw 2>/dev/null >/dev/null )
real 0m1.079s
user 0m0.110s
sys 0m0.490s
$ ll /dev/shm/out*raw | wc --lines
600
$Agreed, good news is that there will be no new modes besides 1-7, high framerate options will just modify those existing. Later after lot of testing by you, me and others maybe new modes that make sense may arise.6by9 wrote: ↑Mon Dec 04, 2017 10:28 amThe main thing on the firmware is supporting a sensible set of modes. FOV is more important to most people than very high speed capture - far too many memories of all the complaints early on when video was the cropped 1080P mode and stills were the full 5MPix. I'm afraid you are the exception, which is part of the reason we're trying to open up the drivers where possible, but all settings are then your responsiblity!
Thank you for fixing, I verified that the fix is good for all temporary new modes.6by9 wrote: ↑Wed Dec 06, 2017 11:39 amFixed and rawcam branch updated. My bad, I was stating what it sounded like and that needed to be the first thing to check.
The default format was VGA raw10, resulting in a 384000 byte buffer. The framework would increase that should the buffer size requirements increase, but would never decrease it. raspiraw didn't copy the values from buffer_size_recommended across, therefore you ended up with a minimum of 384000.
I am just learning how to use github. I learned already that I have to create my own fork of your userland for doing a pull request, and did that. I added raspiraw documentation (new raspiraw folder with just README.md), and many new options. Will test more, and check and extend documentation.
Code: Select all
-r, --regs : Change regs of current mode
-hi, --hinc : Set horizontal odd/even inc
-vi, --vinc : Set vertical odd/even inc
-f, --fps : Set framerate
-w, --width : Set width
-h, --height : Set height
-v, --vts : Set min_vts
-l, --line : Set line_time_ns
-hd0, --header0 : Write the BRCM header to output file 0
-0, --zero : Write empty output files
Code: Select all
$ rm /dev/shm/out.*.raw
$ raspiraw -md 5 -t 1000 -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
30
$ rm /dev/shm/out.*.raw
$ raspiraw -md 5 -t 1000 --fps 49 -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
49
$
Code: Select all
$ rm /dev/shm/out.*.raw
$ raspiraw -md 7 -t 1000 -h 64 -v 65 -l 10000 --vinc 3D --fps 600 -r "380A,0040;3802,78;3806,05FF" -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
604
$

Sorry, missed this one before.PierreG wrote: ↑Thu Dec 07, 2017 1:08 pmHi everybody!
I'm thinking about interfacing another sony imx sensor (224) with Rpi3.
What is the requirements to get raw image with raspiraw?
1) Design/use a sensor board
2) Connect i2c/clock/CSI between sensor board and rpi
3) Define the sensor registers and mode in *_modes.h file
4) run raspiraw, debug and pray
Did someone try to connect another sensor than imx219 and ov5647?


ADV7282M setup now fixed on https://github.com/6by9/raspiraw (although it seems to have the potential for memory corruption - adding an extra few lines of padding to the buffer seems to fix it).
Code: Select all
$ rm /dev/shm/out.*.raw
$ raspiraw -md 7 -t 1000 -hd0 -h 64 -v 65 -l 10000 --vinc 3D --fps 600 -r "380A,0040;3802,78;3806,05FF" -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
604
$

Code: Select all
$ cat raw2ogg2anim
#!/bin/bash
echo "copying /dev/shm/out.????.raw files"
# cp /dev/shm/out.????.raw .
for((i=300; i<324; ++i))
do
cat /dev/shm/out.0000.raw /dev/shm/out.0$i.raw > out.0$i.raw
done
echo "dcraw each .raw file (to .ppm)"
for f in *.raw
do
dcraw $f
echo -en "$f \r"
done
echo
echo ".ppm -> .ppm.d"
for f in *.ppm
do
double $f > $f.d
echo -en "$f \r"
done
echo
echo ".ppm.d -> .ppm.d.png"
for f in *.ppm.d
do
pnmtopng $f > $f.png
echo -en "$f \r"
done
echo
echo "now creating $1.ogg"
gst-launch-1.0 multifilesrc location="out.%04d.ppm.d.png" index=300 caps="image/png,framerate=\(fraction\)1/1" ! pngdec ! videorate ! videoconvert ! videorate ! theoraenc ! oggmux ! filesink location="$1.ogg"
echo "now creating $1.anim.gif"
gifenc.sh $1.ogg $1.anim.gif
echo "done"
$
Thank you for that. raspiraw is such a cool piece of software -- definitely deserving its own repository!6by9 wrote: ↑Mon Dec 11, 2017 10:52 amRaspiraw app is now split out from userland to https://github.com/6by9/raspiraw.
It should have the required source, camera_i2c script, buildme (I probably should have done a makefile - never mind), and a copy of rpi3-gpiovirtbuf.
That's true, under userland I did compile changes with "make -C ~/userland/build/raspberry/release raspiraw/fast" in less than 10 seconds on a Pi 2B. On same Pi 2B "./buildme" takes just 3 seconds.
You can delete the repository, I did so with my userland fork from you.
Code: Select all
$ rm /dev/shm/out*raw
$ raspiraw -md 7 -t 1000 -ts -hd0 -h 64 -v 65 -l 10000 --vinc 3D --fps 600 -r "380A,0040;3802,78;3806,05FF" -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
607
$
Code: Select all
$ cat /dev/shm/out.-001.raw | cut -f1 -d, | sort -n | uniq -c
1
3 1648
2 1649
61 1650
532 1651
1 1652
3 1653
2 1654
$
Code: Select all
$ echo "1000000/1651" | bc -ql
605.69351907934585099939
$ Code: Select all
$ cat /dev/shm/out.-001.raw | cut -f1 -d, | sort -n | uniq -c
1
65 1650
531 1651
4 1652
2 3302
$
Code: Select all
$ grep "^3" /dev/shm/out.-001.raw
3302,2,14461261624
3302,91,14461410205
$ Code: Select all
$ rm /dev/shm/out*raw
$ raspiraw -md 7 -t 8000 -ts -hd0 -h 64 -v 65 -l 10000 --vinc 3D --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
5317
$Code: Select all
$ cat /dev/shm/out.-001.raw | cut -f1 -d, | sort -n | uniq -c
1
22 1498
251 1499
312 1500
274 1501
1061 1502
2388 1503
277 1504
282 1505
309 1506
132 1507
5 3005
1 3006
$
Code: Select all
$ grep ^3 /dev/shm/out.-001.raw
3005,2,27911765057
3005,84,27911889785
3006,1089,27913401545
3005,1691,27914307698
3005,1823,27914507563
3005,2292,27915213852
$



Code: Select all
$ raspiraw -md 7 -t 8000 -ts -hd0 -h 120 -v 121 -l 10000 --vinc 3D --fps 360 -r "380A,0078;3802,78;3806,063B" -sr 1 -o /dev/shm/out.%04d.raw 2>/dev/null


Code: Select all
$ echo "3280*2464/(2592*1944)" | bc -ql
1.60392216633643245440
$
Code: Select all
$ ./md2 2000
removing /dev/shm/out.*.raw
capturing frames for 2000ms with 15 requested
30 frames were captured at 15fps
frame delta time[us] distribution
1
1 66663
16 66664
12 66665
after skip frame indices (middle column)
0% frame skips
$
$ df /dev/shm
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 189784 187680 2104 99% /dev/shm
$
Code: Select all
$ ./md2.sd 4000
removing out.*.raw
capturing frames for 4000ms with 3 requested
12 frames were captured at 3fps
frame delta time[us] distribution
1
2 333321
8 333322
1 333323
after skip frame indices (middle column)
0% frame skips
$
Code: Select all
raspiraw -md 2 -t 4000 -hd --fps 3 -sr 1 -o out.%04d.raw 2>/dev/null >/dev/null
It's mainly a question of how fast your storage is. raspiraw as it stands will be running the camera at 15fps 8MPix 10bits/pixel. That's 144Mbytes/s. Almost no storage will cope with that.mab333 wrote: ↑Fri Dec 22, 2017 10:19 amHermannSW, thank you very much for an expedient and detailed answer - I will look into your recommendations.
A couple of quick follow up questions:
1. If I want to capture a sequence of images for 15 seconds or so, it sounds like there will be some frames skipped (with Pi Zero more often, than with Pi 3). However, would it be the case that only 1 frame is skipped and then you get another sequence of frames without interruption?
So every buffer that comes back is timestamped via the pts field in the MMAL_BUFFER_HEADER_T. It's based off the GPU's microsecond accuracy clock at the point the Frame Start interrupt fires.mab333 wrote:2. Finally, I assume it is also possible to apply a timestamp to the saved file, so you can identify the time difference between the consecutive and skipped frames. My project is focusing on tracking micro-objects in the image and characterizing their speed and trajectories. That is why having a relatively high FPS and an ability to precisely know the timing of the images is important.
So in this case if, as you say, currently raspiraw is running the sensor at 15fps 8Mpix 10bits/pixel = 144Mbytes/s, then if I set it to, say, capture every 4th frame (giving me effective fps of ~3.7), it would end up being roughly 40Mbytes/s. As I understand, if I opt for a, say, UHS-1 sd card and enable sd card overclocking on PI, it should be able to support that capture rate. Is my thinking correct?6by9 wrote: ↑Fri Dec 22, 2017 11:57 amIt's mainly a question of how fast your storage is. raspiraw as it stands will be running the camera at 15fps 8MPix 10bits/pixel. That's 144Mbytes/s. Almost no storage will cope with that.
The default setup is to save one frame every N frames (N set on the command line with "-sr N", default of 20), and therefore drop the capture rate to something more manageable. (It is however blocking the capture thread, so it isn't totally even).
HermannSW has just added frame rate control to raspiraw for the V1 OV5647 sensor (I need to review the pull request again) as the better option is to tell the sensor to run at your desired 2fps than drop frames in a potentially unpredictable manner. That change hasn't been done for the V2 IMX219 sensor yet, and I'm constrained due to NDAs as to what I can say.

As long as they are using MB/s as MegaBytes/s and not MegaBits/s, then you've got a fighting chance.mab333 wrote: ↑Fri Dec 22, 2017 12:27 pmSo in this case if, as you say, currently raspiraw is running the sensor at 15fps 8Mpix 10bits/pixel = 144Mbytes/s, then if I set it to, say, capture every 4th frame (giving me effective fps of ~3.7), it would end up being roughly 40Mbytes/s. As I understand, if I opt for a, say, UHS-1 sd card and enable sd card overclocking on PI, it should be able to support that capture rate. Is my thinking correct?

You're limited by USB2 bandwidth (480Mbit/s, or 60MBytes/s, if my maths/memory are correct)






