jiexiong2016 / GCNv2_SLAM

Real-time SLAM system with deep features
Other
769 stars 194 forks source link

Using the GCN features independantly #30

Open antithing opened 4 years ago

antithing commented 4 years ago

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!

LifeIsSoSolong commented 2 years ago

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).