I have an external function from an opencv dll, cvCreateFileCapture, that should take the path as an input and return a structure.
CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
I created a vs2010 project for testing purposes from where i call this function with a valid file path and get the structure i was supposed to get returned.
When I call this function from a different program (I'm using labVIEW) I jump into the same function with the same input but it returns 0.
Does anyone have an idea why it works 1 way but not the other?
The C call is CvCapture* p = cvCreateFileCapture("C:/Users/****/Downloads/Disturbedloc.avi");
the labview call looks like this:
If the library call works in one environment but not another, then there's a difference in the environment. There are two main approaches:
opencv
has the correct linkage. Perhaps Visual Studio is inspecting opencv
for other libraries (like FFMPEG or GStreamer) and adding extra loader instructions to fetch those binaries on launch. LabVIEW, on the other hand, will do a pure dynamic load, and if the library doesn't correctly advertise its dependencies, then those libraries won't be loaded and you'll get a NULL
pointer.opencv
then watch the Modules window to see if the support libraries are resident in memory. Comparing against your working Visual Studio program would show if any are missing.That run-time linking doesn't work in opencv
is a bug in their project. You should report that to them.
You have two workarounds:
opencv
yourself, and redistribute it with your application.opencv
.Since your opencv
dll returns a pointer to a struct, you have two options:
opencv
library in another C/C++ library so that the inputs/outputs are simpler data types, like numerics.opencv
types. NI has a some good documents describing how LabVIEW interfaces with external libraries, but start here: Calling C/C++ DLLs from LabVIEW.