Does EMGU CV support convertMaps()? Are fixed-point DepthTypes missing?

35 views Asked by At

I'm using Emgu.CV 4.8.1.5350 from NuGet and find that CvInvoke.Remap() works well with X & Y map-Mats defined as DepthType.Cv32F.

However, when I call ConvertMaps() to convert these Mats to fixed-point values, I'm getting an exception at runtime with the message:

OpenCV: dstm1type == CV_16SC2 || dstm1type == CV_32FC1 || dstm1type == CV_32FC2

The Emgu.CV.CvEnum.DepthType Enum doesn't include the values CV_16SC2, CV_32FC1 or CV_32FC2 so I can't specify them when calling ConvertMaps().

Has anyone successfully used Emgu CV's ConvertMaps()? And if so, how?

Here's my code:

 Dim BScanToPPIMap_X As New Mat(m_CompositePPIMat.Size, DepthType.Cv32F, 1, XMapHandle.AddrOfPinnedObject(), m_CompositePPIMat.Width * 4)
 Dim BScanToPPIMap_Y As New Mat(m_CompositePPIMat.Size, DepthType.Cv32F, 1, YMapHandle.AddrOfPinnedObject(), m_CompositePPIMat.Width * 4)

 m_BScanToPPIMap_X = New Mat(m_CompositePPIMat.Size, DepthType.Cv32S, 1)
 m_BScanToPPIMap_Y = New Mat(m_CompositePPIMat.Size, DepthType.Cv32S, 1)

 CvInvoke.ConvertMaps(BScanToPPIMap_X, BScanToPPIMap_Y, m_BScanToPPIMap_X, m_BScanToPPIMap_Y, DepthType.Default, 1)

 XMapHandle.Free()
 YMapHandle.Free()

 BScanToPPIMap_X.Dispose()
 BScanToPPIMap_Y.Dispose()

Per my reply to Dan in the comments, here's the working code:

Dim BScanToPPIMap_Y As New Mat(m_CompositePPIMat.Size, DepthType.Cv32F, 1, YMapHandle.AddrOfPinnedObject(), m_CompositePPIMat.Width * 4)

m_BScanToPPIMap_X = New Mat(m_CompositePPIMat.Size, DepthType.Cv32F, 1)
m_BScanToPPIMap_Y = New Mat(m_CompositePPIMat.Size, DepthType.Cv32F, 1)

CvInvoke.ConvertMaps(BScanToPPIMap_X, BScanToPPIMap_Y, m_BScanToPPIMap_X, m_BScanToPPIMap_Y, DepthType.Cv32F, 1)

XMapHandle.Free()
YMapHandle.Free()

BScanToPPIMap_X.Dispose()
BScanToPPIMap_Y.Dispose()

I think my mistake was to assume that ConvertMaps()'s destination type had to be a non-floating point type, or what was the point? :-)

0

There are 0 answers