# 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 suchCodePudding user response: