Conver cv::KeyPoint::pt to 8 bit unsigned int in opencv 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.
where did you find that idea ?
no, no, no, you entirely misunderstood it. the mask needs to be an image same size of your frame, with white pixels, where you want detection to happen.
The idea was not mine, it was my coworkers'. I have done this same thing in python with the following line:
When converting the types in python i used numpy, but in c++ that proves to be a problem. also from my understanding the mask just passes coordinates to the detect method which tells it where to look for the keypoints.
mask Mask specifying where to look for keypoints (optional). It must be a 8-bit integer matrix with non-zero values in the region of interest. Here is the docs written for the function in c++