05-15-2025 02:37 PM
Hello,
I am currently trying to import this dll for an Optris Xi 400 thermal camera. I have added some preprocessor definitions and that did import some of the functions, but many are still unavailable. (I have these as my definitions so far: PPOINT; POINT; ULONG; USHORT; wchar_t; IRArranging; Type; MeasureAreaType; AlarmSetting; PSIZE;)
From what I read, due to the fact that there is some "C++ ism" in my header file. The problem is that I don't know what I need to change in my header file to get all the functions in the library.
What will I need to do to the header file? Or do are there still things I need to add to the preprocessor definitions?
Thank you!
05-16-2025 02:22 AM
Once I see callbacks in your header, such as `WINAPI SetCallback_OnNewFrame(WORD index, fpOnNewFrame OnNewFrame);`, I immediately forget about the DLL Import Wizard. Instead, I open Visual Studio or any other suitable IDE of your choice and start working on a wrapper. Receiving images via callbacks is typical for many cameras. In the wrapper DLL, Add your own callback, which will copy the received frame (preferred to an IMAQ Image), then call LabVIEW's `occur()` function to notify the LabVIEW code that a new frame has arrived, that is.
05-16-2025 01:52 PM
Thank you for your answer!
I should have mentioned it in my original post, but I am quite new to LabView and coding as a whole. I am sure I can find some information out there that could help me make my own wrapper for this.
I am really not sure what your last sentence means, would the occur function be in the wrapper file that I make in the IDE?
05-16-2025 11:27 PM
That will be a bit complicated, because this is an intermediate-level task. Anyway, your starting point is the Call Library Function Node. Follow the examples in the <LabVIEW xxxx>\examples\Connectivity\Libraries and Executables
folder. Are you familiar with C and able to create a simple DLL? If so, practice passing simple scalars and arrays to and from the DLL first.
Another key consideration is: How will you display the image in LabVIEW? While using a picture control or intensity graph is possible, these methods will be slow. I recommend the Vision Development Module for better performance and lower CPU usage, though this introduces complexity when passing images from a memory pointer to an IMAQ Image.
05-17-2025 01:20 AM
Wait a moment, I found an old example in my archives (a very "quick and dirty").
Let's say this is a library provided by a third-party camera supplier, looks something like that (you have no source code, of course, the only header and library):
#define BUFFER_SIZE 65536
static uint16_t buffer[BUFFER_SIZE];
static volatile BOOL running = false;
static BufferCallback userCallback = NULL;
int CVICALLBACK ThreadProc (void *functionData) {
while (running) { // in general here critical section, skipped to simplification
// EnterCriticalSection(&cs);
// Fill buffer with random values
for (int i = 0; i < BUFFER_SIZE; i++) buffer[i] = (uint16_t)(rand() % 65535);
// Notify application
if (userCallback) userCallback(buffer);
Delay(0.04); //25 FPS
}
return 0;
}
__declspec(dllexport) int Init(BufferCallback callback) {
int Id = -1;
if (!running) {
userCallback = callback;
running = true;
CmtScheduleThreadPoolFunction (DEFAULT_THREAD_POOL_HANDLE, ThreadProc, NULL, &Id);
srand((unsigned int)time(NULL));
}
return Id;
}
__declspec(dllexport) void Close(int Id) {
if (running) {
running = false;
CmtWaitForThreadPoolFunctionCompletion (DEFAULT_THREAD_POOL_HANDLE, Id, 0);
}
}
Then this is your wrapper
#define BUFFER_SIZE 65536
static uint16_t *Image;
LVRefNum *FrameOccurence;
void __stdcall FrameCallback(uint16_t* buffer) {
if (Image && buffer){
for (int i = 0; i < BUFFER_SIZE; i++) Image[i] = buffer[i];
((int (_cdecl *)(LVRefNum))(*Occur))(*FrameOccurence);
}
}
typedef void (__stdcall *BufferCallback)(uint16_t*);
__declspec(dllimport) int __stdcall Init(BufferCallback);
__declspec(dllexport) int Start (uint16_t *LVImage, LVRefNum *LVFrameOccurence)
{
FrameOccurence = LVFrameOccurence;
Image = LVImage;
int Id = Init(FrameCallback);
return Id;
}
Then LabVIEW code:
And how it works:
NI CVI 2020 + LabVIEW 2025 x64, downgraded to LV2018.
If you understand how this simple example works, then for sure you will be able to do the same with your own imager (be very areful with race condition when one thread will write to the buffer and another one will read, but in most cases PC is fast enough to copy out buffer between the frames callbacks).
05-19-2025 02:30 PM
Thank you!
I'll study this and apply the concepts to my own problem.