Simulink with Raspberry Pi Camera Capture
조회 수: 27 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Murat Belge
2014년 3월 19일
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.
댓글 수: 3
Jose
2014년 9월 12일
Hi Chris,
You can put that line in rc.local before "exit 0" line:
[...]
su -c "sudo modprobe bcm2835-v4l2" pi
exit 0
Zuzanna
2016년 1월 7일
편집: Zuzanna
2016년 1월 7일
For me it wasn't working. After tuning off and on the Raspberry Pi I had to type sudo modprobe bcm2835-v4l2 again...
But this tutorial helped me a lot:
I think that crucial thing is to load drivers manualy (modprobe bcm2835-v4l2) and than add sth to any file.
추가 답변 (1개)
Will
2014년 3월 19일
댓글 수: 1
Hamza Idris
2017년 1월 7일
hey Murat! after the process you defined above. I have a code of matlab fcn taking snapshot using command image=snapshot(cam) let cam be camera function do i need to use this command now. please help..
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!