Code Monkey home page Code Monkey logo

cudak2nn's Issues

Linux build issue (error: ‘memcpy’ was not declared in this scope)

g++ -c -I/usr/local/cuda/include/ -Wall -Wextra -Werror -Wshadow -pedantic -Ofast -std=gnu++17 -fomit-frame-pointer -march=native -flto -funroll-all-loops -fpeel-loops -ftracer -ftree-vectorize main.cpp -o main.o
nvcc --use_fast_math -arch=sm_30 -O3 -ccbin cc -std=c++11 -c -I/usr/local/cuda/include/ -Xcompiler "-Wall -Wextra -Werror -Wshadow -Ofast -fomit-frame-pointer -march=native -funroll-all-loops -fpeel-loops -ftracer -ftree-vectorize" CUDAK2NN.cu -o CUDAK2NN.o
/usr/include/string.h: In function ‘void* __mempcpy_inline(void*, const void*, size_t)’:
/usr/include/string.h:652:42: error: ‘memcpy’ was not declared in this scope
   return (char *) memcpy (__dest, __src, __n) + __n;

CUDAK2NN weird h_match values

I'm integrating koral into another project. The results of k2nn are really strange.
here's code snip

  CUDAK2NN(d_desc1, static_cast<int>(kpSize1), tex_q, static_cast<int>(kpSize2), d_matches, matchThreshold); // kpSize1 kpSize2

  // transferring matches back to host
  int* h_matches = reinterpret_cast<int*>(malloc(4 * kpSize2)); // kpSize2
  cudaMemcpy(h_matches, d_matches, 4 * kpSize2, cudaMemcpyDeviceToHost); // kpSize2

  for (size_t i = 0; i < maxkpNum; ++i) {
    if (h_matches[i] != -1) {   // h_matches[i] >= 0
      kMatches.emplace_back(i, h_matches[i]);
    }
    printf("h_match=%i \n", h_matches[i]);
  }

and here's a snip of the the printf statement

h_match=1073743776 
h_match=32661 
h_match=1073743776 
h_match=32661 
h_match=1081027728 
h_match=32661 
h_match=1081027728 
h_match=32661 
h_match=1077809840 
h_match=32661 
h_match=1073741952 
h_match=32661 
h_match=0 
h_match=0 

Am I mistaken by, expecting h_match[i] to equal an index of a corresponding descriptor?

Having a small problem combining KORAL and CUDAK2NN

Hello,

I am trying to test the combination of KORAL and CUDAK2NN for detection and matching. I am able to get KORAL working to detect and describe keypoints in two images, and I believe CUDAK2NN is working fine too, but I am having trouble actually retrieving the matches and drawing them. For a sample, I tried the simplest case: matching between the same image. I tried to follow your sample code from this link.

    memset(&resDesc, 0, sizeof(resDesc));
    resDesc.resType = cudaResourceTypeLinear;
    resDesc.res.linear.devPtr = &koral.desc[0];
    resDesc.res.linear.desc.f = cudaChannelFormatKindUnsigned;
    resDesc.res.linear.desc.x = 32;
    resDesc.res.linear.desc.y = 32;
    resDesc.res.linear.sizeInBytes = 64 * koral.kps.size();
    struct cudaTextureDesc texDesc;
    memset(&texDesc, 0, sizeof(texDesc));
    texDesc.addressMode[0] = cudaAddressModeBorder;
    texDesc.addressMode[1] = cudaAddressModeBorder;
    texDesc.filterMode = cudaFilterModePoint;
    texDesc.readMode = cudaReadModeElementType;
    texDesc.normalizedCoords = 0;
    cudaTextureObject_t tex_q = 0;
    cudaCreateTextureObject(&tex_q, &resDesc, &texDesc, nullptr);

    int* d_matches;
    cudaMalloc(&d_matches, 4 * koral.kps.size());

    CUDAK2NN(&koral.desc[0], static_cast<int>(koral.kps.size()), tex_q, static_cast<int>(koral.kps.size()), d_matches,  5);

    int* h_matches = reinterpret_cast<int*>(malloc(4 * koral.kps.size()));
    cudaMemcpy(h_matches, d_matches, 4 * koral.kps.size(), cudaMemcpyDeviceToHost);
    cudaDeviceReset();

    std::cout << "CUDA reports " << cudaGetErrorString(cudaGetLastError()) << std::endl;

    std::vector<Match> matches;
    std::vector<cv::DMatch> dmatches;
    for (int i = 0; i < koral.kps.size(); ++i) {
        if (h_matches[i] != -1) {
            matches.emplace_back(i, h_matches[i]);
            dmatches.emplace_back(h_matches[i], i, 0.0f);
        }
    }

    std::cout << "CUDAK2NN found " << matches.size() << " matches." << std::endl;
    std::cout << static_cast<int>(converted_kps.size()) << std::endl;

    cv::Mat image_with_matches;
    cv::drawMatches(image, converted_kps, image, converted_kps, dmatches, image_with_matches, cv::Scalar::all(-1.0), cv::Scalar::all(-1.0), std::vector<char>(), cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
    cv::namedWindow("Matches", CV_WINDOW_NORMAL | CV_WINDOW_KEEPRATIO);
    cv::imshow("Matches", image_with_matches);
    cv::waitKey(0);

The output from the detection and matching is exactly as expected:

KORAL found 30994 keypoints and descriptors.
CUDA reports no error
CUDAK2NN found 30993 matches.

But I seem to be making a mistake in retrieving the matches, because h_matches is just full of junk values which eventually causes drawMatches to fail. Could you please let me know where I am going wrong with that? Thanks a lot!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.