How can I store an array on a Raspberry Pi, using the simulink support?
Show older comments
Hi
I am currently using a raspberry pi via simulink. I have a simple colour blob detection model working, which is then run using the pi. A scope displays the x and y position of the colour blob centroid detected by the camera and model. This is in turn stored in matlab.
I am intending to eventually disconnect the pi and have it continue to detect a blob, of course this will not allow the camera display to be viewed and the position data to be recorded as these are handeled by simulink. The camera is not so much of an issue but the position data is, as I intend to use it to track the position of an LED inside a vehicle.
A simple solution would be to put a laptop and the pi in the vehicle together, but that defeats the point of the pi, as I could just use Matlab and a webcam to achieve the same result.
So I would like a solution to storing the complete x y position data of the centroid on the pi, which can the be retrieved later.
Currently I have a user defined function that finds the centroid and outputs a variable 'pos' which is the x and y per sample. This goes out to a scope, I have a branch from this which goes to another user defined function which is a butchered bit of image capture code from an RP tutorial.
below
function fcn(pos, counter) %#codegen
format = ['%d ', 0]; fname = coder.nullcopy(uint8(zeros(2, 32))); coder.ceval('sprintf', coder.wref(fname), ['text%d.dat', 0], counter); fd = coder.opaque('FILE *'); fd = coder.ceval('fopen', fname, ['w', 0]);
for j = 1:1000 coder.ceval('fprintf', fd, format, pos(j, 1)); % coder.ceval('fprintf', fd, format, pos(j, 2)); end
coder.ceval('fclose', fd);
the problem with this is the code generates many single variables per sample rather than continually add to a single array.
Any help would be apreciated.
Answers (1)
Jessica du Toit
on 7 Sep 2015
0 votes
Hi, I don't have an answer but a similar problem. Did you find a solution?
Categories
Find more on Raspberry Pi Hardware in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!