Skip to content
Permalink
Browse files

Bulk commit of everything contained in raspiraw.drop.5_26_18.zip

  • Loading branch information...
Hermann-SW committed May 27, 2018
1 parent 7fe5f72 commit 7362b3b07c90e1d9b1ee22fe421ef6c65f9d6461
Showing with 167 additions and 70 deletions.
  1. +6 −0 adv7282m_modes.h
  2. +6 −0 imx219_modes.h
  3. +6 −0 ov5647_modes.h
  4. +64 −20 raspiraw.c
  5. +25 −0 tools/1296x704_S
  6. +2 −23 tools/1296x720_S
  7. +25 −0 tools/1296x720_s
  8. +2 −23 tools/1296x730_s
  9. +2 −0 tools/camera_i2c_
  10. +11 −0 tools/camver
  11. BIN tools/double
  12. +17 −4 tools/double.c
  13. +1 −0 tools/raspiraw
@@ -341,6 +341,12 @@ struct sensor_def adv7282 = {

.gain_reg = 0,
.gain_reg_num_bits = 0,

.xos_reg = 0,
.xos_reg_num_bits = 0,

.yos_reg = 0,
.yos_reg_num_bits = 0,
};

#endif
@@ -621,6 +621,12 @@ struct sensor_def imx219 = {

.gain_reg = 0x0157,
.gain_reg_num_bits = 8, //Only valid up to 230.

.xos_reg = 0x016C,
.xos_reg_num_bits = 12, // x_output_size [11:8] and [7:0] (imx219 datasheet)

.yos_reg = 0x016E,
.yos_reg_num_bits = 12, // y_output_size [11:8] and [7:0] (imx219 datasheet)
};

#endif
@@ -886,6 +886,12 @@ struct sensor_def ov5647 = {

.gain_reg = 0x350A,
.gain_reg_num_bits = 10,

.xos_reg = 0x3808,
.xos_reg_num_bits = 12, // x_output_size [11:8] and [7:0] (ov5647 datasheet)

.yos_reg = 0x380A,
.yos_reg_num_bits = 12, // y_output_size [11:8] and [7:0] (ov5647 datasheet)
};

#endif
@@ -134,6 +134,12 @@ struct sensor_def

uint16_t gain_reg;
int gain_reg_num_bits;

uint16_t xos_reg;
int xos_reg_num_bits;

uint16_t yos_reg;
int yos_reg_num_bits;
};


