Difference between revisions of "AXIOM Alpha Software"

From apertus wiki
Jump to: navigation, search
(Created page with " ==Reading and Writing Sensor Register== This example script: #!/bin/sh cmv_reg() { addr=$(( 0x60000000 + ($1 * 4) )) [ $# -gt 1 ] && devmem $addr 32 $2 devmem...")
 
Line 1: Line 1:
==Reading and Writing Sensor Register==
==Reading and Writing Sensor Register==


This example script:
Execute the script that contains the sensor interface functions before we can use them:
. ./cmv.func


#!/bin/sh
Set Sensor register 82 to the decimal value "3122"
cmv_reg() {
  cmv_reg  82   3122
    addr=$(( 0x60000000 + ($1 * 4) ))
    [ $# -gt 1 ] && devmem $addr 32 $2
    devmem $addr 32
}
#change the registers 69/98/102/107/108/112 and 124               
cmv_reg  69      2
  cmv_reg  98  39705
cmv_reg 102   8312
cmv_reg 107  9814
cmv_reg 108  12381
cmv_reg 112      5
cmv_reg 124    15
#read the register 127
cmv_reg 127


basically the registers get mapped to 32bit spaces starting at a specific memory address (0x60000000 in this case), reading from that memory will show the register, writing to that memory will change it
Read Register 82:
 
  cmv_reg  82
so register '0' is at 0x60000000, register '1' at 0x60000004 ...


will output:
0x00000C31


This example script reads the current bitdepth the sensor is running with:
get_bitdepth () {
depth=$(( `cmv_reg 118` + 0 ))
[ $depth -eq 0 ] && echo "12 bit mode"
[ $depth -eq 1 ] && echo "10 bit mode"
[ $depth -eq 2 ] && echo "8 bit mode"
}
===statically linked busybox===
===statically linked busybox===
http://vserver.13thfloor.at/Stuff/AXIOM/FAKE/
http://vserver.13thfloor.at/Stuff/AXIOM/FAKE/
Line 44: Line 24:


/bin/sh and /sbin/devmem both link to busybox on the axiom alpha filesystem so both can be tested with this executeable
/bin/sh and /sbin/devmem both link to busybox on the axiom alpha filesystem so both can be tested with this executeable
==Setting & Reading Sensor Registers==
Set Register:
. ./cmv.func
cmv_reg  82  3122
Read Register:
  cmv_reg  82
will output:
0x00000C31


==Capturing an Image==
==Capturing an Image==

Revision as of 19:15, 3 January 2014

1 Reading and Writing Sensor Register

Execute the script that contains the sensor interface functions before we can use them:

. ./cmv.func

Set Sensor register 82 to the decimal value "3122"

cmv_reg  82   3122

Read Register 82:

 cmv_reg  82

will output:

0x00000C31

1.1 statically linked busybox

http://vserver.13thfloor.at/Stuff/AXIOM/FAKE/

builtin fake devmem

all you need to get it to work is the following:

dd if=/dev/zero of=/tmp/mem bs=1k seek=4M count=1

this will create a sparse 4GB file /tmp/mem, which will be used by the fake devmem values written can be read back, non existing values return 0

/bin/sh and /sbin/devmem both link to busybox on the axiom alpha filesystem so both can be tested with this executeable

2 Capturing an Image

Preparations:

ssh root@*alpha-IP* "./cmv_train2

Capture the image:

ssh root@*alpha-IP* "./cmv_snap2 -e 10ms" | tee snap.raw16 | display -size 4096x3072 -depth 16 gray:-

So we dont need to type the password every time we snap an image:

Install:

sudo apt-get install sshpass

Use:

sshpass -p '1234' ssh root@*alpha-IP* "./cmv_snap2 -e 10ms" | tee snap.raw16 | display -size 4096x3072 -depth 16 gray:-

3 cmv_snap2

./cmv_snap2 -h
This is ./cmv_snap2 V1.5
options are:
-h        print this help message
-8        output 8 bit per pixel
-b        enable black columns
-r        dump sensor registers
-t        enable cmv test pattern
-e <exp>  exposure time
-m <val>  capture mask and value
-n <num>  number of frames
-s <num>  shift values by <num>
-B <val>  register mapping base
-S <val>  register mapping size
-M <val>  buffer memory base
-Z <val>  buffer memory size
-R <fil>  load sensor registers
-P <pat>  idle pattern

"./cmv_snap2 -r" without an -e parameter outputs only registers

4 cmv_hist2

Outputs a RAW histogram of the last snapped image. 4 columns (flip on: GRBG, flip off:RGGB) with 4096 values (when operating in 12 bit mode) each.

Download: http://vserver.13thfloor.at/Stuff/AXIOM/cmv_io2/cmv_hist2

./cmv_hist2
This is ./cmv_hist2 V1.0
options are:
-h        print this help message
-s        acquire snapshot
-B <val>  register mapping base
-S <val>  register mapping size
-M <val>  buffer memory base
-Z <val>  buffer memory size

4.1 Examples

./cmv_hist2 -s

Acquire new snapshot and output histogram

./cmv_hist2

Acquire histogram from last captured snapshot in memory

5 cmv_train2

./cmv_train2 -h
This is ./cmv_train2 V1.0
options are:
-h        print this help message
-a        test all bit pattern
-B <val>  memory mapping base
-S <val>  memory mapping size
-A <val>  memory mapping address
-P <val>  training pattern

6 Post Processing images

6.1 Create RGGB separated color images from raw file:

convert -size 4096x3072 -depth 16 -crop +0+0 -sample 2048x1536 gray:colors_500ms.raw16 gray:colors_500ms_ch0.raw
convert -size 4096x3072 -depth 16 -crop -1+0 -sample 2048x1536 gray:colors_500ms.raw16 gray:colors_500ms_ch1.raw
convert -size 4096x3072 -depth 16 -crop +0-1 -sample 2048x1536 gray:colors_500ms.raw16 gray:colors_500ms_ch2.raw
convert -size 4096x3072 -depth 16 -crop -1-1 -sample 2048x1536 gray:colors_500ms.raw16 gray:colors_500ms_ch3.raw

6.2 Simple debayer with ImageMagick:

For flipped images:

convert \( -size 4096x3072 -depth 16 gray:colors_500ms.raw16 \) \
\( -clone 0 -crop -1-1 \) \( -clone 0 -crop -1+0 \) \( -clone 0 -crop +0-1 \) \
-sample 2048x1536 \( -clone 2,3 -average \) -delete 2,3 -swap 0,1 +swap -combine colors_500ms.png

For unflipped images:

convert \( -size 4096x3072 -depth 16 gray:IT8_incand.raw16 \) \
\( -clone 0 -crop -1-1 \) \( -clone 0 -crop -1+0 \) \( -clone 0 -crop +0-1 \) \
-sample 2048x1536 \( -clone 0,1 -average \) -delete 0,1 +swap -combine IT8_incand.png

6.3 Plot Histogram of Raw Image

Create histogram values file with imagemagick:

convert -size 4096x3072 -depth 16 gray:image.raw16 -format "%c" histogram:info: > histogram.hist

Reformat the file:

gawk -F, '(NF>3) { printf "%d\t%d\n", $2/16, $1 }' 

Or all in one command:

convert -size 4096x3072 -depth 16 gray:image.raw16 -format %c histogram:info:- | gawk -F, '(NF>3) { printf "%d\t%d\n", $2/16, $1 }' > histogram.info

Then draw it with this gnuplot script:

set notitle
set term svg size 1024, 512
set xlabel "Values"
set ylabel "Number of Pixels"
set multiplot
set obj 1 rectangle behind from screen 0,0 to screen 1,1
set obj 1 fillstyle solid 1.0 fillcolor rgbcolor "white"
set xrange[0:4096]
set yrange[0:8000]
plot 	'histogram.info' using 1:2	with lines lc rgb "#FF0000"	title "name your curve", \
       'histogram2.info' using 1:2	with lines lc rgb "#FF0000"	title "name your curve"
unset multiplot

execute the script with:

gnuplot thescript > output.svg