diff --git a/modules/gpu/src/cuda/orb.cu b/modules/gpu/src/cuda/orb.cu index 723bf28ffb04..bcaf265d8d37 100644 --- a/modules/gpu/src/cuda/orb.cu +++ b/modules/gpu/src/cuda/orb.cu @@ -53,15 +53,24 @@ namespace cv { namespace gpu { namespace device { namespace orb { + struct greater_pos : public thrust::binary_function + { + __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 loc_ptr(loc); + thrust::device_ptr loc_ptr((short2 *) loc); thrust::device_ptr response_ptr(response); - thrust::sort_by_key(response_ptr, response_ptr + size, loc_ptr, thrust::greater()); + 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()); return n_points; } diff --git a/modules/gpu/src/orb.cpp b/modules/gpu/src/orb.cpp index af224a5351e1..64d4b1d03e1a 100644 --- a/modules/gpu/src/orb.cpp +++ b/modules/gpu/src/orb.cpp @@ -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);