Skip to content

Commit

Permalink
ORB sorts FAST detector results for repeatability
Browse files Browse the repository at this point in the history
  • Loading branch information
timbobbarnes committed Apr 20, 2016
1 parent 3bd6912 commit b20cbd0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions modules/gpu/src/cuda/orb.cu
Expand Up @@ -53,15 +53,24 @@ namespace cv { namespace gpu { namespace device
{
namespace orb
{
struct greater_pos : public thrust::binary_function<short2,short2,bool>
{
__host__ __device__ bool operator()(const short2& a, const short2& b) const
{
return (a.x > b.x) || ((a.x == b.x) && (a.y > b.y));
}
};

////////////////////////////////////////////////////////////////////////////////////////////////////////
// cull

int cull_gpu(int* loc, float* response, int size, int n_points)
{
thrust::device_ptr<int> loc_ptr(loc);
thrust::device_ptr<short2> loc_ptr((short2 *) loc);
thrust::device_ptr<float> response_ptr(response);

thrust::sort_by_key(response_ptr, response_ptr + size, loc_ptr, thrust::greater<float>());
thrust::sort_by_key(loc_ptr, loc_ptr + size, response_ptr, greater_pos());
thrust::stable_sort_by_key(response_ptr, response_ptr + size, loc_ptr, thrust::greater<float>());

return n_points;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/gpu/src/orb.cpp
Expand Up @@ -399,7 +399,7 @@ namespace
cv::gpu::ORB_GPU::ORB_GPU(int nFeatures, float scaleFactor, int nLevels, int edgeThreshold, int firstLevel, int WTA_K, int scoreType, int patchSize) :
nFeatures_(nFeatures), scaleFactor_(scaleFactor), nLevels_(nLevels), edgeThreshold_(edgeThreshold), firstLevel_(firstLevel), WTA_K_(WTA_K),
scoreType_(scoreType), patchSize_(patchSize),
fastDetector_(DEFAULT_FAST_THRESHOLD)
fastDetector_(DEFAULT_FAST_THRESHOLD, true, 1)
{
CV_Assert(patchSize_ >= 2);

Expand Down

0 comments on commit b20cbd0

Please sign in to comment.