@@ -169,6 +175,8 @@ enum {
CommandRegs,
CommandHinc,
CommandVinc,
CommandVoinc,
CommandHoinc,
CommandFps,
CommandWidth,
CommandHeight,
@@ -201,7 +209,9 @@ static COMMAND_LIST cmdline_commands[] =
{ CommandAwbGains, "-awbgains", "awbg", "Set the AWB gains to use.", 1 },
{ CommandRegs, "-regs", "r", "Change (current mode) regs", 0 },
{ CommandHinc, "-hinc", "hi", "Set horizontal odd/even inc reg", -1},
{ CommandVinc, "-vinc", "vi", "Set vertical odd/even inc reg", -1},
{ CommandVinc, "-vinc", "vi", "Set vertical odd/even inc reg", -1}, // ov5647
{ CommandVoinc, "-voinc", "voi","Set vertical odd inc reg", -1}, // imx219
{ CommandHoinc, "-hoinc", "hoi","Set horizontal odd inc reg", -1}, // imx219
{ CommandFps, "-fps", "f", "Set framerate regs", -1},
{ CommandWidth, "-width", "w", "Set current mode width", -1},
{ CommandHeight, "-height", "h", "Set current mode height", -1},
@@ -241,6 +251,8 @@ typedef struct {
char *regs;
int hinc;
int vinc;
int voinc;
int hoinc;
double fps;
int width;
int height;
@@ -751,6 +763,22 @@ static int parse_cmdline(int argc, char **argv, RASPIRAW_PARAMS_T *cfg)
i++;
break;

case CommandVoinc:
if (strlen(argv[i+1]) != 2 ||
sscanf(argv[i + 1], "%x", &cfg->voinc) != 1)
valid = 0;
else
i++;
break;

case CommandHoinc:
if (strlen(argv[i+1]) != 2 ||
sscanf(argv[i + 1], "%x", &cfg->hoinc) != 1)
valid = 0;
else
i++;
break;

case CommandFps:
if (sscanf(argv[i + 1], "%lf", &cfg->fps) != 1)
valid = 0;
@@ -862,6 +890,8 @@ int main(int argc, char** argv) {
.regs = NULL,
.hinc = -1,
.vinc = -1,
.voinc = -1,
.hoinc = -1,
.fps = -1,
.width = -1,
.height = -1,
@@ -949,14 +979,26 @@ int main(int argc, char** argv) {

if (cfg.hinc >= 0)
{
// TODO: handle modes different to ov5647 as well
modReg(sensor_mode, 0x3814, 0, 7, cfg.hinc, EQUAL);
if (!strcmp(sensor->name, "ov5647"))
modReg(sensor_mode, 0x3814, 0, 7, cfg.hinc, EQUAL);
}

if (cfg.vinc >= 0)
{
// TODO: handle modes different to ov5647 as well
modReg(sensor_mode, 0x3815, 0, 7, cfg.vinc, EQUAL);
if (!strcmp(sensor->name, "ov5647"))
modReg(sensor_mode, 0x3815, 0, 7, cfg.vinc, EQUAL);
}

if (cfg.voinc >= 0)
{
if (!strcmp(sensor->name, "imx219"))
modReg(sensor_mode, 0x0171, 0, 2, cfg.voinc, EQUAL);
}

if (cfg.hoinc >= 0)
{
if (!strcmp(sensor->name, "imx219"))
modReg(sensor_mode, 0x0170, 0, 2, cfg.hoinc, EQUAL);
}

if (cfg.fps > 0)
@@ -968,34 +1010,36 @@ int main(int argc, char** argv) {

if (cfg.width > 0)
{
sensor_mode->width = cfg.width;
// TODO: handle modes different to ov5647 as well
modReg(sensor_mode, 0x3808, 0, 3, cfg.width >>8, EQUAL);
modReg(sensor_mode, 0x3809, 0, 7, cfg.width &0xFF, EQUAL);
sensor_mode->width = cfg.width;
modReg(sensor_mode, sensor->xos_reg+0, 0, 3, cfg.width >>8, EQUAL);
modReg(sensor_mode, sensor->xos_reg+1, 0, 7, cfg.width &0xFF, EQUAL);
}

if (cfg.height > 0)
{
sensor_mode->height = cfg.height;
// TODO: handle modes different to ov5647 as well
modReg(sensor_mode, 0x380A, 0, 3, cfg.height >>8, EQUAL);
modReg(sensor_mode, 0x380B, 0, 7, cfg.height &0xFF, EQUAL);
modReg(sensor_mode, sensor->yos_reg+0, 0, 3, cfg.height >>8, EQUAL);
modReg(sensor_mode, sensor->yos_reg+1, 0, 7, cfg.height &0xFF, EQUAL);
}

if (cfg.left > 0)
{
// TODO: handle modes different to ov5647 as well
int val = cfg.left * (cfg.mode < 2 ? 1 : 1 << (cfg.mode / 2 - 1));
modReg(sensor_mode, 0x3800, 0, 3, val >>8, EQUAL);
modReg(sensor_mode, 0x3801, 0, 7, val &0xFF, EQUAL);
if (!strcmp(sensor->name, "ov5647"))
{
int val = cfg.left * (cfg.mode < 2 ? 1 : 1 << (cfg.mode / 2 - 1));
modReg(sensor_mode, 0x3800, 0, 3, val >>8, EQUAL);
modReg(sensor_mode, 0x3801, 0, 7, val &0xFF, EQUAL);
}
}

if (cfg.top > 0)
{
// TODO: handle modes different to ov5647 as well
int val = cfg.top * (cfg.mode < 2 ? 1 : 1 << (cfg.mode / 2 - 1));
modReg(sensor_mode, 0x3802, 0, 3, val >>8, EQUAL);
modReg(sensor_mode, 0x3803, 0, 7, val &0xFF, EQUAL);
if (!strcmp(sensor->name, "ov5647"))
{
int val = cfg.top * (cfg.mode < 2 ? 1 : 1 << (cfg.mode / 2 - 1));
modReg(sensor_mode, 0x3802, 0, 3, val >>8, EQUAL);
modReg(sensor_mode, 0x3803, 0, 7, val &0xFF, EQUAL);
}
}


@@ -0,0 +1,25 @@
#!/bin/bash

if [ "$1" = "" ]; then echo "format: `basename $0` ms"; exit; fi

echo "removing /dev/shm/out.*.raw"
rm -f /dev/shm/out.*.raw

fps=190
echo "capturing frames for ${1}ms with ${fps}fps requested"
raspiraw -md 5 -t $1 -ts tstamps.csv -hd0 hd0.32k --height 176 --top 0 --vinc F1 --fps $fps -sr 1 -o /dev/shm/out.%04d.raw 2>/dev/null >/dev/null

us=`cut -f1 -d, tstamps.csv | sort -n | uniq -c | sort -n | tail -1 | cut -b9-`
l=`ls -l /dev/shm/out.*.raw | wc --lines`
echo "$l frames were captured at $((1000000 / $us))fps"

echo "frame delta time[us] distribution"
cut -f1 -d, tstamps.csv | sort -n | uniq -c

echo "after skip frame indices (middle column)"
grep "^[1-46-9]" tstamps.csv

skips=`grep "^[1-46-9]" tstamps.csv | wc --lines | cut -f1 -d\ `
stamps=`wc --lines tstamps.csv | cut -f1 -d\ `
per=`expr \( 100 \* $skips \) / \( $skips + $stamps \)`
echo "$per% frame skips"
@@ -1,25 +1,4 @@
#!/bin/bash
echo "please use 1296x704_s instead"

if [ "$1" = "" ]; then echo "format: `basename $0` ms"; exit; fi

echo "removing /dev/shm/out.*.raw"
rm -f /dev/shm/out.*.raw

fps=190
echo "capturing frames for ${1}ms with ${fps}fps requested"
raspiraw -md 5 -t $1 -ts tstamps.csv -hd0 hd0.32k --height 180 --top 0 --vinc F1 --fps $fps -sr 1 -o /dev/shm/out.%04d.raw 2>/dev/null >/dev/null

us=`cut -f1 -d, tstamps.csv | sort -n | uniq -c | sort -n | tail -1 | cut -b9-`
l=`ls -l /dev/shm/out.*.raw | wc --lines`
echo "$l frames were captured at $((1000000 / $us))fps"

echo "frame delta time[us] distribution"
cut -f1 -d, tstamps.csv | sort -n | uniq -c

echo "after skip frame indices (middle column)"
grep "^[1-46-9]" tstamps.csv

skips=`grep "^[1-46-9]" tstamps.csv | wc --lines | cut -f1 -d\ `
stamps=`wc --lines tstamps.csv | cut -f1 -d\ `
per=`expr \( 100 \* $skips \) / \( $skips + $stamps \)`
echo "$per% frame skips"
# https://www.raspberrypi.org/forums/viewtopic.php?f=43&p=1319906#p1319906
@@ -0,0 +1,25 @@
#!/bin/bash

if [ "$1" = "" ]; then echo "format: `basename $0` ms"; exit; fi

echo "removing /dev/shm/out.*.raw"
rm -f /dev/shm/out.*.raw

fps=114
echo "capturing frames for ${1}ms with ${fps}fps requested"
raspiraw -md 5 -t $1 -ts tstamps.csv -hd0 hd0.32k --height 360 --top 0 --vinc 71 --fps $fps -sr 1 -o /dev/shm/out.%04d.raw 2>/dev/null >/dev/null

us=`cut -f1 -d, tstamps.csv | sort -n | uniq -c | sort -n | tail -1 | cut -b9-`
l=`ls -l /dev/shm/out.*.raw | wc --lines`
echo "$l frames were captured at $((1000000 / $us))fps"

echo "frame delta time[us] distribution"
cut -f1 -d, tstamps.csv | sort -n | uniq -c

echo "after skip frame indices (middle column)"
grep "^[1-79]" tstamps.csv

skips=`grep "^[1-79]" tstamps.csv | wc --lines | cut -f1 -d\ `
stamps=`wc --lines tstamps.csv | cut -f1 -d\ `
per=`expr \( 100 \* $skips \) / \( $skips + $stamps \)`
echo "$per% frame skips"
@@ -1,25 +1,4 @@
#!/bin/bash
echo "please use 1296x720_s instead"

if [ "$1" = "" ]; then echo "format: `basename $0` ms"; exit; fi

echo "removing /dev/shm/out.*.raw"
rm -f /dev/shm/out.*.raw

fps=98
echo "capturing frames for ${1}ms with ${fps}fps requested"
raspiraw -md 5 -t $1 -ts tstamps.csv -hd0 hd0.32k --height 365 --top 0 --vinc 71 --fps $fps -sr 1 -o /dev/shm/out.%04d.raw 2>/dev/null >/dev/null

us=`cut -f1 -d, tstamps.csv | sort -n | uniq -c | sort -n | tail -1 | cut -b9-`
l=`ls -l /dev/shm/out.*.raw | wc --lines`
echo "$l frames were captured at $((1000000 / $us))fps"

echo "frame delta time[us] distribution"
cut -f1 -d, tstamps.csv | sort -n | uniq -c

echo "after skip frame indices (middle column)"
grep "^[2-9]" tstamps.csv

skips=`grep "^[2-9]" tstamps.csv | wc --lines | cut -f1 -d\ `
stamps=`wc --lines tstamps.csv | cut -f1 -d\ `
per=`expr \( 100 \* $skips \) / \( $skips + $stamps \)`
echo "$per% frame skips"
# https://www.raspberrypi.org/forums/viewtopic.php?f=43&p=1319906#p1319906
@@ -0,0 +1,2 @@
#!/bin/bash
cd `dirname $0`/.. && ./camera_i2c
@@ -0,0 +1,11 @@
#!/bin/bash
dt=`vcgencmd get_camera | grep "detected=1"`
if [ "$dt" = "" ]; then
echo "no camera detected"
else
cd ~/raspiraw ; ./camera_i2c 2>&1 | cat > /dev/null
v1=`i2cdetect -y 0 54 54 | grep " 36"` ; v2=`i2cdetect -y 0 16 16 | grep " 10"`
if [ "$v1" != "" ]; then echo -n "v1"; fi
if [ "$v2" != "" ]; then echo -n "v2"; fi
echo " camera found"
fi
BIN +4.03 KB (150%) tools/double
Binary file not shown.
@@ -6,23 +6,36 @@ int main(int argc, char *argv[])
{
FILE *src = fopen(argv[1],"rb");
char line[9999],m;
int w,h,f,i;
int w,h,f,i,j,x=(argc>2)?2:1;

assert(src);
fgets(line, 9999, src); assert(0 == strcmp(line, "P6\n") || 0 == strcmp(line, "P5\n"));
m=line[1];
fgets(line, 9999, src); assert(2 == sscanf(line, "%d %d", &w, &h));
fgets(line, 9999, src); assert(1 == sscanf(line, "%d", &f));
assert(3*w < 9999);
assert(9 <= printf("P%c\n%d %d\n%d\n",m,w,2*h,f));
assert(9 <= printf("P%c\n%d %d\n%d\n",m,w*x,2*h,f));

f = (m=='5') ? 1 : 3;

for(i=0; i<h; ++i)
{
assert(f*w == fread(line, 1, f*w, src));
assert(f*w == fwrite(line, 1, f*w, stdout));
assert(f*w == fwrite(line, 1, f*w, stdout));
if (x==2)
{
for(j=w-1; j>=0; --j)
{
if (f==1) { line[2*j]=line[2*j+1]=line[j]; }
else
{
line[2*j*f+0] = line[(2*j+1)*f+0] = line[j*f+0];
line[2*j*f+1] = line[(2*j+1)*f+1] = line[j*f+1];
line[2*j*f+2] = line[(2*j+1)*f+2] = line[j*f+2];
}
}
}
assert(f*w*x == fwrite(line, 1, f*w*x, stdout));
assert(f*w*x == fwrite(line, 1, f*w*x, stdout));
}

h=ftell(src); fseek(src, 0, SEEK_END); assert(h == ftell(src));

1 comment on commit 7362b3b

@Hermann-SW

This comment has been minimized.

Copy link
Owner Author

commented on 7362b3b May 27, 2018

v1 and v2 directory tools of raspiraw.drop.5_26_18.zip are missing from this commit, those tools will be joined into tools directory and commited soon.

Please sign in to comment.
You can’t perform that action at this time.