Search code examples
c#emgucv

EmguCV System.ArgumentException: 'Unable to decode file'


I am trying to instantiate an EmguCv Mat using a file path and EmguCVEnum as the parameters.

The code looks like this

using (Mat mat = new Mat("Y:\\Desktop\\test.dng", ImreadModes.Unchanged))

However it is throwing an error:

System.ArgumentException: 'Unable to decode file: Y:\Desktop\demTest\ATHS4829.dng'

Is there a way to create a Mat using a DNG file or its image data?


Solution

  • I was able to solve this issue by retrieving the bytes stored inside the DNG and putting them into an array. Then creating a Image<Bgr, ushort> object using the bytes array. After that i was able to call

    UMat mat = img.ToUMat();