Celebrandil / CudaSift

A CUDA implementation of SIFT for NVidia GPUs (1.2 ms on a GTX 1060)
MIT License
852 stars 287 forks source link

Wrong Sift points coordinates #20

Open omaraltayyan opened 7 years ago

omaraltayyan commented 7 years ago

Hi, thanks a lot for your great work

I am having an issue with the code Whenever i try to read the sift points after extracting them from the image, their x and y coordinates aren't where they should be

So i am simply drawing these points over the image with opencv and displaying them in real-time, and the sift points seem to construct shapes of objects in the image but with a larger​ scale and a big offset

I tried multiplying and dividing the x and y coordinates with the scale attribute of the corresponding sift point but it didn't work

Any idea how this might be solved??

Note: i am running the code on a GT 750m (Kepler w/ cc of 3.0, 4GB DDR3, 12ms to run)

omaraltayyan commented 7 years ago

@Celebrandil can you please take some of your time to answer, sorry to insist but i gotta use this in my school project which is only a few weeks away

Celebrandil commented 7 years ago

Do you have an image illustrating the problem? SIFT features are often found in the weirdest of places.

omaraltayyan commented 7 years ago

@Celebrandil here is a video i made to illustrate the problem:

https://youtu.be/ine41zFnmpk

this is the code used for drawing

image.convertTo(image, CV_8UC1);
for (int i = 0; i < imageSiftData.numPts; i++)
{
    SiftPoint siftPoint = imageSiftData.h_data[i];
    Point2f pointToDraw(siftPoint.xpos, siftPoint.ypos);

    cv::circle(image, pointToDraw, 3, Scalar(0, 0, 0), 2);
}

and this is the keypoint detection code:

    image.convertTo(convertedImage, CV_32FC1);
        image = convertedImage;
    CudaImage cudaImage;
    unsigned int imageWidth = image.cols;
    unsigned int imageHeight = image.rows;

    cudaImage.Allocate(imageWidth, imageHeight, iAlignUp(imageWidth, 128), false, NULL, (float*)image.data);
    cudaImage.Download();

    // Extract Sift features from image
    SiftData imageSiftData;
    float initBlur = 1.0f;
    float thresh = 1.0f;
    InitSiftData(imageSiftData, 4096, true, true);

    ExtractSift(imageSiftData, cudaImage, 5, initBlur, thresh, 0.0f, false);
Celebrandil commented 7 years ago

I fail to see what the problem might be. It indeed looks like as if the coordinates are scaled up by a factor of two.

lgalardini commented 4 years ago

Hi there, this problem have been fixed? Is this the correct way to extract keypoints? Thank you in advance and have a nice day!

P.S. = thank you for your work and sharing!