Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Create a DLL to Read an Image Using OpenCV

Solved!
Go to solution

Hi all,

 

I am trying to create a DLL to do some image processing using OpenCV. So in the first place, I am trying to create a DLL that can read an image and display it. But I have encountered a problem when I call this DLL in LabVIEW.

 

The error in LabVIEW says:"Error 1097 occurred at Call Library Function Node in DLL Read Image (Play).vi

 

Possible reason(s):

LabVIEW: An exception occurred within the external code called by a Call Library Function Node. The exception might have corrupted the LabVIEW memory. Save any work to a new location and restart LabVIEW."

 

These are the steps that I have followed:

1. Download OpenCV2.4.9 and extract the files. Make proper changes to Environment Variables to include OpenCV.

2. Start a new Microsoft Visual Studio 2010 Project to create a DLL.

3. Add a property sheet to the property manager to include OpenCV Library.

4. Edit the Read Image DLL(Play).cpp code as it is in the attached file.

5. Compile to create the Read Image DLL(Play).dll file.

6. Create a VI in LabVIEW to call the DLL.

 

Attached are the related files: 1. Read Image DLL(Play).cpp  2. Read Image DLL(Play).dll  3. Read Image DLL(Play).vi

 

Would anyone kindly help me with this? I suppose it might be the problem with the Read Image DLL(Play).cpp code.

 

Thanks very much.

 

1. Attached Read Image DLL(Play).cpp code:

///include necessary image processing opencv libraries 

#include "stdafx.h"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>

using namespace std;
using namespace cv;

 

///function declaration
extern "C" {
_declspec (dllexport) int main( int argc, char** argv );
}

 

/// Global Variables
Mat img;

_declspec (dllexport) int main( int argc, char** argv )
{
/// Load image
img = imread( argv[1], 1 );
return 0;
}

Download All
0 Kudos
Message 1 of 5
(10,473 Views)
Solution
Accepted by topic author Cheng6688

Hello,

 

if it helps, here are some examples on Labview/OpenCV image processing:

 

https://decibel.ni.com/content/blogs/kl3m3n

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Message 2 of 5
(10,452 Views)

Hi Klemen,

 

This is really helpful. And I will look deeper into the details! Thanks a lot!

0 Kudos
Message 3 of 5
(10,414 Views)

How to fix error "nivisocvsamples. dll" on NI LabVIEW Vision OpenCV Utilities

 

can i detect the face in video stream using open cv in labview without creating dll files??

 

 

0 Kudos
Message 4 of 5
(5,041 Views)

Hi soomro,

 

This thread is over 4 years old. I would recommend creating a new thread with details on your question. If this forum post is part of the problem/solution feel free to link it in your new post.

Jacob C.
Applications Engineering
National Instruments
0 Kudos
Message 5 of 5
(5,026 Views)