External application video link to Matlab

I have a external Borland C builder application (and source code) that I want to link to Matlab. This borland application read a video data of custom hardware and I need to send it to my boss Matlab application.
Also I need also a link back from Matlab to my application to control the hardware.
What is the easiest why to achieve this?
Thanks Hurter

Answers (1)

Is the program written to use ActiveX ?
What kind of link were you thinking of? What does the application do with the data once it reads it?
If the code interface can be rewritten into the form of a DLL, then you can use loadlib() and call the routines.
Possibly, though, it might make more sense to recode as a device driver for data acquisition purposes.

7 Comments

Hi Walter
No the builder application doesn't use activeX.
On the hardware I use a FTDI USB chip and there DLL in my builder application.
My application download the video from the hardware in YUV422 format and then convert it to 24-bit RGB that I need to send it to Matlab to be processed.
"If the code interface can be rewritten into the form of a DLL, then you can use loadlib() and call the routines. Possibly, though, it might make more sense to recode as a device driver for data acquisition purposes"
I never tried this. At a stage I did try use mex compile with the FTDI DLL but gave up because of allot of compiler and linking errors and I still need a link down to the hardware. The hardware currently does not use the same link for the commands from the PC. I still need to add that on the same FTDI usb link.
MATLAB can convert YUV422 to RGB in the Image Acquisition Toolbox. It might possibly be easiest to connect the USB to the machine MATLAB is running on, and (if necessary) adapt a driver so that MATLAB can see the device as a camera that it can get frames from.
Hurter
Hurter on 23 Jan 2013
Edited: Hurter on 23 Jan 2013
Thanks for the reply.
Yes I know that matlab can convert YUV422 to RGB. But my problem is still how to get the data into Matlab. The video stream of the hardware is not standard YUV422 stream... I did strip the stream from it's headers and add my own, a line count to make it easier to sync. Also I don't send any blanking data that normally comes with YUV422 video stream. This I done to save up some bandwidth on the usb link.
Ok, assuming that the stream is not standard. Can I still use the Acquisition Toolbox?
And how to connect the USB to Matlab?
ok
I played a bit and can load a DLL into matlab using:
loadlibrary('ftd2xx','ftd2xx')
command.
Now in my builder program I did the following:
FT_HANDLE ftHandle;
FT_STATUS ftStatus;
to create variable or rather a structure of the ftdi link.
How can I do this in matlab?
Because the next command will be something like this:
ftStatus = calllib ('ftd2xx','FT_OpenEx','12345678A', 'FT_OPEN_BY_SERIAL_NUMBER', ftHandle)
to open the usb link.
BTW the FT_OPEN_BY_SERIAL_NUMBER is a #define in the header file and no errors from it but that I can replace with the correct value if I need to. The '12345678A' is the FTDI device id I assign when I programmed these
Thanks for your help
I note that you have opened a new Question on how to deal with structures with bitfields, so the loadlib() issues are probably best handled over there.
Hurter
Hurter on 24 Jan 2013
Edited: Hurter on 24 Jan 2013
Yes
I have open a new question on to deal with structures since its is a bit different than the Question in this tread. Any ideas that I do wrong?
Still no solution on any of them.
There was a stage (about a month back) that I try to use a mex compile route but did not succeed on that( yet). The plan was to make a DLL using mex-compile and then import that DLL into BorlandC builder. I battle to import that DLL or rather that I get linking issues. Unless I mist a step in that process.
Al right I gave up on this method.
Will try to use a network. I think it will be slower because the data will be ship serial, but at lest I can get bidirectional communication and Matlab can pass commands down to the hardware.
Unless someone can give me alternative, this will be the route to go for now.
Thanks Walter for your input. I think that is not only the correct way to do this but most probably the fastest as well. To bad I could not get this going...

Sign in to comment.

Asked:

on 23 Jan 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!