rodAndBarDetection code update: fix bugs for compile errors
This commit is contained in:
parent
5c42f164d3
commit
c69f28ca41
@ -184,8 +184,15 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HC_channelSpaceMeasure_test
|
|||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rodAndBarDetection_test", "rodAndBarDetection_test\rodAndBarDetection_test.vcxproj", "{59F9508A-4295-4A7D-858C-7B4F0A7F8C82}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rodAndBarDetection_test", "rodAndBarDetection_test\rodAndBarDetection_test.vcxproj", "{59F9508A-4295-4A7D-858C-7B4F0A7F8C82}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{95DC3F1A-902A-490E-BD3B-B10463CF0EBD} = {95DC3F1A-902A-490E-BD3B-B10463CF0EBD}
|
||||||
|
{AEC22DC1-FBE0-4D9C-B090-D4821A9D846B} = {AEC22DC1-FBE0-4D9C-B090-D4821A9D846B}
|
||||||
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rodAndBarDetection", "rodAndBarDetection\rodAndBarDetection.vcxproj", "{AEC22DC1-FBE0-4D9C-B090-D4821A9D846B}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rodAndBarDetection", "rodAndBarDetection\rodAndBarDetection.vcxproj", "{AEC22DC1-FBE0-4D9C-B090-D4821A9D846B}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{95DC3F1A-902A-490E-BD3B-B10463CF0EBD} = {95DC3F1A-902A-490E-BD3B-B10463CF0EBD}
|
||||||
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|||||||
@ -554,7 +554,7 @@ SG_APISHARED_EXPORT SSG_planeCalibPara sg_getPlaneCalibPara2_ROI(
|
|||||||
SVzNL3DRangeD roi);
|
SVzNL3DRangeD roi);
|
||||||
|
|
||||||
//根据两个向量计算旋转矩阵
|
//根据两个向量计算旋转矩阵
|
||||||
SG_APISHARED_EXPORT SSG_planeCalibPara wd_conputeRTMatrix(
|
SG_APISHARED_EXPORT SSG_planeCalibPara wd_computeRTMatrix(
|
||||||
SVzNL3DPoint& vector1,
|
SVzNL3DPoint& vector1,
|
||||||
SVzNL3DPoint& vector2);
|
SVzNL3DPoint& vector2);
|
||||||
|
|
||||||
|
|||||||
@ -2417,7 +2417,7 @@ SSG_planeCalibPara sg_HCameraVScan_getGroundCalibPara(
|
|||||||
return planePara;
|
return planePara;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSG_planeCalibPara wd_conputeRTMatrix(SVzNL3DPoint& vector1, SVzNL3DPoint& vector2)
|
SSG_planeCalibPara wd_computeRTMatrix(SVzNL3DPoint& vector1, SVzNL3DPoint& vector2)
|
||||||
{
|
{
|
||||||
Vector3 a = Vector3(vector1.x, vector1.y, vector1.z);
|
Vector3 a = Vector3(vector1.x, vector1.y, vector1.z);
|
||||||
Vector3 b = Vector3(vector2.x, vector2.y, vector2.z);
|
Vector3 b = Vector3(vector2.x, vector2.y, vector2.z);
|
||||||
@ -3107,9 +3107,12 @@ bool fitLine3DLeastSquares(const std::vector<SVzNL3DPoint>& points, SVzNL3DPoint
|
|||||||
center = { cx, cy, cz };
|
center = { cx, cy, cz };
|
||||||
|
|
||||||
// 2. 构造去中心化的协方差矩阵(3x3)
|
// 2. 构造去中心化的协方差矩阵(3x3)
|
||||||
Eigen::MatrixXd centered = A.rowwise() - Eigen::Vector3d(cx, cy, cz);
|
// 关键修复:使用RowVector3d(行向量)做rowwise减法,匹配维度
|
||||||
Eigen::Matrix3d cov = centered.transpose() * centered / (points.size() - 1);
|
Eigen::RowVector3d centroid_row(cx, cy, cz);
|
||||||
|
Eigen::MatrixXd centered = A.rowwise() - centroid_row; // 维度匹配,无报错
|
||||||
|
|
||||||
|
// 协方差矩阵计算(n-1为无偏估计,工程中也可直接用n)
|
||||||
|
Eigen::Matrix3d cov = centered.transpose() * centered / (points.size() - 1);
|
||||||
// 3. 特征值分解:求协方差矩阵的特征值和特征向量
|
// 3. 特征值分解:求协方差矩阵的特征值和特征向量
|
||||||
Eigen::SelfAdjointEigenSolver<Eigen::Matrix3d> eigensolver(cov);
|
Eigen::SelfAdjointEigenSolver<Eigen::Matrix3d> eigensolver(cov);
|
||||||
if (eigensolver.info() != Eigen::Success) {
|
if (eigensolver.info() != Eigen::Success) {
|
||||||
|
|||||||
@ -124,7 +124,6 @@ SVzNL3DPoint _ptRotate(SVzNL3DPoint pt3D, double matrix3d[9])
|
|||||||
int* errCode)
|
int* errCode)
|
||||||
{
|
{
|
||||||
*errCode = 0;
|
*errCode = 0;
|
||||||
SSX_hexHeadScrewInfo screwInfo;
|
|
||||||
memset(&screwInfo, 0, sizeof(SSX_hexHeadScrewInfo));
|
memset(&screwInfo, 0, sizeof(SSX_hexHeadScrewInfo));
|
||||||
int lineNum = (int)scanLines.size();
|
int lineNum = (int)scanLines.size();
|
||||||
if (lineNum == 0)
|
if (lineNum == 0)
|
||||||
@ -250,7 +249,7 @@ SVzNL3DPoint _ptRotate(SVzNL3DPoint pt3D, double matrix3d[9])
|
|||||||
//¼ÆËãÐýתÏòÁ¿
|
//¼ÆËãÐýתÏòÁ¿
|
||||||
SVzNL3DPoint vector1 = P1_dir;
|
SVzNL3DPoint vector1 = P1_dir;
|
||||||
SVzNL3DPoint vector2 = { 0, 0, -1.0 };
|
SVzNL3DPoint vector2 = { 0, 0, -1.0 };
|
||||||
SSG_planeCalibPara rotatePara = wd_conputeRTMatrix( vector1, vector2);
|
SSG_planeCalibPara rotatePara = wd_computeRTMatrix( vector1, vector2);
|
||||||
//
|
//
|
||||||
SSG_ROIRectD roi_xoy;
|
SSG_ROIRectD roi_xoy;
|
||||||
roi_xoy.left = P0_center.x - rodRidius * 4; //2D·¶Î§
|
roi_xoy.left = P0_center.x - rodRidius * 4; //2D·¶Î§
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user