07-22-2014 03:53 AM
I'd like to use the OpenCV's FileStorage function in the LabVIEW. Mainly because I want to transfer a c++ project to a LabVIEW project.
But in this case, i can't load the xml file.
i tested it in a consolo project, it seems to work.
here is the code:
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace std;
using namespace cv;
class myclass{
public:
FileStorage f;
Mat temp;
int loadfile(){
f.open("C:\\Users\\Silva\\Documents\\results\\text.xml",FileStorage::READ);
if(!f.isOpened())
return -1;
f["count"]>>temp;
return 0;
};
};
myclass temp;
extern "C"{
_declspec (dllexport) int loadfile();
}
_declspec (dllexport) int loadfile(){
int error_code;
error_code = temp.loadfile();
if(error_code!=-1)
return 0;
return -1;
}
Solved! Go to Solution.
07-22-2014 04:35 AM
Hello,
first, did you try debugging the code?
Best regards,
K
07-22-2014 06:19 AM
Thank you for your kindness.
Yes, i wrote it and tryed it as a consolo project, it seems work well.
but when i change it to a dll project, labVIEW reported an error,
07-22-2014 06:32 AM - edited 07-22-2014 06:32 AM
No, I meant debugging the calling .dll in Labview via the Visual Studio, or whatever programing environment you are using...
I know you've added the sorce code to the previous post, but can you also attach the .cpp file you are using?
Best regards,
K
07-22-2014 07:49 AM
Thank you ,klemen.
Yes,I debugged it in VS2010, and it worked well.(OpenCV2.4.8)
But when i call the dll in LabVIEW2011, it reported the error .
As you can see, i attached the cpp file, vi, xml file and dll as a zip file in the fisrt post.
07-22-2014 08:09 AM - edited 07-22-2014 08:22 AM
I am really sorry, somehow I missed that...
No error with your code here:
Best regards,
K
07-22-2014 08:33 AM
Thank you ,klemen.
I think i choose the wrong version of the dll file.
i chose the release version.
I change it to the debug version and it works!
Thank you.
But I still don't know why the release version don't work.
07-23-2014 12:22 AM
Hello,
the release build also works here.
Best regards,
K
07-23-2014 01:52 AM
Thank you ,klemen.
I have tested it and it works.
But i have another question.
for example I draw an circle or points on an image . How can i return the image to LabVIEW and display it?
07-23-2014 02:02 AM
Hello,
have you seen the link in my signature?
There you will find some examples on how to pass the image from OpenCV to Labview.
Best regards,
K