CudaSift icon indicating copy to clipboard operation
CudaSift copied to clipboard

Why I can't get any match correspondence even with the same images?

Open yiran-THU opened this issue 5 years ago • 10 comments

Thank you for sharing this implementaion!

Environment

  • Platform: Windows 10 64-bit, VS2015 OpenCV3.4.1 CUDA8 1060

Current Behavior:

I have successfully build this repository with no errors. I have tested mainSift.cpp with the same image (limg and rimg are the same picture) many times, none of them get any match correspondence! I never chenge the code of mainSift.cpp.

Here is My output of mainSift.cpp:

Image size = (812,725)
Initializing data...
Device Number: 0
  Device name: GeForce GTX 1060
  Memory Clock Rate (MHz): 4004
  Memory Bus Width (bits): 192
  Peak Memory Bandwidth (GB/s): 192.2

SIFT extraction time =        1.99 ms
Incl prefiltering & memcpy =  3.09 ms 2623

SIFT extraction time =        1.82 ms
Incl prefiltering & memcpy =  3.06 ms 2624

MatchSiftData time =          6.16 ms
...
MatchSiftData time =          4.85 ms
Number of original features: 2623 2624
Number of matching features: 0 0 0% 1 3

Expected Behavior:

I expect CUDAsift find the correct correspondence , and show the correspondence between model image and test image.

Besides, the finding homography process is based on both model image's feature and test image's feature. Why there is only siftData1 input to functionFindHomography and ImproveHomography in mainSift.cpp?

for (int i = 0; i<500; i++)
  MatchSiftData(siftData1, siftData2);
float homography[9];
int numMatches;
FindHomography(siftData1, homography, &numMatches, 10000, 0.00f, 0.80f, 5.0);
int numFit = ImproveHomography(siftData1, homography, 5, 0.00f, 0.80f, 3.0);

I have been troubling in above two problems several days, can you help me for any suggestion? Thank you!

yiran-THU avatar Oct 21 '18 10:10 yiran-THU

That is weird. Could you upload the image? I cannot verify it. It might be something related to the unusual image size, but that seems like something I should have noticed before then.

Celebrandil avatar Oct 26 '18 08:10 Celebrandil

By the way, MatchSiftData uses both siftData1 and siftData2. It will create per feature cross-references, which means that FindHomography and ImproveHomography won't need siftData2.

Celebrandil avatar Oct 26 '18 08:10 Celebrandil

@Celebrandil I think something is wrong in the procedure of MatchSiftData of my computer. I have modified the mainSift.cpp, my test code fragment is shown below:

	ExtractSift(siftData1, img1, 5, initBlur, thresh, 0.0f, false, memoryTmp);
	ExtractSift(siftData2, img2, 5, initBlur, thresh, 0.0f, false, memoryTmp);

	FreeSiftTempMemory(memoryTmp);

	MatchSiftData(siftData1, siftData2);

        showCorrespondence(siftData1, siftData2, limg_0, rimg_0);


void showCorrespondence(SiftData &siftData1, SiftData &siftData2, cv::Mat limg_0, cv::Mat rimg_0)
{
	int numPts = siftData1.numPts;
	SiftPoint *sift1 = siftData1.h_data;
	SiftPoint *sift2 = siftData2.h_data;

	int w = limg_0.size().width;
	int h = limg_0.size().height;

	cv::resize(rimg_0, rimg_0, cv::Size(w, h));

	cv::Mat img_m = cv::Mat::zeros(h , 2*w,CV_8UC3);
	limg_0.copyTo(img_m(cv::Rect(0,0,w,h)));
	rimg_0.copyTo(img_m(cv::Rect(w,0,w,h)));

	std::cout << sift1[1].xpos << ", " << sift1[1].ypos << std::endl;
	for (int j = 0; j < numPts; j++)
	{
		int k = sift1[j].match;
		if (sift1[j].match_error < 5)
		{
			cv::circle(img_m, cv::Point(sift1[j].xpos, sift1[j].ypos),2,cv::Scalar(60, 20, 220),2);
			cv::circle(img_m, cv::Point(sift1[j].match_xpos + w, sift1[j].match_ypos), 2, cv::Scalar(173, 216, 230),2);
			std::cout << sift1[j].match_xpos << ", " << sift1[j].match_ypos << std::endl;
			cv::line(img_m,cv::Point(sift1[j].xpos, sift1[j].ypos),cv::Point(sift1[j].match_xpos + w, sift1[j].match_ypos),cv::Scalar(0,255,0),1);
		}
	}

	cv::namedWindow("Result");
	cv::resizeWindow("Result",cv::Size(600,300));
	cv::imshow("Result",img_m);
	cv::waitKey();
}

The result picture is _20181030114552

yiran-THU avatar Oct 30 '18 03:10 yiran-THU

Unfortunately, I cannot verify it on my machine with the images from the data/ directory, even with your showCorrespondence function. Weird.

img_m

Celebrandil avatar Nov 01 '18 14:11 Celebrandil

@Celebrandil what's the CUDA version are you use?

yiran-THU avatar Nov 02 '18 02:11 yiran-THU

Here is my result. result

yiran-THU avatar Nov 02 '18 02:11 yiran-THU

@Celebrandil what's the CUDA version are you use?

Hello yiran-THU, can you send me a copy of my version, I have the same configuration as you, but my failure to compile successfully My email is [email protected]

yangninghua avatar Nov 26 '18 13:11 yangninghua

Here is my result. result

Building NVCC (Device) object CMakeFiles/cudasift.dir/Debug/cudasift_generated_cudaImage.cu.obj nvcc fatal : redefinition of argument 'gpu-architecture' CMake Error at cudasift_generated_cudaImage.cu.obj.Debug.cmake:219 (message): Error generating E:/ynh/c2/build/CMakeFiles/cudasift.dir//Debug/cudasift_generated_cudaImage.cu.obj

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB6006: “cmd.exe”

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB6006: “cmd.exe”

yangninghua avatar Nov 26 '18 13:11 yangninghua

Building NVCC (Device) object CMakeFiles/cudasift.dir/Debug/cudasift_generated_cudaImage.cu.obj nvcc fatal : redefinition of argument 'gpu-architecture' CMake Error at cudasift_generated_cudaImage.cu.obj.Debug.cmake:219 (message): Error generating E:/ynh/c2/build/CMakeFiles/cudasift.dir//Debug/cudasift_generated_cudaImage.cu.obj

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB6006: “cmd.exe”

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB6006: “cmd.exe”

Please see my comment here. I used this method today to get everything to successfully compile on Windows 10.

EDIT: The version of Visual Studio doesn't matter. I managed to get everything to work in VS2017. The solution that I ended up with was the method mentioned in my other comment where I modified the architecture value from the code supplied by Celebrandil. I have a GT640 graphics card so I had to use the lowest available architecture value which I believe is 3.0 (even though the website says 2.1 CUDA only supports as low as 3.0 now.)

gmcgrath-lakehead avatar Apr 09 '19 20:04 gmcgrath-lakehead

@yangninghua remove duplicated flag -arch=sm_62 works for me

mintisan avatar May 28 '19 14:05 mintisan