IDL and C- [message #39420] |
Wed, 19 May 2004 18:44  |
rsmith1
Messages: 3 Registered: May 2004
|
Junior Member |
|
|
Hello-
I am attending a small undergraduate university at I am trying to I am
trying to interface a CCD with a computer through an NI IMAQ card in
IDL.
The only examples they give are in C or through the use of labview.
I
need to be able to snap images from the card inside of IDL. The way I
am currently going about the problem is to use the code they have
given
inside of C and then reference it using the IDL call_external
function.
The C code is compiling fine now and the IDL code seems to be
referencing the C code, however there are some variable declaration
issues. Here is my code in IDL:
Pro TestDLL2
image = bytarr(640,480)
help, image
image = call_external("C:\11ryan\temp\Debug\testDLL.dll","testDLL ")
help, image
END
This references the following C code:
#include <stdio.h>
#include <windows.h>
#include ".\resource.h"
#include "IDL_export.h"
#define _NIWIN
#include "nitypes.h"
#include "niimaq.h"
#include "sample.h"
#include "acqfuncs.h"
extern "C" __declspec(dllexport) char* testDLL(void)
{
INTERFACE_ID interfaceID;
SESSION_ID sessionID;
Int8* buffer = NULL;
IMG_ERR error;
uInt32 top, left, height, width, rowBytes;
//open an interface and start a session
error = imgInterfaceOpen("img0", &interfaceID);
error = imgSessionOpen(interfaceID, &sessionID);
//pass a pointer to a NULL pointer and the driver will allocate
//a buffer of the appropriate size for you.
error = imgSnap(sessionID, &buffer);
//get the image dimensions. These default dimensions depend on the
type
//of camera that is currently configured
error = imgSessionGetROI(sessionID, &top, &left, &height, &width);
error = imgGetAttribute(sessionID, IMG_ATTR_ROWBYTES, &rowBytes);
//process function here
//close this interface and free all resources associated with it,
//such as the buffer that was allocated by the driver during
imgSnap
return buffer;
}
The c code was given in a manual from NI, however I left out the final
portion where they close the buffer and I made some changes in order
to
get it to compile as well as pass information through to IDL. As it
stands now, I have declared an array inside of IDL the size of my
image. When I use the call_external function IDL changes the variable
type on the fly and returns a long int. I think that this is a
pointer
to the memory address of the start of the buffer. I am unsure as to
how to take this information and obtain the image from it inside of
IDL. Any help you can offer is appreciated. Thanks in advance-
-Ryan
|
|
|