GCNv2_SLAM icon indicating copy to clipboard operation
GCNv2_SLAM copied to clipboard

Using the GCN features independantly

Open antithing opened this issue 5 years ago • 1 comments

Hi, thank you for making this code available. I am trying to build a test project that uses the deep features outside of OrbSlam, and I am running:

void main()
{
	GCNextractor* mpGCNextractor;

	int nFeatures = 1200;
	float fScaleFactor = 1.2;
	int nLevels = 8;
	int fIniThFAST = 20;
	int fMinThFAST = 7;

	mpGCNextractor = new GCNextractor(nFeatures, fScaleFactor, nLevels, fIniThFAST, fMinThFAST);


	std::cout << "loaded deep model" << std::endl;

	cv::Mat frame1 = cv::imread("frames/frame_0Left.jpg", 1);
	cv::Mat frame2 = cv::imread("frames/frame_60Left.jpg", 1);


	cv::resize(frame1, frame1, cv::Size(640, 480));
	cv::resize(frame2, frame2, cv::Size(640, 480));


	std::vector<cv::KeyPoint> mvKeys, mvKeys2;
	cv::Mat mDescriptors, mDescriptors2;

	(*mpGCNextractor)(frame1, cv::Mat(), mvKeys, mDescriptors);
	(*mpGCNextractor)(frame2, cv::Mat(), mvKeys2, mDescriptors2);


	cv::Mat outImg;
	cv::drawKeypoints(frame1, mvKeys, outImg, cv::Scalar(255, 0, 0),cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);

	std::vector<cv::DMatch> matches;
	std::vector<cv::Mat> descMatch; // matched desc to return
	find_feature_matches(mvKeys, mvKeys2, mDescriptors, mDescriptors2, matches);


	cv::Mat matchesImage2;
	cv::drawMatches(frame1, mvKeys, frame2, mvKeys2, matches, matchesImage2);
	cv::imshow("curr-prev", matchesImage2);
	cv::waitKey(1);
	cv::imshow("kp", outImg);
	cv::waitKey(0);

}

This gives me keypoints, but they don't make any sense, and none are matched.

I have switched to:

 const char *net_fn = "GCN/gcn2_640x480.pt";
  //  net_fn = (net_fn == nullptr) ? "gcn2.pt" : net_fn;
    module = torch::jit::load(net_fn);

in GCNextractor.cpp.

What am I doing wrong?

Thanks!

antithing avatar Aug 20 '19 16:08 antithing

Have you solve this problem? I only want to get keypoints using GCNv2.

When I use GCNextractor to get kps like your code, I get some kps evenly distributed (no use).

LifeIsSoSolong avatar Feb 16 '22 12:02 LifeIsSoSolong