Вопрос

I am trying to get a live view of a video camera working from Matlab. The video camera SDK is written in C, so I have been using .dll's to communicate from Matlab to the camera (I am a self-taught programmer, so I apologize if my terminology is off). For the live view however, I fear that while Matlab is reading the data from the camera buffer, the camera won't be aware that the data is being read by Matlab, and continue to blindly update the buffer. Therefore, I am thinking a handshake mechanism is required, and this is where my trouble comes in.

Below is the pseudo-code that outlines my current solution. My question is in regard to the statement inside the two while() loops. How do I actually go about checking the status of the booleans I'm using?. The possibilities I can think of require messy passing of arguments to and from multiple functions. Is there a cleaner way?

//C-code
initCamera();
dataReadyForSend = false;
grabFrame();
dataReadyForSend = true;
while(dataReceivedByMatlab == false)
    { // Check status};
//repeat

And now for the Matlab side:

% Matlab-code
dataReceieved = false;
while(waitForReadySignal() == false)
    { %Check status}
readDataFromC();
dataRecieved == true;
sendMessageOfSuccess(); %Tell C "I got the data"

Thank you,

R.S.

Это было полезно?

Решение

Matlab can easily call c-code compiled with the mex command. It seems that the simplest thing would be to write your code to read from the camera buffer in c, and then just call that from matlab.

You can see some examples of these extensions here.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top