MATLAB Answers

Using Raspberry Pi cameraboard for realtime acquisition in simulink

14 views (last 30 days)
Marco
Marco on 24 May 2014
Commented: Marco on 11 Jun 2014
Hello,
I have seen that in new MAtlab (2014a) you can control raspberry pi cameraboard by class:
but it works by for loop and taking snapshots, and furthermore you must specify the duration of acquisition. I have red in this topic that you can set V4L2 block as default camera:
I have tried that but it has a lag as usb camera (I guess because there are however the Linux drivers).
So I have seen that it runs in real-time acquisition if I use Linux-shell commands like:
[status, message] = h.execute(['raspivid -o vid.h264 -t 20000']) %where 20000 is the duration of acquisition in msec
I thought that I can use above code in a 'MATLAB Function' block but I guess it is not supported by C/C++ code generation because I don't see it in the list of supported functions. Some suggestions to perform a rea-time acquisition with raspberryPi's cameraboard? Thanks

  0 Comments

Sign in to comment.

Answers (1)

Murat Belge
Murat Belge on 4 Jun 2014
Marco,
The MATLAB Support Package for Raspberry Pi includes support for real-time acquisition from Camera Board. You need to use the snapshot() methods of the cameraboard object in a loop. If you complete your image processing within frame capture time, usually 33ms, this method provides a low-latency way of capturing and analyzing images from Raspberry Pi camera. Take a look at the Green Ball Detection example included in the MATLAB Support Package for Raspberry Pi.
The command you are citing, raspivid -o vid.h264 -t 20000, just captures a 20 second video clip and saves it onto the SD card of the Raspberry Pi. You can then retrieve the video file in Simulink for online analysis. Since you cannot access the captured video while recording is in progress, I would not call this real-time acquisition.
What exactly you are trying to do with the Raspberry Pi Camera? Object tracking, face detection, etc.? I might offer better help if you detail your use case.

  1 Comment

Marco
Marco on 11 Jun 2014
Sorry for my delay. Yes you have understood. I am trying to do Real-time techniques for object tracking and so on.

Sign in to comment.

Sign in to answer this question.