Ask Your Question

Revision history [back]

Generate a mask for FAST keypoints in c++

im trying to use a mask to compute SIFT descriptors. The idea is the following:

  • Detect keypoints with FAST
  • Create a mask with those keypoints
  • Pass that mask in the detectAndCompute method of the SIFT algorithm

Here is my code:

fast->detect(frame, fkps2);
std::vector<cv::Point2i> mask;
for (int i = 0; i < sizeof(fkps2); i++) {
    mask[i] = fkps2[i].pt;
}
algo->detectAndCompute(frame, mask, keypoints2, descriptors2, true);

In python i did this the following way:

mask = np.array([np.uint8(k.pt[0]) for k in kp2])

However in C++ this doesnt work (the point2 int vector mask cant be applied to frame)

Generate a mask for FAST keypoints in c++

im trying I want to use a mask FAST keypoints to compute improve the SIFT descriptors. The idea is the following:detector and find keypoints more easily.

  • Detect keypoints

    I have tried doing this many times but i have a problem with FAST

  • Create a mask with those keypoints
  • Pass that mask in converting the detectAndCompute method of the SIFT algorithm

point to 8 bit unsigned int. Here is my code:

fast->detect(frame, fkps2);
std::vector<cv::Point2i> mask;
cv::Mat mask = cv::Mat();
for (int i = 0; i < sizeof(fkps2); size(fkps2); i++) {
    mask[i] = fkps2[i].pt;
mask.push_back(cv::Mat(fkps2[i].pt));
}
algo->detectAndCompute(frame, mask, keypoints2, descriptors2, true);

In python i did this This does generate the following way:mask without a problem, but the problem occures when passing the mask in the detect function of SIFT:

mask = np.array([np.uint8(k.pt[0]) for k in kp2])
algo->detect(frame, keypoints2, mask);

However Here it says that types of points in C++ mask must be 8 bit unsigned ints. Basically, the each of fkps2[i].pt needs to be converted to an unsigned int.

I have done research and tried many ways of doing this doesnt work (the point2 int vector mask cant be applied to frame)but was unsuccessful in doing so.

Generate a mask for FAST keypoints in c++

I want to use a mask FAST keypoints to improve the SIFT detector and find keypoints more easily.

I have tried doing this many times but i have a problem with converting the point to 8 bit unsigned int. Here is my code:

fast->detect(frame, fkps2);
cv::Mat mask = cv::Mat();
for (int i = 0; i < size(fkps2); i++) {
    mask.push_back(cv::Mat(fkps2[i].pt));
}

This does generate the mask without a problem, but the problem occures when passing the mask in the detect function of SIFT:

algo->detect(frame, keypoints2, mask);

Here it says that types of points in mask must be 8 bit unsigned ints. Basically, the each of fkps2[i].pt needs to be converted to an unsigned int.

I have done research and tried many ways of doing this but was unsuccessful in doing so.