Successful I2C/CSI2 raspiraw capture with V2 camera IMX219 - Raspberry Pi Forums


for interested in using raspiraw v2 imx219 camera:
in persuit of triggering "instant" 5s exposure images without delay, have captured raw bayer still images rpi v2 noir (imx219) using i2c/csi2 support in vc.ril.rawcam mmal api. (many 6by9 this!)
followed raspiraw v1 camera setup instructions in forum thread viewtopic.php?f=43&t=109137&start=150

imx219 registers i've found far @ bottom of post. findings & experience welcome!

imx219 sensor turned out on address 0x10 using "i2cdetect -y 0".
random results; picture, no picture, pure noise or half noise/half picture.
after trial , error register settings, got repeatedly successful captures .
set streaming off (0x0100=0x00), setup registers, wait 3s before enabling streaming , save first capture.
can change analog (0x0157), digital (0x0158, 0x0159) gain , coarse integration (0x015a, 0x015b) registers fine.
i'll digging 5s exposure time, seems involve long lines & frames. interesting.

here's did capture raspiraw , v2 camera:

git clone git://git.drogon.net/wiringpi; cd wiringpi/; git pull origin; ./build
wget https://raw.githubusercontent.com/6by9/ ... camera_i2c; chmod +x camera_i2c
#added these lines @ end of /boot/config.txt
start_file=start_x.elf
dtparam=i2c_vc=on
dtparam=i2c_arm=on

#added these lines @ end of /etc/rc.local
sudo modprobe i2c_bcm2708 # needed probe /dev/i2cx show up
sudo modprobe i2c_dev

sudo apt-get install cmake; git clone https://github.com/6by9/userland.git;
cd userland; git fetch origin; git checkout -b rawcam origin/rawcam; sudo ./buildme; sudo ln -s /opt/vc/bin/raspiraw /usr/bin/raspiraw

~/camera_i2c # setup gpio pins camera operation
raspiraw # run camera , record raw frames

output 1,0237,440 bytes large raw bayer file. (matches jbeales comment in viewtopic.php?f=43&t=146310&p=1001567&h ... 9#p1001567)
data needs converted rgb, used picameras documentation python script [http://picamera.readthedocs.io/en/relea ... a-captures].
modified read in raw file (filename argument) directly no jpeg headers , setting resolution manually:

code: select all

... numpy.lib.stride_tricks import as_strided file = open(sys.argv[1], 'rb') stream = io.bytesio(file.read()) data = stream.getvalue() data = np.fromstring(data, dtype=np.uint8) ver=2 reshape, crop = {     1: ((1952, 3264), (1944, 3240)),     2: ((2480, 4128), (2464, 4100)), ...
spits out binary able open in gimp using 3280x2462 rgb format.

had reading these threads:
"pi camera v2 raw bayer data" viewtopic.php?f=43&t=146310&p=1001567&h ... 9#p1001567
"raw output information" viewtopic.php?f=43&t=44918&sid=1db39dfe ... &start=200


register information gathered these sources:
mediatek https://github.com/omlet05/mediatek-hel ... w_sensor.c
chromium https://chromium.googlesource.com/chrom ... a/imx219.c
android https://android.googlesource.com/kernel ... o/imx219.c
asus zenfone5 https://github.com/zenfonearea/android_ ... 9/imx219.h
linux v4l2 driver http://dl.linux-sunxi.org/sdk/a80/a80_s ... e/imx219.c, http://dl.linux-sunxi.org/sdk/a80/a80_s ... e/camera.h

color & white balancing aside, far i've found following setup give successful captures every time:
/

code: select all

* 3280x2464@15 fps */ {0x0100, 0x00}, 		// 0=off, 1=stream, 2=max 	{0x30eb, 0x05}, 	{0x30eb, 0x0c}, 	{0x300a, 0xff}, 	{0x300b, 0xff}, 	{0x30eb, 0x05}, 	{0x30eb, 0x09}, 	{0x0114, 0x01},		// csi mipi lanes [1:0]  (0x01=2, 0x03=4) 	{0x0128, 0x00},		// dphy_cntrl 	{0x012a, 0x18},		// exck_freq [15:8] 	{0x012b, 0x00},		// exck_freq [7:0] 	{0x0157, 0x00},         // analog gain 	{0x0158, 0x00},         // digital gain [15:8] 	{0x0159, 0x00}          // digital gain [7:0]         // {0x015a, 0x01},		// shutter/integration time [15:8]         // {0x015b, 0x00},		// shutter/integration time [7:0] 	{0x0160, 0x09},		// frame length [15:8] 	{0x0161, 0xc8},		// frame length [7:0] 	{0x0162, 0x0d},		// line length [15:8] 	{0x0163, 0x78},		// line length [7:0] 	{0x0164, 0x00}, 	{0x0165, 0x00}, 	{0x0166, 0x0c}, 	{0x0167, 0xcf}, 	{0x0168, 0x00}, 	{0x0169, 0x00}, 	{0x016a, 0x09}, 	{0x016b, 0x9f}, 	{0x016c, 0x0c}, 	{0x016d, 0xd0}, 	{0x016e, 0x09}, 	{0x016f, 0xa0}, 	{0x0170, 0x01},		// x_odd_inc [2:0] 	{0x0171, 0x01},		// y_odd_inc [2:0] 	{0x0172, 0x03}, 	{0x0174, 0x00},		// binning mode h_a 	{0x0175, 0x00},		// binning mode v_a 	{0x018c, 0x0a},		// csi data format [15:8] 	{0x018d, 0x0a},		// csi data format [7:0] 	{0x0301, 0x05},		// vtpxck_div 	{0x0303, 0x01},		// vtsyck_div 	{0x0304, 0x03},		// prepllck_vt_div [3:0] 	{0x0305, 0x03},		// prepllck_op_div [3:0] 	{0x0306, 0x00},		// pll_vt_mpy [10:8] 	{0x0307, 0x2b},		// pll_vt_mpy [7:0] 	{0x0309, 0x0a},		// oppxck_div [4:0] 	{0x030b, 0x01},		// opsyck_div  	{0x030c, 0x00},		// pll_op_mpy [10:8] 	{0x030d, 0x55},		// pll_op_mpy [7:0] 	{0x455e, 0x00},		// cis tuning ? 	{0x471e, 0x4b},		// cis tuning ? 	{0x4767, 0x0f},		// cis tuning ? 	{0x4750, 0x14},		// cis tuning ? 	{0x4540, 0x00},		// cis tuning ? 	{0x47b4, 0x14},		// cis tuning ? 	{0x4713, 0x30},		// cis tuning ? 	{0x478b, 0x10},		// cis tuning ? 	{0x478f, 0x10},		// cis tuning ? 	{0x4797, 0x0e},		// cis tuning ? 	{0x479b, 0x0e},		// cis tuning ? {0x0100, 0x01}



raspberrypi



Comments