08-27-2020 09:55 PM
hello,everyone.I met a big problem in using the CLFN to call a DLL ( in C code )which is writed by using some library functions of Opencv,I tested the DLL in Visual Studio 2015 and it made it,but when I try to use the CLFN of Labview to call this DLL,it didn't work and the error number is 1097.I have tried many times and still failed.Cause it was the first time that I have tried to using the CLFN,I hope someone can give me some detailed steps about how to using it to call a DLL written by using some library functions of Opencv.
Thank you sincerely.
08-27-2020 10:01 PM - edited 08-27-2020 10:38 PM
hello,everyone.I met a big problem in using the CLFN to call a DLL ( in C code )which is writed by using some library functions of Opencv,I tested the DLL in Visual Studio 2015 and it made it,but when I try to use the CLFN of Labview to call this DLL,it didn't work and the error number is 1097.I have tried many times and still failed.Cause it was the first time that I have tried to using the CLFN,I hope someone can give me some detailed steps about how to using it to call a DLL written by using some library functions of Opencv.
Thank you sincerely.
08-28-2020 02:30 AM
A std::string parameter data type is NOT a CStr!!
std::string is a C++ object, a CStr is equivalent to a simple char * parameter.
LabVIEW can not generate C++ object data types, mainly becuase there is no standardized way how the binary representation of C++ objects is implemented and about memory management of object pointers (from which heap are they created and destroyed).
So you need to change your C(++) code to accept a char *Location instead. C++ should be able to do auto conversion between the incoming char * byte array to the required std::string for your function but for other OpenCV C++ data types you will need to make explicit conversions between the standard C types (or possible native LabVIEW types) and the C++ objects OpenCV normally requires.
08-28-2020 02:56 AM
Thanks so much for your answer,Zealot.I will try to do what you have suggested me to do.one more question is that it is the first time that I have done this job,can you recommand me some useful and detailed reference so that I can systematically know how to do it rather than doing it in a chaos order.thanks again!!!
08-28-2020
03:15 AM
- last edited on
03-06-2025
03:54 PM
by
Content Cleaner
Well the first and most important step is to be a proficient C(++) programmer. If you are at the level of having to take up the teaching book about C(++) pretty much at every second line of code you write, you are in for a hard ride.
LabVIEW's internal workings are a bit more complex than the typical Hello world C code example and accordingly, trying to create a DLL that gets interfaced through the Call Library Node is a more advanced task.
NI has an OpenCV package that helps interfacing LabVIEW to OpenCV for standard image acquisition and processing. You may take a look at that as it also includes the C source code for the wrapper DLL that among other things translates between the LabVIEW IMAQ data and the OpenCV mat object. This will show you some of the complications to interface between these two environments, and don't get shocked at the complexity of that code. While interfacing between C and especially C++ code to LabVIEW is already a fairly complex topic, this is made extra complicated by the fact of having to transfer image data between the two environments. Each environment has its own tricks to make the memory management for image data (which can potentially get huge) performant and that requires some smarts to make this work properly (the naive approach of simply copying everything from one format into the other may seem logical but would be a complete performance killer).
There are quite a few other threads in this forum such as this, that also give you more details about possible approaches for various tasks when trying to interface to OpenCV. Expect to invest a lot of time into this if you want to make something specific. It's not childs play at all.
08-28-2020 04:07 AM
well,thanks you so much.