本文整理汇总了C++中parameters::find方法的典型用法代码示例。如果您正苦于以下问题:C++ parameters::find方法的具体用法?C++ parameters::find怎么用?C++ parameters::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parameters
的用法示例。
在下文中一共展示了parameters::find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extract
static return_type extract(parameters const& params,
std::string const& name,
boost::optional<T> const& default_opt_value)
{
boost::optional<T> result(default_opt_value);
parameters::const_iterator itr = params.find(name);
if (itr != params.end())
{
util::apply_visitor(value_extractor_visitor<T>(result),itr->second);
}
return result;
}
示例2: diff
matches im_utility::diff(const std::string &im_file1, const std::string &im_file2, const parameters ¶ms, key_points *im1_kps, key_points *im2_kps)
{
using namespace cv;
matches mt;
std::vector<KeyPoint> im1_key_points, im2_key_points;
std::vector<DMatch> matches;
std::vector<DMatch> good_matches;
double min_hessian = 400.0;
if (params.find(key_hessian_threshold) != params.end()) min_hessian = params.at(key_hessian_threshold);
double sigma = 2.0;
if (params.find(key_match_threshold) != params.end()) sigma = params.at(key_match_threshold);
int speedup = speedup_default;
if (params.find(key_speedup) != params.end())
speedup = params.at(key_speedup);
//auto info = getBuildInformation();
if (speedup == speedup_use_cuda)
{
using namespace gpu;
DeviceInfo dev;
auto name = dev.name();
GpuMat img1, img2;
// upload data
img1.upload(imread(im_file1, CV_LOAD_IMAGE_GRAYSCALE));
img2.upload(imread(im_file2, CV_LOAD_IMAGE_GRAYSCALE));
// detect keypoints & computing descriptors
SURF_GPU surf;
GpuMat kps_gpu1, kps_gpu2;
GpuMat desc_gpu1, desc_gpu2;
surf(img1, GpuMat(), kps_gpu1, desc_gpu1);
surf(img2, GpuMat(), kps_gpu2, desc_gpu2);
// matching descriptors
BFMatcher_GPU matcher_gpu(NORM_L2);
GpuMat trainIdx, distance;
matcher_gpu.matchSingle(desc_gpu1, desc_gpu2, trainIdx, distance);
// download results
std::vector<float> desc1, desc2;
surf.downloadKeypoints(kps_gpu1, im1_key_points);
surf.downloadKeypoints(kps_gpu2, im2_key_points);
surf.downloadDescriptors(desc_gpu1, desc1);
surf.downloadDescriptors(desc_gpu2, desc2);
BFMatcher_GPU::matchDownload(trainIdx, distance, matches);
good_matches = matches;
}
else if (speedup == speedup_use_ocl)
{
using namespace ocl;
DevicesInfo devs;
getOpenCLDevices(devs, CVCL_DEVICE_TYPE_GPU);
int dev = 0;
if (params.find(key_ocl_dev) != params.end())
dev = params.at(key_ocl_dev);
if (dev < 0 || dev >= devs.size()) dev = 0;
setDevice(devs[dev]);
SURF_OCL surf(800.0);
BFMatcher_OCL matcher(NORM_L2);
oclMat desc1, desc2;
oclMat im1, im2;
im1 = imread(im_file1, CV_LOAD_IMAGE_GRAYSCALE);
im2 = imread(im_file2, CV_LOAD_IMAGE_GRAYSCALE);
surf(im1, oclMat(), im1_key_points, desc1);
surf(im2, oclMat(), im2_key_points, desc2);
matcher.match(desc1, desc2, matches);
double max_dist = 0;
double min_dist = 100;
for (int i = 0; i < desc1.rows; i++)
{
double dist = matches[i].distance;
if (dist < min_dist) min_dist = dist;
if (dist > max_dist) max_dist = dist;
}
for (int i = 0; i < desc1.rows; i++)
{
if (matches[i].distance <= max(sigma * min_dist, 0.02))
{
good_matches.push_back(matches[i]);
}
}
}
else
{
auto get_file_desc = [](const std::string &filename, double min_hessian, std::vector<cv::KeyPoint> *out_key_points)
{
using namespace cv;
Mat desc;
Mat img = imread(filename, CV_LOAD_IMAGE_GRAYSCALE);
if (!img.data) return desc;
//.........这里部分代码省略.........