MATLAB: Simulink with Raspberry Pi Camera Capture

MATLABraspberry pisimulink

Hi all,
As is documented here, http://www.mathworks.co.uk/help/simulink/raspberry-pi.html, simulink offers hardware functionality with the Pi, however there are no functions or examples for using the new pi cameras. Such as image capture, instead there is only support for webcam video capture.
Would using the camera be easy to implement without this support, or do I need to find another method other than simulink?
Thanks

Best Answer

The Raspberry Pi camera is supported by the Simulink. The Raspberry Pi Simulink Block library has a block called "V4L2 Video Capture". This block can capture images from any camera that has a V4L2 driver. Raspberry Pi foundation has recently released a V4L2 driver for the pi camera. Hence this block is compatible with the Raspberry Pi camera. Also note that the new (R2014a) MATLAB Support Package for Raspberry Pi Hardware supports capturing images from the Raspberry Pi camera module directly from the MATLAB command line.
In order to use V4L2 Video Capture Simulink block with the Raspberry Pi camera module, follow the instructions below (step 1 & 2 below is needed only for R2013a/R2013b releases):
1. Upgrade your Raspbian image to the latest to get the official V4L2 driver for Camera Board:
# sudo apt-get update
# sudo apt-get dist-upgrade
# sudo rpi-update
2. Reboot
# sudo reboot
3. After reboot, execute the following command to load the V4L2 driver for the Raspberry Pi Camera:
# sudo modprobe bcm2835-v4l2
After this step, you should see a /dev/video0 device (check by "ls -al /dev/vid*") that corresponds to the Camera Board. Now use the V4L2 Video Capture Block to capture images from this video device.
Note that you need to perform step 3 above every time you reboot your board. You can incorporate the command in step 3 into "/etc/rc.local" to automatically load the V4L2 driver at boot time.
Related Question