how to convert cv::Mat from C++ opencv to Mat for C# opencvsharp?
See original GitHub issueI want to Convert Mat object from  C++  opencv  to C# opencvsharp.but I donât how to do .
C++/opencv-------Mat------------>DLL------->C#/opencvsharp---------->Mat.
At first,I Wrote one DLL for C++ as following:
//C++ DLL -----unmanaged
TSO.h
extern "C"
{
__declspec(dllexport)  Mat WINAPI GetImage(char* filename);//The Mat object is C++ object from opencv
}
TSO.cpp
__declspec(dllexport)  Mat WINAPI GetImage(char* filename)
{
return imread(filename);
}
then I quote this dll in C# ,As the same time I quote opencvsharp
[DllImport("TSO.dll", EntryPoint = "GetImage")]
 public extern static Mat GetImage(string filename);//Mat is from opencvsharp
finally ,I did like this
Mat img=GetImage(@"D:\1.jpg");//C#object form opencvsharp
            pictureBoxIpl1.ImageIpl = img;//pictureBoxIpl1  is control of opencvsharp
but it doesnât work,So how to convert?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:8 (2 by maintainers)
Top Results From Across the Web
how to convert Mat.at<cv::Vec3b>() from C++ opencv ...
I want to convert C++ OpenCV Code to C# OpenCVSharp. But i don't know how to replace this code cv::Mat mat; mat.at<cv::vec3b>(int ...
Read more >cv::Mat Class Reference
Converts an array to another data type with optional scaling. More... void, copySize (const Mat &m). internal use function; properly re-allocates _size, ...
Read more >Mat Class
Performs an inverse Discrete Fourier transform of 1D or 2D floating-point array. Public method Static member, ImDecode. Creates the Mat instance from image...
Read more >OpenCV: Operations with images
A conversion from Mat to C API data structures (C++ only):. Mat img = imread("image.jpg");. IplImage img1 = cvIplImage(img);. CvMat m = cvMat...
Read more >From cv::Mat to saving image in a given format(png,jpeg...)
Hi,. I am trying to work out how to save an image in a given format (PGM, PNG, JPEG,... ) once I have...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
đ¤ If your Matâs Type is 8UC1 or 8UC3, encoding it into an image such as BMP or PNG is one way to do it. If itâs any other type, then copying the pixel values might be a good way.
However, if you are using C++ in the first place, I would suggest that you donât use OpenCvSharp and write all image processing consistently in C++.
it doesnât work đ