void computeDescriptors( const cv::Mat& image, std::vector<cv::KeyPoint>& keypoints, cv::Mat& descriptors) { std::vector<float> d; cv::gpu::GpuMat imgGpu(image); cv::gpu::GpuMat descriptorsGPU; try { surf_(imgGpu, cv::gpu::GpuMat(), keypoints, descriptorsGPU, true); } catch(cv::Exception &e) { UERROR("GPUSURF error: %s \n(If something about layer_rows, parameter nOctaves=%d of SURF " "is too high for the size of the image (%d,%d).)", e.msg.c_str(), surf_.nOctaves, image.cols, image.rows); } // Download descriptors if (descriptorsGPU.empty()) descriptors = cv::Mat(); else { Q_ASSERT(descriptorsGPU.type() == CV_32F); descriptors = cv::Mat(descriptorsGPU.size(), CV_32F); descriptorsGPU.download(descriptors); } }
void SurfFeaturesFinderGpu::find(const Mat &image, ImageFeatures &features) { CV_Assert(image.depth() == CV_8U); ensureSizeIsEnough(image.size(), image.type(), image_); image_.upload(image); ensureSizeIsEnough(image.size(), CV_8UC1, gray_image_); cvtColor(image_, gray_image_, CV_BGR2GRAY); surf_.nOctaves = num_octaves_; surf_.nOctaveLayers = num_layers_; surf_.upright = false; surf_(gray_image_, GpuMat(), keypoints_); surf_.nOctaves = num_octaves_descr_; surf_.nOctaveLayers = num_layers_descr_; surf_.upright = true; surf_(gray_image_, GpuMat(), keypoints_, descriptors_, true); surf_.downloadKeypoints(keypoints_, features.keypoints); descriptors_.download(features.descriptors); }
void detectKeypoints(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints, const cv::Mat & mask = cv::Mat()) { cv::gpu::GpuMat imgGpu(image); cv::gpu::GpuMat maskGpu(mask); try { surf_(imgGpu, maskGpu, keypoints); } catch(cv::Exception &e) { UERROR("GPUSURF error: %s \n(If something about layer_rows, parameter nOctaves=%d of SURF " "is too high for the size of the image (%d,%d).)", e.msg.c_str(), surf_.nOctaves, image.cols, image.rows); } }