Home > Back-end >  C # can't call c encapsulates the opencv. DLL functions
C # can't call c encapsulates the opencv. DLL functions

Time:05-22

This is a test case, the use of c + + from the opencv imread encapsulated into a DLL, then, using c # call, however, the c # call not encapsulated the imread function after finishing all the time, does anyone know what reason is this, thank you!
 
# include
# include
# include
# include
# include "test. H"

# pragma comment (lib, "opencv_world310. Lib")

Using the namespace CV;
using namespace std;

Extern "C" __declspec (dllexport) int test ()
{
Mat readImage=imread (" D: \ \ PIC \ \ pic1 JPG ");
Int rowPic=readImage. Rows;
Return rowPic;
}

Then using c # call
 
[c # code] - Call the test. The DLL
The namespace testOilDetectionCsharp
{
Public sealed partial class MainPage: Page
{
[DllImport (" test. DLL, "CharSet=CharSet. The Unicode)]
Extern static int test ();

Public MainPage ()
{
Enclosing InitializeComponent ();
}

Private void Button_Click (object sender, RoutedEventArgs e)
{
The unsafe
{
Int num=test ();
TextBox. Text=num. ToString ();
}
}

}
}

In theory, the imread function after reading the image data, c # call returns the number of rows images, but in fact did not return the expected value, it always return zero value, don't know why I can't call c # after encapsulation of opencv

CodePudding user response:

The building Lord have the answer, I now also is such

CodePudding user response:

reference 1st floor FSDFCSDFSDF response:
the original poster is the answer, I now also is such

Well, I here appear such problem because opencv compiled version problem, this version is a little problems, in another version can call succeeds, you can try to change a version to see
  • Related