0

In EmguCV 3.1.X (installed from Nuget) with the non-commercial license I had this code, which I got from here and which worked fine:

    public static dynamic GetValue(this UMat mat, int row, int col)
    {
        var value = CreateElement(mat.Depth);
        Marshal.Copy(mat.ToMat(AccessType.Read).DataPointer + (row * mat.Cols + col) * mat.ElementSize, value, 0, 1);
        return value[0];
    }

I now want to switch to the commercial version of EmguCV 3.3.X (installed from Nuget) and therefore had to change this code into:

    public static dynamic GetValue(this UMat mat, int row, int col)
    {
        var value = CreateElement(mat.Depth);
        Marshal.Copy(mat.GetMat(AccessType.Read).DataPointer + (row * mat.Cols + col) * mat.ElementSize, value, 0, 1);
        return value[0];
    }

For no apparent reason, this code hangs without exception or anything on the line: Marshal.Copy(mat.GetMat(AccessType.Read).DataPointer + (row * mat.Cols + col) * mat.ElementSize, value, 0, 1);

Am I doing something wrong or could this be bug in EmguCV?

packoman
  • 1,230
  • 1
  • 16
  • 36
  • The library changed so you must rebuild you c# project to use the new dll. Usually I just delete the bin folder of the c# project to force all code to build. Make sure you save any files that you manually placed in the bin folder. when you change a dll the compiler dependencies somethimes do not recognize dll changes – jdweng Nov 23 '17 at 16:59

1 Answers1

0

I don't have the "CreateElement" function available, so I used the following code to test. It should be similar.

        UMat u = new UMat(new Size(480, 320), DepthType.Cv8U, 1);
        u.SetTo(new MCvScalar(100));

        byte[] value = new byte[1];
        int row = 100;
        int col = 200;

        using (Mat m = u.GetMat(AccessType.Read))
        {
            IntPtr ptr = m.DataPointer + row * m.Step + col * m.ElementSize;
            Marshal.Copy(ptr, value, 0, 1);
        }

Tested with the v3.3.0.2824 release from Emgu CV commercial release nuget repository and works without hanging. If you still have the same issue, please upload the complete code and I will take a look.

Thanks.