shimat / opencvsharp

OpenCV wrapper for .NET
Apache License 2.0
5.39k stars 1.15k forks source link

OpenCvSharp4 ImRead vs OpenCvSharp3 #1462

Closed Goczilla closed 2 years ago

Goczilla commented 2 years ago

Summary of your issue

Imread not working anymore with .tif file after updating the OpenCvsharp version. The file is 450Mo weight and on 48 bits. Image can be download here (if you auto adjust contrast, you will see a dots grid).

Environment

.Net 4.8 Windows 10 Visual Studio 2019 Profesionnal Nugget Package for OpenCvSharp4.Windows and all dependencies for OpenCvSharp4.Extensions (include OpenCvSharp4 and .runtime.win (redundancy ?))

What did you do when you faced the problem?

Before to update, a simple imread on every format a file worked. Now, it is not working for some .tif files generated by other part of my project.

Path of my file in the string variable (double slash into it, but only one shown in this post) : C:\Users\mgauquelin\Downloads\ReferencePiezoVerification_SN404108.tif

Format of my matrix after imread it : Sans titre

The warning message I get: imread_('C:\Users\mgauquelin\Downloads\ReferencePiezoVerification_SN404108.tif'): can't read data: unknown exception

I also see something strange when I do cv::getBuildInformation(), that a path is D:a/openCVbut I don't know what is this path because there is no such folder.

Example code:

Just for information, I check if the file permission was okay, and it is. My "result" variable is equal to true.

                bool result;
                string file = "myPath";
                using (FileStream fs = new FileStream(file, FileMode.Open))
                {
                    if (fs.CanRead)
                    {
                        result= true;
                    }
                    else
                    {
                        result= false;
                    }
                }
                mat = OpenCvSharp.Cv2.ImRead(file, ImreadModes.Unchanged);

What did you intend to be?

Try to open other format of file : ok. Try to come back to OpenCvSharp3 : ok

Goczilla commented 2 years ago

An issue was open on the openCv C++ Github (click here) because it is not C# related.