brute-force search
#include <pcl/search/brute_force.h>
#include <pcl/common/common.h>
#include <iostream> using namespace std;
using namespace pcl; int main()
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>); // x+y+z=1平面
for (float x = -1.0; x <= 1.0; x += 0.5)
{
for (float y = -1.0; y <= 1.0; y += 0.5)
{
pcl::PointXYZ cloud_;
cloud_.x = x;
cloud_.y = y;
cloud_.z = - x - y;
cloud->push_back(cloud_);
}
} pcl::search::BruteForce<pcl::PointXYZ> bfsearch;
bfsearch.setInputCloud(cloud);
std::vector<int> k_indices;
std::vector<float> k_distances;
pcl::PointXYZ p(-1.0,-1.0,3.0);
bfsearch.nearestKSearch(p,,k_indices,k_distances); return ;
}
template <typename PointT> int
pcl::search::BruteForce<PointT>::denseKSearch (
const PointT &point, int k, std::vector<int> &k_indices, std::vector<float> &k_distances) const
{
// container for first k elements -> O(1) for insertion, since order not required here
std::vector<Entry> result;
result.reserve (k);
std::priority_queue<Entry> queue; Entry entry;
for (entry.index = ; entry.index < std::min (static_cast<unsigned> (k), static_cast<unsigned> (input_->size ())); ++entry.index)
{
entry.distance = getDistSqr (input_->points[entry.index], point);
result.push_back (entry);
} queue = std::priority_queue<Entry> (result.begin (), result.end ()); // add the rest
for (; entry.index < input_->size (); ++entry.index)
{
entry.distance = getDistSqr (input_->points[entry.index], point);
if (queue.top ().distance > entry.distance)
{
queue.pop ();
queue.push (entry);
}
} k_indices.resize (queue.size ());
k_distances.resize (queue.size ());
size_t idx = queue.size () - ;
while (!queue.empty ())
{
k_indices [idx] = queue.top ().index;
k_distances [idx] = queue.top ().distance;
queue.pop ();
--idx;
} return (static_cast<int> (k_indices.size ()));
}
brute-force search的更多相关文章
- nginx 1.3.9/1.4.0 x86 Brute Force Remote Exploit
测试方法: 本站提供程序(方法)可能带有攻击性,仅供安全研究与教学之用,风险自负! #nginx 1.3.9/1.4.0 x86 brute force remote exploit # copyri ...
- 常用字符串匹配算法(brute force, kmp, sunday)
1. 暴力解法 // 暴力求解 int Idx(string S, string T){ // 返回第一个匹配元素的位置,若没有匹配的子串,则返回-1 int S_size = S.length(); ...
- 小白日记46:kali渗透测试之Web渗透-SqlMap自动注入(四)-sqlmap参数详解- Enumeration,Brute force,UDF injection,File system,OS,Windows Registry,General,Miscellaneous
sqlmap自动注入 Enumeration[数据枚举] --privileges -U username[CU 当前账号] -D dvwa -T users -C user --columns [ ...
- SRM 582 Div II Level Three: ColorTheCells, Brute Force 算法
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12581 Burte Force 算法,求解了所有了情况,注意 ...
- Test SRM Level Three: LargestCircle, Brute Force
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=3005&rd=5858 思路: 如果直接用Brute F ...
- 安全性测试入门:DVWA系列研究(一):Brute Force暴力破解攻击和防御
写在篇头: 随着国内的互联网产业日臻成熟,软件质量的要求越来越高,对测试团队和测试工程师提出了种种新的挑战. 传统的行业现象是90%的测试工程师被堆积在基本的功能.系统.黑盒测试,但是随着软件测试整体 ...
- HDU 6215 Brute Force Sorting(模拟链表 思维)
Brute Force Sorting Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Othe ...
- hdu6215 Brute Force Sorting
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6215 题目: Brute Force Sorting Time Limit: 1000/100 ...
- HDU - 6215 2017 ACM/ICPC Asia Regional Qingdao Online J - Brute Force Sorting
Brute Force Sorting Time Limit: 1 Sec Memory Limit: 128 MB 题目连接 http://acm.hdu.edu.cn/showproblem.p ...
- 「暑期训练」「Brute Force」 Restoring Painting (CFR353D2B)
题意 给定一定条件,问符合的矩阵有几种. 分析 见了鬼了,这破题谁加的brute force的标签,素质极差.因为范围是1e5,那你平方(枚举算法)的复杂度必然爆. 然后你就会思考其中奥妙无穷的数学规 ...
随机推荐
- 深入理解C++的动态绑定和静态绑定【转】
转自:http://blog.csdn.net/chgaowei/article/details/6427731 为了支持c++的多态性,才用了动态绑定和静态绑定.理解他们的区别有助于更好的理解多态性 ...
- 华东交通大学2016年ACM“双基”程序设计竞赛 1008
Problem Description halfyarn找你写个简单的题?好哒!给你n个整数,现在要求你选择两个位置的数,例如选择第pos_a个数a,和第pos_b个数b,给定ans=min(a,b) ...
- [问题2014S13] 复旦高等代数II(13级)每周一题(第十三教学周)
[问题2014S13] (1) 设 \(A\) 是数域 \(\mathbb{K}\) 上的 \(n\) 阶非异阵, 若存在主对角元全为 \(1\) 的下三角阵 \(L\in M_n(\mathbb ...
- Linux Shell 文本处理工具集锦
本文将介绍Linux下使用Shell处理文本时最常用的工具:find.grep.xargs.sort.uniq.tr.cut.paste.wc.sed.awk:提供的例子和参数都是最常用和最为实用的: ...
- c++ 指针常量,常量指针
当const遇到指针 一般来说,const修饰指针可以分为下面的集中情况. 描述 例子 含义 备注 const在*的左边 const int *b=&a; int const *b=& ...
- Educational Codeforces Round 6 E. New Year Tree dfs+线段树
题目链接:http://codeforces.com/contest/620/problem/E E. New Year Tree time limit per test 3 seconds memo ...
- js函数式编程
最近在看朴灵的<深入浅出nodejs>其中讲到函数式编程.理解记录下 高阶函数 比较常见,即将函数作为参数,或是将函数作为返回值得函数. 如ECMAScript5中提供的一些数组方法 fo ...
- [必会] 表单验证+弹框~老司机原生js
<!DOCTYPE html><html><head> <meta charset="gb2312"> <title>恰 ...
- 微软2017校招笔试题2 composition
题目 Alice writes an English composition with a length of N characters. However, her teacher requires ...
- Http协议总结
Http协议(Hyper Text Transfer Protocol)是目前网络上使用最广泛的,面向应用层的协议.它基于传输层的TCP协议进行通信.它是一种通用的,无状态的协议(不对当前的状态进行记 ...