久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费
標題:
ROS中激光雷達數(shù)據(jù)處理之特征提取 源程序
[打印本頁]
作者:
18864960139
時間:
2022-3-3 11:10
標題:
ROS中激光雷達數(shù)據(jù)處理之特征提取 源程序
ROS中激光雷達的數(shù)據(jù)就是一串距離值,每隔1度一個距離值(具體情況得看激光雷達的參數(shù)),通過實測激光雷達的數(shù)據(jù)提取關(guān)鍵特征,直線,圓弧
// 進行多邊形擬合: Points : 輪廓上的點 n -- 輪廓點數(shù)目 Eps -- 擬合精度
// 返回值: 若該輪廓段需要分段,則返回分段點在該輪廓點列中的索引,否則,返回 0 表示不需要分段
// 這里是整個算法計算復(fù)雜性最大的一個地方
// 為了提高程序運行效率,對點到直線的距離計算進行改進:
// 多邊形擬合中的直線是由點列中的點決定的
// 為了計算點到直線的距離,
// 采用坐標系旋轉(zhuǎn),將直線旋轉(zhuǎn)到x軸方向,這樣點到直線的距離即為各個點
// 在坐標旋轉(zhuǎn)后的y值的絕對值
// 同時,坐標旋轉(zhuǎn)矩陣在該次運算中為定值,只需一次計算,不需要多次的開方或三角計算
int OpenRadar::PolyContourFit( int* X, int* Y, int n , float Eps ) // 根據(jù)輪廓點,用多邊形擬合該輪廓點
{
double dis = sqrt((double)(((X[0] - X[n - 1])*(X[0] - X[n - 1])) +
((Y[0] - Y[n - 1])* (Y[0] - Y[n - 1]))));
double cosTheta = (X[n- 1] - X[0]) / dis;
double sinTheta = - ( Y[n- 1] - Y[0] )/dis;
double MaxDis = 0;
int i ;
int MaxDisInd = -1;
double dbDis;
for(i = 1 ; i < n - 1 ; i++)
{
// 進行坐標旋轉(zhuǎn),求旋轉(zhuǎn)后的點到x軸的距離
dbDis = abs( (Y[i] - Y[0]) * cosTheta + (X[i] - X[0])* sinTheta);
if( dbDis > MaxDis)
{
MaxDis = dbDis;
MaxDisInd = i;
}
}
if(MaxDis > Eps)
{
return MaxDisInd;
// cout << "Line 1 : " << endl;
// cout << "Start :" << Points[0].x << " " << Points[0].y << " --- " << Points[MaxDisInd].x << " " << Points[MaxDisInd].y << endl;
// cout << "角度: "<<180 * atan2(Points[0].y - Points[MaxDisInd].y , Points[0].x - Points[MaxDisInd].x ) / 3.1415926;
// cout << "Line 2 :" << endl;
// cout << "Start :" << Points[MaxDisInd].x << " " << Points[MaxDisInd].y << " --- " << Points[n - 1].x << " " << Points[n - 1].y << endl;
// cout << "角度: "<< 180 * atan2(Points[n - 1].y - Points[MaxDisInd].y , Points[n - 1].x - Points[MaxDisInd].x ) / 3.1415926;
}
// else{
// cout << "Line 1 : " << endl;
// cout << "Start :" << Points[0].x << " " << Points[0].y << " --- " << Points[n - 1].x << " " << Points[n - 1].y << endl;
// cout << "角度: "<<180 * atan2(Points[n - 1].y - Points[0].y , Points[n - 1].x - Points[0].x ) / 3.1415926;
// }
return 0;
}
//將折線拆成兩段
int OpenRadar::BreakPolyLine(vector<int>& BreakedRadarRho,
vector<double>& BreakedRadarTheta,
vector<int>& SepRadarRho ,
vector<double>&SepRadarTheta)
{
int rho = 0;
double theta = 0.0;
int X[1200] = {0};
int Y[1200] = {0};
int rhoCopy[1200] = {0};
double thetaCopy[1200] = {0};
int pointCnt = 0;
int lineCnt = 0;
int N = 0;
SepRadarRho.clear();
SepRadarTheta.clear();
Corners.clear();
//進行多次迭代,將所有的折線都拆分成直線段
vector<int>CornerIndex;
int CornerCnt = 0;
int tempIndex = 0;
for (int i = 0; i < static_cast<int>(BreakedRadarRho.size());i++)
{
rho = BreakedRadarRho.at(i);
theta = BreakedRadarTheta.at(i);
if (rho < 0)
{
if (pointCnt > 200)//數(shù)目比較少的點直接拋棄
{
CornerIndex.clear();
CornerCnt = FindCorners(CornerIndex,X,Y,0,pointCnt,200);
if (CornerIndex.size() == 0)
{
for (int k = 0 ; k < pointCnt;k++)
{
SepRadarRho.push_back(rhoCopy[k]);
SepRadarTheta.push_back(thetaCopy[k]);
}
SepRadarRho.push_back(-1);
SepRadarTheta.push_back(1000.0);
lineCnt++;
}else
{
tempIndex = 0;
for (int k = 0 ; k < pointCnt;k++)
{
SepRadarRho.push_back(rhoCopy[k]);
SepRadarTheta.push_back(thetaCopy[k]);
if (k == CornerIndex.at(tempIndex))
{
SepRadarRho.push_back(-1);
SepRadarTheta.push_back(1000.0);
lineCnt++;
if (tempIndex < static_cast<int>(CornerIndex.size()) -1)
{
tempIndex++;
}
}
}
SepRadarRho.push_back(-1);
SepRadarTheta.push_back(1000.0);
lineCnt++;
}
}
pointCnt = 0;
continue;
}
X[pointCnt] = static_cast<int>(rho*cos(theta));
Y[pointCnt] = static_cast<int>(rho*sin(theta));
rhoCopy[pointCnt] = rho;
thetaCopy[pointCnt] = theta;
pointCnt++;
}
//cout<<"lineCnt: "<<lineCnt<<endl;
return lineCnt;
}
//進行直線擬合
void OpenRadar::FitLine(vector<LinePara>& FittedLine,vector<int>& RadarRho,vector<double>& RadarTheta){
int rho = 0;
double theta = 0.0;
int X[1200] = {0};
int Y[1200] = {0};
int pointCnt = 0;
LinePara tmpLinePara;
FittedLine.clear();
for (int i = 0 ; i < static_cast<int>(RadarRho.size());i++)
{
rho = RadarRho.at(i);
theta = RadarTheta.at(i);
if (rho < 0)
{
if (pointCnt > 100 )//點數(shù)目足夠多的點列才進行直線擬合
{
WeightedFit(X ,Y ,pointCnt,&tmpLinePara);
FittedLine.push_back(tmpLinePara);
//存儲擬合的數(shù)據(jù)和擬合結(jié)果
/* FILE* pF = fopen("line.txt","w");
fprintf(pF,"[a]\n");
fprintf(pF,"%f\n",tmpLinePara.a);
fprintf(pF,"[b]\n");
fprintf(pF,"%f\n",tmpLinePara.b);
fprintf(pF,"[x]\n");
for (int j = 0; j < pointCnt ;j++)
{
fprintf(pF,"%d,",X[j]);
}
fprintf(pF,"\n[y]\n");
for (int j = 0; j < pointCnt ;j++)
{
fprintf(pF,"%d,",Y[j]);
}
fclose(pF);*/
pointCnt = 0;
continue;
}else {
pointCnt = 0;
continue;
}
}
X[pointCnt] = static_cast<int>(rho*cos(theta));
Y[pointCnt] = static_cast<int>(rho*sin(theta));
pointCnt++;
}
/* for (int i = 0; i < FittedLine.size();i++)
{
cout<<"a: "<<FittedLine.at(i).a<<" b: "<<FittedLine.at(i).b<<" ";
cout<<"x1: "<<FittedLine.at(i).startPoint.x<<" "
<<"y1: "<<FittedLine.at(i).startPoint.y<<" "
<<"x1: "<<FittedLine.at(i).endPoint.x<<" "
<<"y1: "<<FittedLine.at(i).endPoint.y<<endl;
}*/
}
復(fù)制代碼
51hei.png
(6.64 KB, 下載次數(shù): 90)
下載附件
2022-3-12 01:54 上傳
以上代碼:
OpenRadar7.0.zip
(25.96 KB, 下載次數(shù): 13)
2022-3-3 11:09 上傳
點擊文件名下載附件
激光雷達數(shù)據(jù)處理之特征提取
下載積分: 黑幣 -5
歡迎光臨 (http://www.zg4o1577.cn/bbs/)
Powered by Discuz! X3.1
主站蜘蛛池模板:
最新午夜综合福利视频
|
日韩专区中文字幕
|
日韩精品一二三
|
99久久电影
|
av黄色免费
|
爱爱爱av
|
成人超碰
|
99久久99
|
亚洲美女视频
|
国产福利91精品一区二区三区
|
日日操视频
|
久久久精品久久
|
国产 欧美 日韩 一区
|
国产欧美三区
|
国产视频1区
|
日韩国产一区二区
|
天天躁人人躁人人躁狂躁
|
成人午夜电影在线观看
|
国产精品综合一区二区
|
www.久久影视
|
国产精品成人在线
|
久久国产精品视频
|
天天夜碰日日摸日日澡
|
一区二区三区欧美在线观看
|
国产精品一卡二卡三卡
|
男女视频在线观看免费
|
亚洲精品一区中文字幕
|
男女爱爱网站
|
久久一二
|
欧美日日日日bbbbb视频
|
天天干天天爱天天
|
日韩日b视频
|
户外露出一区二区三区
|
中文字幕韩在线第一页
|
97免费视频在线观看
|
一区二区免费在线观看
|
国产农村妇女精品一二区
|
日日摸夜夜爽人人添av
|
不卡的av在线
|
亚洲国产精品精华素
|
人妖av
|