Search code examples
c#opencvimread

OpenCvSharp4 ImRead return empty image (whereas OpenCvSharp3 works)


Imread is not working anymore with ".tif" (48 bits) file after updating the OpenCvSharp wrapper version from OpenCvSharp3Any-Cpu (wrapper 4.X) to OpenCvSharp4.Windows and .Extensions. The file is 450Mo weight.

The warning message:

imread_('C:\Users\mgauquelin\Downloads\ReferencePiezoVerification_SN404108.tif'): can't read data: unknown exception

My 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 ?)

For information, the path of my file in the string variable is : C:\Users\mgauquelin\Downloads\ReferencePiezoVerification_SN404108.tif

Here is a sample code of my reading, with a check of the permission to read (always true) after the check the file exists (always true also) :

            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);

I tried to open other format of file : ok. I tried to come back to OpenCvSharp3 : ok. I read a lot of forums which deal with the file permission, the path of the file. Already check this.

Format of my matrix after imread: enter image description here

Thank you in advance for any help.


Solution

  • I reported this bug to the opencv forum and a new bug ticket was created. So no workaround for today with this version of OpenCvSharp4.