Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Interfacing of IP thermal camera with MATLAB

Subject: Interfacing of IP thermal camera with MATLAB

From: swati

Date: 6 Feb, 2013 07:58:08

Message: 1 of 4

Hello,

I have to interface FLIR IP thermal camera with MATLAB for video streaming. I have tried with Image acquisition and Instrument control toolbox,but didnot work.Please help.

Subject: Interfacing of IP thermal camera with MATLAB

From: William Frane

Date: 7 Feb, 2013 21:02:08

Message: 2 of 4

Hello swati,

A few years ago I had the dubious privilege of interfacing a FLIR thermal camera with MATLAB; at the time, the only available means of doing so was by using an ActiveX plugin provided by FLIR, but at the time I recall hearing that their newer cameras supported the GigE (gigabit ethernet) protocol. If the camera you have can provide GigE video output that may be your best bet (try googling "MATLAB GigE camera" for some places to start).

I suspect, however, that the most useful source of information for you will be the documentation that came with your camera and any software (e.g., an SDK) that you may have purchased with it. You might also try FLIR's support site or customer service, although my personal experience with the latter was not particularly impressive. If a FLIR representative told you that the camera can stream video to MATLAB before you purchased it, follow up with them and try to get an example of this functionality that you can expand upon.

If you're still completely at a loss, someone on the newsreader may be able to help you (provided the FLIR camera you have is endowed with the ability to connect using a standardized protocol like GigE that MATLAB supports), but you'll need to be far more specific about what you've already tried and what the capabilities of your camera are. For example, rather than just saying that you've got a FLIR IP camera, give the exact model, and provide specific details (including code) regarding what you've already tried.

Hope that helps.

Will

"swati " <swati19_ojha@rediffmail.com> wrote in message <ket2eg$6sr$1@newscl01ah.mathworks.com>...
> Hello,
>
> I have to interface FLIR IP thermal camera with MATLAB for video streaming. I have tried with Image acquisition and Instrument control toolbox,but didnot work.Please help.

Subject: Interfacing of IP thermal camera with MATLAB

From: swati

Date: 12 Feb, 2013 16:07:19

Message: 3 of 4


Hello William,
Thanks for your reply.

We have got FLIR F-645 camera which works on standard ethernet protocol not "GigE camera".We are trying to create mex function which is also not giving correct results.Whenever we call it in MATLAB , it gives error as " segmentation violation" and MATLAB shuts down. Here is the code:

#include <mex.h>
#include <cv.h>
#include <highgui.h>

using namespace std;

void convertIplImageToMxArr(IplImage* cvImg, double *imgP);

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
   
  char *name = "rtsp://192.168.250.116:554/ch0";
   int rows, cols;
   double *A;
   

   CvCapture* camera = cvCreateFileCapture(name);
   
if(!camera)
    {
mexErrMsgTxt("Cannot load image");
return;
}


IplImage* cvImg = cvQueryFrame(camera);

    rows = mxGetM(prhs[0]); /* Get the dimensions of A */
cols = mxGetN(prhs[0]);
A = mxGetPr(prhs[0]); /* Get the pointer to the data of A */

convertIplImageToMxArr(cvImg, A);
}



void convertIplImageToMxArr(IplImage* cvImg, double *imgP)
{
    double divVal = pow(2.0, cvImg->depth) - 1;

    for ( int x = 0 ; x < cvImg->width; x++ )
{
for ( int y = 0 ; y < cvImg->height; y++ )
{
CvScalar s = cvGet2D(cvImg, y, x);
for (int c = 0; c < cvImg->nChannels; c++)
{
imgP[ y + x * cvImg->height + c * cvImg->height * cvImg->width ] = s.val[c] / divVal;
}
        }
    }
}

Would you please tell us how to interface FLIR camera using an ActiveX plugin provided by FLIR, as we have also got that.

Regards,
  Swati

Subject: Interfacing of IP thermal camera with MATLAB

From: William Frane

Date: 23 Feb, 2013 00:58:10

Message: 4 of 4

Hello swati,

It sounds like your MEX file is encountering a segmentation fault; I'm wasn't aware that FLIR offers a C/C++ API (I assume cv.h and/or highgui.h are include files for code provided by FLIR), but assuming the seg fault is in your code and not one of the FLIR-provided files, I'd check for the usual suspects (see http://en.wikipedia.org/wiki/Segmentation_fault#Common_causes if you haven't encountered seg faults before).

Regarding use of the FLIR ActiveX control: it's been a few years since I worked with it, but there are some general things I remember that might be of use to you:

- Once the FLIR ActiveX control is installed, check that MATLAB recognizes it using the actxcontrollist command. It should be listed as CAMCTRL.LVCamCtrl.#, where # is some apparently random number (it varied by computer when I used the FLIR SDK).

- The properties and methods for the FLIR ActiveX control should be listed in the documentation for the FLIR SDK. I don't recall off the top of my head how to access an ActiveX control's methods from MATLAB, but this documentation page is probably a good place to start: http://www.mathworks.com/help/matlab/ref/actxcontrol.html

- I was able to locate one of my old test files that uses the FLIR ActiveX control to load an already-recorded sequence file and extract a couple of frames. I've included its code below; it's pretty basic, but it should be a decent place to start (even if you don't have any sequence files around, it shows how to start the FLIR ActiveX control and invoke its methods).

Hope that helps.

Will

=== SAMPLE MATLAB FLIR ACTIVEX CONTROL CODE ===

flir_fig = figure;
flir = actxcontrol('CAMCTRL.LVCamCtrl.3','parent',flir_fig);

% "Connecting" to a file device.
invoke(flir,'Connect',10,0,2,0,'0');

% Set path of sequence file to open.
pathToSequenceFile = 'C:\Seq Files\test838.SEQ';
invoke(flir,'SetCameraProperty',53,pathToSequenceFile);

% Get the number of frames in the sequence file.
num_frames = invoke(flir,'GetCameraProperty',76);

% Retrieve the current frame; for some reason it's transposed.
frame = invoke(flir,'GetImage',3);

figure
imagesc(frame');

% Change the current frame (note that the parameter must be cast as a long int).
frameNumber = 300;
invoke(flir,'SetCameraProperty',77,cast(frameNumber,'int32'));

frame = invoke(flir,'GetImage',3);

figure
imagesc(frame');

invoke(flir,'Disconnect');

clear flir;
close(flir_fig);

=== END SAMPLE CODE ===

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us