SIFT.Compute results in empty output matrix

Ask questions on using Emgu CV with VB
Post Reply
C8002
Posts: 1
Joined: Fri Jan 03, 2020 8:17 am

SIFT.Compute results in empty output matrix

Post by C8002 » Fri Jan 03, 2020 8:29 am

Hello,

I've found an article on how to match an image to a library of other images using a SIFT detector and FLANN index written in C# and have decided to translate the code into VB.NET. However, I seem to have made an error while translating, as the SIFT.Compute command will result in an empty output matrix (or a matrix with the size 1x0), thus giving me 0 matches even if I use an identical image from the library.

This is my translated code:

Code: Select all

        Private Function ComputeSingleDescriptors(ByVal fpath As String) As Matrix(Of Single)
            Dim descs As Matrix(Of Single) = New Matrix(Of Single)(New Single() {})
            Using img As Image(Of Gray, Byte) = New Image(Of Gray, Byte)(fpath)
                descs = New Matrix(Of Single)(img.Rows, img.Cols)
                Dim keypoints As New Util.VectorOfKeyPoint
                detector.DetectRaw(img, keypoints) 'This function works correctly and will generate keypoints.
                detector.Compute(img, keypoints, descs)
            End Using
            Return descs
        End Function
This is the original code, as found in the article:

Code: Select all

public Matrix<float> ComputeSingleDescriptors(string fileName)
{
    Matrix<float> descs;

    using (Image<Gray, Byte> img = new Image<Gray, byte>(fileName))
    {
        VectorOfKeyPoint keyPoints = detector.DetectKeyPointsRaw(img, null);
        descs = detector.ComputeDescriptorsRaw(img, null, keyPoints);
    }

    return descs;
}
Any help is greatly appreciated.
~C8002

Post Reply