Hi AhmedWassimBENSALEMENISo-3626,
To use OpenCvSharp, you need to add both OpenCvSharp4 and OpenCvSharp4.runtime.* packages to your project.
Right-click your project namre->Manager NuGet Packages->Browse-> Search and Install them.
Then you can achieve it via BitmapConverter.ToMat() method.
Here is my test code you can refer to.
Image img = Image.FromFile(@"C:\Users\Pictures\home.PNG");
Bitmap bmpScreenshot = new Bitmap(img);
var imageMat = OpenCvSharp.Extensions.BitmapConverter.ToMat(bmpScreenshot);
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentationto enable e-mail notifications if you want to receive the related email notification for this thread.