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,那你平方(枚举算法)的复杂度必然爆. 然后你就会思考其中奥妙无穷的数学规 ...
随机推荐
- (2) 深入理解Java Class文件格式(一)
好文转载:http://blog.csdn.net/zhangjg_blog/article/details/21486985 Class文件在Java体系结构中的位置和作用 在上一篇博客中, 大致讲 ...
- ado.net C#如何实现数据库增删改查
ado.net数据库访问技术将数据库中的数据,提取到内存中,展示给用户看还可以将内存中的数据写入数据库中去 并不是唯一的数据库访问技术,但是它是最底层的数据库访问技术也就是说是最麻烦但是是最不可缺少的 ...
- 【Nginx】配置Nginx的负载均衡
参考的优秀文章 tomcat配置文件server.xml详解 AJP协议总结与分析 Using nginx as HTTP load balancer 在本机运行2个Tomcat 现需要运行两个Tom ...
- C++string中有关字符串内容修改和替换的函数浅析
1.assign() 原型: //string (1) basic_string& assign (const basic_string& str); //substring (2) ...
- linux 修改home目录下的中文目录名为英文
编辑home/下的 .config/user-dirs.dirs,把所有的中文名称修改为英文名称 在home目录下创建对应的英文名称路径 运行 xdg-user-dirs-update 重启机器
- consul笔记-集群加入的问题
加入集群的问题 1 只有2个server的时候,一个挂掉,不会选举出新的leader. 2 使用 -bootstrap 可以直接启动为leader,这和-bootstrap-expect 是有区别的 ...
- jsoup: Java HTML Parser (类似jquery)
jsoup is a Java library for working with real-world HTML. It provides a very convenient API for extr ...
- 25、java中观察者模式Observable和Observer
如果想要实现观察者模式,则必须依靠java.util包中提供的Observable类和Observer接口 观察者设计模式 现在很多的购房者都在关注着房子的价格变化,每当房子价格变化的时候,所有的购房 ...
- Windows2012安装IIS和FTP
Windows2012安装IIS和FTP 1.打开Windows 2012的服务器管理器,选择 管理→添加角色和功能 2.进入 添加角色和功能向导,选择 “Web服务器(IIS)” 3.根据情况选 ...
- 实体类调用泛型父类中的静态方法中执行CRUD——第二版
using System; using System.Collections.Generic; using System.Data.Entity; using System.Linq; namespa ...