Collecting RAW Images from IMX219 on BeaglePlay

Thought I’d drop a post here demonstrating how I went about reading single-frame Bayer-formatted images from Arducam IMX219 CSI-2 camera on BeaglePlay. Had seen a few posts on this topic that, while they are all several months old, apparently were unresolved. @RenierSTFR @damia

Module Driver

Applied IMX219 device-tree overlay supplied by @Nishanth_Menon here.

Neither the IMX219 nor AM625 SoC have image signal processing (ISP) blocks on their processors, meaning that using them to stream video was effectively impossible. However, seeing evidence of variously-successful attempts online, I took it upon myself to extract pixel data from the sensor via the V4L2 API.

Pipeline Configuration

Running media-ctl -d /dev/media-0 -p shows the IMX219 is being probed succesfully. All entities of the pipeline must, crucially, be configured in uniform before frames can be captured from the camera; configuring the sensor by itself results in an error

# media-ctl -V '"imx219 4-0010":0[SRGGB8/640x480]'
# media-ctl -V '"cdns_csi2rx.30101000.csi-bridge":0[SRGGB8/640x480]'
# media-ctl -V '"30102000.ticsi2rx":0[SRGGB8/640x480]'

Extracting Pictures to File

Fortunately, the V4L2 API provides a method to obtain a single-frame image from the camera’s memory buffer:

v4l2-ctl --device /dev/video0 --set-fmt-video=width=640,height=480,pixelformat=RGGB --stream-mmap --stream-to=picture.raw --stream-count=1

Items worth considering:

  • If the camera isn’t probing, confirm the CSI cable is connected in the proper orientation …
  • The WXH dimensions can presumably be configured to different values than those above.
  • While obtaining images from the camera is gratifying, note that the pixel format is 8-bit RGGB (Bayer); converting this into RGB and other formats requires add’l processing.

Further Reference:

1 Like

Thanks for this great writeup @egakaned !

Have you considered submitting this as a PR to Using CSI Cameras — BeagleBoard Documentation ?

Cc @lorforlinux , please take a look at this.

Do you know how (or is it possible) to access the I2C bus of the CSI, to control the sensor?

@Illia_Pikin I would assume it’s possible but it’s unfamiliar territory for me… Sorry I can’t be of greater help.

@dhruvag2000 Thanks a lot! Not sure why the Beagleplay Docs page is laid out this way but there is in fact a tutorial on using CSI under the “Expansion” heading. Also there’s a quick little tutorial in section 4.4 of the Beagleplay Manual on using CSI that was also helpful.