更新smallApex算法
This commit is contained in:
@@ -118,14 +118,14 @@ static cv::Mat apexHalconAlgo(std::shared_ptr<detData>data, cv::Mat& src)
|
||||
AllBaseRects.push_back(rectAndResult(rect,false));
|
||||
}
|
||||
|
||||
for (int i = 0; i < hv_out_OK_PingsSize / 4; i++)
|
||||
for (int i = 0; i < hv_out_PingsSize / 4; i++)
|
||||
{
|
||||
cv::Rect rect(
|
||||
hv_out_OK_Pings[i * 4].D(),
|
||||
hv_out_OK_Pings[i * 4 + 1].D(),
|
||||
hv_out_OK_Pings[i * 4 + 2].D(),
|
||||
hv_out_OK_Pings[i * 4 + 3].D());
|
||||
okPos.push_back(rect);
|
||||
hv_out_Pings[i * 4].D(),
|
||||
hv_out_Pings[i * 4 + 1].D(),
|
||||
hv_out_Pings[i * 4 + 2].D(),
|
||||
hv_out_Pings[i * 4 + 3].D());
|
||||
//okPos.push_back(rect);
|
||||
AllPoints.push_back(rect);
|
||||
}
|
||||
std::vector<startAndEndPoints>xLines;
|
||||
|
||||
@@ -1,14 +1,138 @@
|
||||
#include <detData.h>
|
||||
#include <handleAiModel.h>
|
||||
#include <Inspenction_apex.hpp>
|
||||
#include <Inspection_apexSmall.hpp>
|
||||
#include <simpleAlgo.h>
|
||||
//输入det切出的连接器图片
|
||||
static void apexSmallHalconPaint(cv::Mat& out, std::vector<startAndEndPoints>xLines, const std::vector<cv::Rect>& AllPinsPos, const std::vector<rectAndResult>& AllPos, double& maxRange)
|
||||
{
|
||||
std::vector<std::vector<rectAndResult>> groupedRectangles = groupRectanglesByX(AllPos, 40);//编组
|
||||
for (auto& vec : groupedRectangles)//排序
|
||||
sortRectanglesByY(vec);
|
||||
std::vector<std::vector<cv::Rect>> PinGroupedRectangles = groupRectanglesByX(AllPinsPos, 40);//编组
|
||||
for (auto& vec : PinGroupedRectangles)//排序
|
||||
sortRectanglesByY(vec);
|
||||
std::sort(xLines.begin(), xLines.end(), compareByStartX);
|
||||
for (auto& linex : xLines)//画竖线
|
||||
{
|
||||
cv::line(out,
|
||||
cv::Point(linex.start.x, linex.start.y),
|
||||
cv::Point(linex.end.x, linex.end.y),
|
||||
cv::Scalar(0, 255, 0), 3);
|
||||
}
|
||||
|
||||
for (int i = 0; i < xLines.size(); i++)
|
||||
{
|
||||
if (groupedRectangles.size() > i)
|
||||
for (auto& rectIn : groupedRectangles[i])
|
||||
{
|
||||
cv::Point mid(rectIn.rect.x, rectIn.rect.y);
|
||||
double range = pointToLineDistance(mid, xLines[i].start, xLines[i].end) * pixACC;
|
||||
maxRange = max(maxRange, range);
|
||||
cv::Rect rect(rectIn.rect.x - rectIn.rect.width / 2, rectIn.rect.y - rectIn.rect.height / 2, rectIn.rect.width, rectIn.rect.height);
|
||||
cv::Scalar scolor;
|
||||
if (rectIn.isOK == false)
|
||||
scolor = cv::Scalar(0, 0, 255);
|
||||
else
|
||||
scolor = cv::Scalar(0, 255, 0);
|
||||
cv::rectangle(out, rect, scolor, 5); //画pin针
|
||||
//cv::putText(out,
|
||||
// std::to_string(range),
|
||||
// cv::Point(mid.x, mid.y - 5), 4, 1,
|
||||
// scolor);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < xLines.size(); i++)
|
||||
{
|
||||
if (PinGroupedRectangles.size() > i)
|
||||
for (auto& rectIn : PinGroupedRectangles[i])
|
||||
{
|
||||
cv::Point mid(rectIn.x, rectIn.y);
|
||||
double range = pointToLineDistance(mid, xLines[i].start, xLines[i].end) * pixACC;
|
||||
maxRange = max(maxRange, range);
|
||||
cv::Rect rect(rectIn.x - rectIn.width / 2, rectIn.y - rectIn.height / 2, rectIn.width, rectIn.height);
|
||||
cv::Scalar scolor = cv::Scalar(0, 255, 0);
|
||||
cv::rectangle(out, rect, scolor, 3); //画pin针
|
||||
cv::putText(out,
|
||||
std::to_string(range),
|
||||
cv::Point(mid.x, mid.y - 5), 4, 1,
|
||||
scolor);
|
||||
}
|
||||
}
|
||||
}
|
||||
static cv::Mat apexSmallHalconAlgo(std::shared_ptr<detData>data, cv::Mat& src)
|
||||
{
|
||||
data->segOriginImgs.push_back(src);
|
||||
return src;
|
||||
}
|
||||
cv::Mat halconImg;
|
||||
src(cv::Rect(50, 50, src.cols - 100, src.rows - 150)).copyTo(halconImg);
|
||||
HTuple hv_out_OK_Pings;
|
||||
HTuple hv_out_NG_Pings;
|
||||
HTuple hv_out_Flag_INS;
|
||||
HTuple hv_out_Line;
|
||||
HTuple hv_pin_number;
|
||||
HTuple hv_out_Pings;
|
||||
HObject ho_in_Image = MatToHObject(halconImg);
|
||||
cv::Mat r = HObject2Mat(ho_in_Image);
|
||||
sk2_APEXSMALL_Pin(ho_in_Image, &hv_out_OK_Pings, &hv_out_NG_Pings,
|
||||
&hv_out_Line, &hv_pin_number, &hv_out_Pings, &hv_out_Flag_INS);
|
||||
int flag = hv_out_Flag_INS.D();
|
||||
if (halconImg.channels() == 1)
|
||||
cv::cvtColor(halconImg, halconImg, cv::COLOR_GRAY2BGR);
|
||||
int hv_out_OK_PingsSize = hv_out_OK_Pings.Length(),
|
||||
hv_out_NG_PingsSize = hv_out_NG_Pings.Length();
|
||||
int lineSize = hv_out_Line.Length();
|
||||
int hv_out_PingsSize = hv_out_Pings.Length();
|
||||
int hv_pin_numberSize = hv_pin_number.Length();
|
||||
std::cout << "OKSize" << hv_out_OK_PingsSize << "NGSize" << hv_out_NG_PingsSize << std::endl;
|
||||
std::vector<rectAndResult> AllBaseRects;
|
||||
std::vector<cv::Rect> AllPoints;
|
||||
std::vector<cv::Rect>okPos;
|
||||
for (int i = 0; i < hv_out_OK_PingsSize / 4; i++)
|
||||
{
|
||||
cv::Rect rect(
|
||||
hv_out_OK_Pings[i * 4].D(),
|
||||
hv_out_OK_Pings[i * 4 + 1].D(),
|
||||
hv_out_OK_Pings[i * 4 + 2].D(),
|
||||
hv_out_OK_Pings[i * 4 + 3].D());
|
||||
okPos.push_back(rect);
|
||||
AllBaseRects.push_back(rectAndResult(rect, true));
|
||||
}
|
||||
std::vector<cv::Rect>ngPos;
|
||||
for (int i = 0; i < hv_out_NG_PingsSize / 4; i++)
|
||||
{
|
||||
cv::Rect rect(
|
||||
hv_out_NG_Pings[i * 4].D(),
|
||||
hv_out_NG_Pings[i * 4 + 1].D(),
|
||||
hv_out_NG_Pings[i * 4 + 2].D(),
|
||||
hv_out_NG_Pings[i * 4 + 3].D());
|
||||
ngPos.push_back(rect);
|
||||
AllBaseRects.push_back(rectAndResult(rect, false));
|
||||
}
|
||||
|
||||
for (int i = 0; i < hv_out_PingsSize / 4; i++)
|
||||
{
|
||||
cv::Rect rect(
|
||||
hv_out_Pings[i * 4].D(),
|
||||
hv_out_Pings[i * 4 + 1].D(),
|
||||
hv_out_Pings[i * 4 + 2].D(),
|
||||
hv_out_Pings[i * 4 + 3].D());
|
||||
//okPos.push_back(rect);
|
||||
AllPoints.push_back(rect);
|
||||
}
|
||||
std::vector<startAndEndPoints>xLines;
|
||||
for (int i = 0; i < lineSize / 4; i++)
|
||||
{
|
||||
startAndEndPoints p;
|
||||
p.start.x = hv_out_Line[i * 4 + 1].D();
|
||||
p.start.y = hv_out_Line[i * 4].D();
|
||||
p.end.x = hv_out_Line[i * 4 + 3].D();
|
||||
p.end.y = hv_out_Line[i * 4 + 2].D();
|
||||
xLines.push_back(p);
|
||||
}
|
||||
//画线
|
||||
double maxRange = 0;
|
||||
apexSmallHalconPaint(halconImg, xLines, AllPoints, AllBaseRects, maxRange);
|
||||
data->maxPinDetValue = maxRange;
|
||||
return halconImg;
|
||||
}
|
||||
|
||||
//输入det切出的连接器图片
|
||||
static cv::Mat apexSmallHandleAiAlgo(std::shared_ptr<detData>data, cv::Mat& src, handleAiModelManager* _handleAiModelManager)
|
||||
|
||||
@@ -2,104 +2,122 @@
|
||||
#include <Eigen/Dense>
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
Eigen::Vector3d convertToEigenVector(const Eigen::Matrix<double, 3, 1>& mat) {
|
||||
return Eigen::Vector3d(mat(0), mat(1), mat(2));
|
||||
Eigen::Vector3d calculateCentroid(const Eigen::Vector3d& P1, const Eigen::Vector3d& P2, const Eigen::Vector3d& P3) {
|
||||
return (P1 + P2 + P3) / 3.0;
|
||||
}
|
||||
Eigen::Vector3d calculateTranslation(const Eigen::Vector3d& A1, const Eigen::Vector3d& A2, const Eigen::Vector3d& A3,
|
||||
const Eigen::Vector3d& B1, const Eigen::Vector3d& B2, const Eigen::Vector3d& B3) {
|
||||
Eigen::Vector3d centroidA = calculateCentroid(A1, A2, A3);
|
||||
Eigen::Vector3d centroidB = calculateCentroid(B1, B2, B3);
|
||||
return centroidB - centroidA;
|
||||
}
|
||||
Eigen::Matrix3d calculateRotationMatrix(const Eigen::Vector3d& A1, const Eigen::Vector3d& A2, const Eigen::Vector3d& A3,
|
||||
const Eigen::Vector3d& B1, const Eigen::Vector3d& B2, const Eigen::Vector3d& B3) {
|
||||
// 定义物体 A 的局部坐标系
|
||||
Eigen::Vector3d v1_A = (A2 - A1).normalized();
|
||||
Eigen::Vector3d v2_A = (A3 - A1).normalized();
|
||||
Eigen::Vector3d v3_A = v1_A.cross(v2_A).normalized();
|
||||
Eigen::Matrix3d RA;
|
||||
RA.col(0) = v1_A;
|
||||
RA.col(1) = v3_A.cross(v1_A).normalized();
|
||||
RA.col(2) = v3_A;
|
||||
|
||||
// 定义物体 B 的局部坐标系
|
||||
Eigen::Vector3d v1_B = (B2 - B1).normalized();
|
||||
Eigen::Vector3d v2_B = (B3 - B1).normalized();
|
||||
Eigen::Vector3d v3_B = v1_B.cross(v2_B).normalized();
|
||||
Eigen::Matrix3d RB;
|
||||
RB.col(0) = v1_B;
|
||||
RB.col(1) = v3_B.cross(v1_B).normalized();
|
||||
RB.col(2) = v3_B;
|
||||
|
||||
// 计算旋转矩阵
|
||||
Eigen::Matrix3d R_AB = RB * RA.transpose();
|
||||
return R_AB;
|
||||
}
|
||||
|
||||
// Function to compute the affine transformation using Eigen
|
||||
Eigen::Matrix<double, 4, 4> computeAffine3D(
|
||||
const std::vector<Eigen::Vector3d>& src,
|
||||
const std::vector<Eigen::Vector3d>& dst)
|
||||
{
|
||||
Eigen::Matrix<double, 4, 4> affine = Eigen::Matrix<double, 4, 4>::Identity();
|
||||
|
||||
// Prepare the matrices
|
||||
Eigen::Matrix<double, 3, 3> A;
|
||||
Eigen::Matrix<double, 3, 1> b;
|
||||
Eigen::Matrix<double, 3, 1> x;
|
||||
|
||||
// Calculate the centroid of source and destination points
|
||||
Eigen::Vector3d src_mean = Eigen::Vector3d::Zero();
|
||||
Eigen::Vector3d dst_mean = Eigen::Vector3d::Zero();
|
||||
for (size_t i = 0; i < src.size(); ++i) {
|
||||
src_mean += src[i];
|
||||
dst_mean += dst[i];
|
||||
}
|
||||
src_mean /= src.size();
|
||||
dst_mean /= dst.size();
|
||||
|
||||
// Compute the centered matrices
|
||||
Eigen::Matrix<double, 3, Eigen::Dynamic> src_centered(3, src.size());
|
||||
Eigen::Matrix<double, 3, Eigen::Dynamic> dst_centered(3, dst.size());
|
||||
for (size_t i = 0; i < src.size(); ++i) {
|
||||
src_centered.col(i) = src[i] - src_mean;
|
||||
dst_centered.col(i) = dst[i] - dst_mean;
|
||||
}
|
||||
|
||||
// Compute the covariance matrix and SVD
|
||||
Eigen::Matrix<double, 3, 3> H = dst_centered * src_centered.transpose();
|
||||
Eigen::JacobiSVD<Eigen::Matrix<double, 3, 3>> svd(H, Eigen::ComputeFullU | Eigen::ComputeFullV);
|
||||
Eigen::Matrix<double, 3, 3> R = svd.matrixV() * svd.matrixU().transpose();
|
||||
Eigen::Matrix<double, 3, 1> t = dst_mean - R * src_mean;
|
||||
|
||||
affine.block<3, 3>(0, 0) = R;
|
||||
affine.block<3, 1>(0, 3) = t;
|
||||
|
||||
return affine;
|
||||
Eigen::Vector3d calculateEulerAngles(const Eigen::Matrix3d& R) {
|
||||
return R.eulerAngles(0, 1, 2); // 返回绕 X, Y, Z 轴的欧拉角(Yaw-Pitch-Roll)
|
||||
}
|
||||
int oevaluate()
|
||||
Eigen::Vector3d calculateCentroid(const std::vector<Eigen::Vector3d>& points) {
|
||||
Eigen::Vector3d centroid(0, 0, 0);
|
||||
for (const auto& point : points) {
|
||||
centroid += point;
|
||||
}
|
||||
centroid /= points.size();
|
||||
return centroid;
|
||||
}
|
||||
Eigen::Matrix3d calculateRotationMatrixSVD(const std::vector<Eigen::Vector3d>& A_points, const std::vector<Eigen::Vector3d>& B_points) {
|
||||
Eigen::Matrix3d H = Eigen::Matrix3d::Zero();
|
||||
for (size_t i = 0; i < A_points.size(); ++i) {
|
||||
H += (B_points[i] - calculateCentroid(B_points)) * (A_points[i] - calculateCentroid(A_points)).transpose();
|
||||
}
|
||||
Eigen::JacobiSVD<Eigen::MatrixXd> svd(H, Eigen::ComputeFullU | Eigen::ComputeFullV);
|
||||
Eigen::Matrix3d R = svd.matrixV() * svd.matrixU().transpose();
|
||||
return R;
|
||||
}
|
||||
|
||||
//std::vector<Eigen::Vector3d> P1 = {
|
||||
// Eigen::Vector3d(453.64, -1373.59, -203.9841), // -130.33 - 73.6541
|
||||
// Eigen::Vector3d(462.86, -1228.2 , -206.8113), // -130.42 - 76.3913
|
||||
// Eigen::Vector3d(723.69, -1228.2 , -206.3582), // -130.43 - 75.9282
|
||||
// Eigen::Vector3d(755.77, -447.5516, -967.41), // -385.56 - 61.9916
|
||||
// Eigen::Vector3d(756.7 , -447.9429, -999.2), // -385.56 - 62.3829
|
||||
// Eigen::Vector3d(347.92, -450.0665, -1000.87), // -385.48 - 64.5865
|
||||
// Eigen::Vector3d(-120.6791, -1024.55, -599.13), // -132.24 + 11.5609
|
||||
// Eigen::Vector3d(-120.9298, -1024.53, -680.57), // -132.24 + 11.3102
|
||||
// Eigen::Vector3d(-121.3208, -1098.14, -680.15) // -132.28 + 10.9592
|
||||
//};
|
||||
|
||||
//std::vector<Eigen::Vector3d> P1 = {
|
||||
// Eigen::Vector3d(453.65, -1373.59, -203.9069), // -130.33 - 73.5769
|
||||
// Eigen::Vector3d(462.86, -1228.2 , -206.8159), // -130.42 - 76.3959
|
||||
// Eigen::Vector3d(723.65, -1228.18, -206.21), // -130.4 - 75.81
|
||||
// Eigen::Vector3d(755.82, -481.713, -967.43), // -385.57 - 96.143
|
||||
// Eigen::Vector3d(756.2 , -481.9407, -1000.99), // -385.56 - 96.3807
|
||||
// Eigen::Vector3d(347.96, -484.8419, -1000.87), // -385.48 - 99.3619
|
||||
// Eigen::Vector3d(-120.3304, -1024.55, -599.13), // -132.24 + 11.9096
|
||||
// Eigen::Vector3d(-120.3962, -1024.52, -680.58), // -132.24 + 11.8438
|
||||
// Eigen::Vector3d(-121.0291, -1098.13, -680.17) // -132.27 + 11.2409
|
||||
//};
|
||||
|
||||
void oneArea()//:)
|
||||
{
|
||||
// Define 3D points for Cube 1
|
||||
std::vector<Eigen::Vector3d> P1 = {
|
||||
Eigen::Vector3d(453.64, -1373.59, -203.9841), // -130.33 - 73.6541
|
||||
Eigen::Vector3d(462.86, -1228.2 , -206.8113), // -130.42 - 76.3913
|
||||
Eigen::Vector3d(723.69, -1228.2 , -206.3582), // -130.43 - 75.9282
|
||||
Eigen::Vector3d(755.77, -447.5516, -967.41), // -385.56 - 61.9916
|
||||
Eigen::Vector3d(756.7 , -447.9429, -999.2), // -385.56 - 62.3829
|
||||
Eigen::Vector3d(347.92, -450.0665, -1000.87), // -385.48 - 64.5865
|
||||
Eigen::Vector3d(-120.6791, -1024.55, -599.13), // -132.24 + 11.5609
|
||||
Eigen::Vector3d(-120.9298, -1024.53, -680.57), // -132.24 + 11.3102
|
||||
Eigen::Vector3d(-121.3208, -1098.14, -680.15) // -132.28 + 10.9592
|
||||
Eigen::Vector3d A1(755.77, -447.5516, -967.41), A2(756.7, -447.9429, -999.2), A3(347.92, -450.0665, -1000.87);
|
||||
Eigen::Vector3d B1(755.82, -481.713, -967.43), B2(756.2, -481.9407, -1000.99), B3(347.96, -484.8419, -1000.87);
|
||||
|
||||
// 计算偏移量
|
||||
Eigen::Vector3d translation = calculateTranslation(A1, A2, A3, B1, B2, B3);
|
||||
std::cout << "Translation: \n" << translation << std::endl;
|
||||
|
||||
Eigen::Matrix3d rotationMatrix = calculateRotationMatrix(A1, A2, A3, B1, B2, B3);
|
||||
Eigen::Vector3d eulerAngles = calculateEulerAngles(rotationMatrix);
|
||||
std::cout << "Euler Angles (Yaw, Pitch, Roll): \n" << eulerAngles << std::endl;
|
||||
}
|
||||
void threeArea()//:(
|
||||
{
|
||||
std::vector<Eigen::Vector3d> A_points = {
|
||||
{453.64, -1373.59, -203.9841}, {462.86, -1228.2 , -206.8113}, {723.69, -1228.2 , -206.3582}, // 面 1
|
||||
{755.77, -447.5516, -967.41}, {756.7 , -447.9429, -999.2}, {347.92, -450.0665, -1000.87}, // 面 2
|
||||
{-120.6791, -1024.55, -599.13}, {-120.9298, -1024.53, -680.57}, {-121.3208, -1098.14, -680.15} // 面 3
|
||||
};
|
||||
|
||||
|
||||
// Define 3D points for Cube 2
|
||||
std::vector<Eigen::Vector3d> P2 = {
|
||||
Eigen::Vector3d(453.64, -1373.59, -203.9841), // -130.33 - 73.6541
|
||||
Eigen::Vector3d(462.86, -1228.2 , -206.8113), // -130.42 - 76.3913
|
||||
Eigen::Vector3d(723.69, -1228.2 , -206.3582), // -130.43 - 75.9282
|
||||
Eigen::Vector3d(755.77, -447.5516, -967.41), // -385.56 - 61.9916
|
||||
Eigen::Vector3d(756.7 , -447.9429, -999.2), // -385.56 - 62.3829
|
||||
Eigen::Vector3d(347.92, -450.0665, -1000.87), // -385.48 - 64.5865
|
||||
Eigen::Vector3d(-120.6791, -1024.55, -599.13), // -132.24 + 11.5609
|
||||
Eigen::Vector3d(-120.9298, -1024.53, -680.57), // -132.24 + 11.3102
|
||||
Eigen::Vector3d(-121.3208, -1098.14, -680.15) // -132.28 + 10.9592
|
||||
std::vector<Eigen::Vector3d> B_points = {
|
||||
{453.65, -1373.59, -203.9069}, {462.86, -1228.2 , -206.8159}, {347.96, -484.8419, -1000.87}, // 面 1
|
||||
{755.82, -481.713, -967.43}, {756.2 , -481.9407, -1000.99}, {347.92, -450.0665, -1000.8}, // 面 2
|
||||
{-120.3304, -1024.55, -599.13}, {-120.3962, -1024.52, -680.58}, {-121.0291, -1098.13, -680.17} // 面 3
|
||||
};
|
||||
|
||||
// 计算质心(用于计算平移量)
|
||||
Eigen::Vector3d centroidA = calculateCentroid(A_points);
|
||||
Eigen::Vector3d centroidB = calculateCentroid(B_points);
|
||||
Eigen::Vector3d translation = centroidB - centroidA;
|
||||
std::cout << "Translation: \n" << translation << std::endl;
|
||||
|
||||
// Compute the affine transformation matrix
|
||||
Eigen::Matrix<double, 4, 4> affine = computeAffine3D(P1, P2);
|
||||
// 计算旋转矩阵和欧拉角
|
||||
Eigen::Matrix3d R_AB = calculateRotationMatrixSVD(A_points, B_points);
|
||||
Eigen::Vector3d eulerAngles = calculateEulerAngles(R_AB);
|
||||
std::cout << "Euler Angles (Yaw, Pitch, Roll): \n" << eulerAngles << std::endl;
|
||||
|
||||
// Extract translation vector and rotation matrix
|
||||
Eigen::Matrix<double, 3, 3> R = affine.block<3, 3>(0, 0);
|
||||
Eigen::Vector3d t = affine.block<3, 1>(0, 3);
|
||||
|
||||
// Print affine transformation matrix
|
||||
std::cout << "Affine Transformation Matrix:" << std::endl;
|
||||
std::cout << affine << std::endl;
|
||||
|
||||
// Print translation vector
|
||||
std::cout << "Translation: (" << t[0] << ", " << t[1] << ", " << t[2] << ")" << std::endl;
|
||||
|
||||
// Convert rotation matrix to Euler angles
|
||||
Eigen::Vector3d euler_angles = R.eulerAngles(0, 1, 2);
|
||||
std::cout << "Rotation (Euler Angles): (" << euler_angles[0] << ", " << euler_angles[1] << ", " << euler_angles[2] << ")" << std::endl;
|
||||
double x = 687.376 + t[0];
|
||||
double y = -147.500 + t[1];
|
||||
double z = 328.880 + t[2];
|
||||
double rx = -90 + euler_angles[0] * 180.0 / 3.1415926;
|
||||
double ry = euler_angles[1] * 180.0 / 3.1415926;
|
||||
double rz = -90.000 + euler_angles[2] * 180.0 / 3.1415926;
|
||||
return 0;
|
||||
}
|
||||
#pragma once
|
||||
@@ -4,18 +4,18 @@
|
||||
using namespace HalconCpp;
|
||||
|
||||
// Procedure declarations
|
||||
void Get_Pin_Region(HObject ho_in_Image, HObject ho_in_PinRegion, HObject ho_in_HpinRegion,
|
||||
void Get_APEXSMALLPin_Region(HObject ho_in_Image, HObject ho_in_PinRegion, HObject ho_in_HpinRegion,
|
||||
HObject* ho_out_Pin_Region, HObject* ho_out_PincenterLine, HTuple hv_in_BaseLenth,
|
||||
HTuple hv_in_Seledge, HTuple hv_in_expand, HTuple* hv_out_Flag, HTuple* hv_out_Ngtails);
|
||||
void Get_Rectangle2_Corner(HObject ho_Rectangle, HTuple* hv_out_Row, HTuple* hv_out_Col);
|
||||
void sk2_ASR_Pin(HObject ho_Image, HTuple* hv_Out_Line, HTuple* hv_Out_ok_pin, HTuple* hv_Out_Ng_pin,
|
||||
void Get_APEXSMALLRectangle2_Corner(HObject ho_Rectangle, HTuple* hv_out_Row, HTuple* hv_out_Col);
|
||||
void sk2_APEXSMALL_Pin(HObject ho_Image, HTuple* hv_Out_Line, HTuple* hv_Out_ok_pin, HTuple* hv_Out_Ng_pin,
|
||||
HTuple* hv_Out_Pins, HTuple* hv_Out_number, HTuple* hv_Make);
|
||||
void sk2_Get_region(HObject ho_Image, HObject* ho_Out_region1, HObject* ho_Out_region2,
|
||||
HTuple* hv_Make);
|
||||
void sk2_Pin_Detect(HObject ho_Image, HObject ho_region, HObject* ho_Out_Line_region,
|
||||
void sk2_APEXSMALLPin_Detect(HObject ho_Image, HObject ho_region, HObject* ho_Out_Line_region,
|
||||
HObject* ho_Out_Pin_region, HTuple* hv_Make);
|
||||
// Procedures
|
||||
void Get_Pin_Region(HObject ho_in_Image, HObject ho_in_PinRegion, HObject ho_in_HpinRegion,
|
||||
void Get_APEXSMALLPin_Region(HObject ho_in_Image, HObject ho_in_PinRegion, HObject ho_in_HpinRegion,
|
||||
HObject* ho_out_Pin_Region, HObject* ho_out_PincenterLine, HTuple hv_in_BaseLenth,
|
||||
HTuple hv_in_Seledge, HTuple hv_in_expand, HTuple* hv_out_Flag, HTuple* hv_out_Ngtails)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ void Get_Pin_Region(HObject ho_in_Image, HObject ho_in_PinRegion, HObject ho_in_
|
||||
&hv_Length21);
|
||||
GenRectangle2(&ho_Rectangle1, hv_Row1, hv_Column1, hv_Phi1, hv_Length11 + 50, hv_Length21 + 40);
|
||||
|
||||
Get_Rectangle2_Corner(ho_Rectangle1, &hv_out_Row, &hv_out_Col);
|
||||
Get_APEXSMALLRectangle2_Corner(ho_Rectangle1, &hv_out_Row, &hv_out_Col);
|
||||
LineOrientation(HTuple(hv_out_Row[2]), HTuple(hv_out_Col[2]), HTuple(hv_out_Row[3]),
|
||||
HTuple(hv_out_Col[3]), &hv_Phi);
|
||||
hv_Point_Row = HTuple();
|
||||
@@ -283,7 +283,7 @@ void Get_Pin_Region(HObject ho_in_Image, HObject ho_in_PinRegion, HObject ho_in_
|
||||
return;
|
||||
}
|
||||
|
||||
void Get_Rectangle2_Corner(HObject ho_Rectangle, HTuple* hv_out_Row, HTuple* hv_out_Col)
|
||||
void Get_APEXSMALLRectangle2_Corner(HObject ho_Rectangle, HTuple* hv_out_Row, HTuple* hv_out_Col)
|
||||
{
|
||||
|
||||
// Local iconic variables
|
||||
@@ -295,7 +295,7 @@ void Get_Rectangle2_Corner(HObject ho_Rectangle, HTuple* hv_out_Row, HTuple* hv_
|
||||
HTuple hv_rowSortIndex, hv_Exception;
|
||||
|
||||
//**********************************************************************
|
||||
//Function Name: Get_Rectangle2_Corner
|
||||
//Function Name: Get_APEXSMALLRectangle2_Corner
|
||||
//Author: ������
|
||||
//Description: ��ȡ��������Ķ�������,(4����)
|
||||
//Input:
|
||||
@@ -431,7 +431,7 @@ void sk2_Get_region(HObject ho_Image, HObject* ho_Out_region1, HObject* ho_Out_r
|
||||
return;
|
||||
}
|
||||
|
||||
void sk2_Pin_Detect(HObject ho_Image, HObject ho_region, HObject* ho_Out_Line_region,
|
||||
void sk2_APEXSMALLPin_Detect(HObject ho_Image, HObject ho_region, HObject* ho_Out_Line_region,
|
||||
HObject* ho_Out_Pin_region, HTuple* hv_Make)
|
||||
{
|
||||
|
||||
@@ -503,7 +503,7 @@ void sk2_Pin_Detect(HObject ho_Image, HObject ho_region, HObject* ho_Out_Line_re
|
||||
5000);
|
||||
|
||||
SelectShape(ho_SelectedRegions2, &ho_SelectedRegions8, "ratio", "and", 0, 78.543);
|
||||
Get_Pin_Region(ho_Image, ho_ImageReduced2, ho_SelectedRegions8, &ho_out_Pin_Region,
|
||||
Get_APEXSMALLPin_Region(ho_Image, ho_ImageReduced2, ho_SelectedRegions8, &ho_out_Pin_Region,
|
||||
&ho_out_PincenterLine, 2, 2, 11, &hv_out_Flag, &hv_out_Ngtails);
|
||||
|
||||
//��ȡ��������
|
||||
@@ -541,7 +541,7 @@ void sk2_Pin_Detect(HObject ho_Image, HObject ho_region, HObject* ho_Out_Line_re
|
||||
|
||||
SelectShape(ho_ConnectedRegions2, &ho_SelectedRegions1, "height", "and", 10.1,
|
||||
100);
|
||||
Get_Pin_Region(ho_Image, ho_ImageReduced4, ho_SelectedRegions1, &ho_out_Pin_Region1,
|
||||
Get_APEXSMALLPin_Region(ho_Image, ho_ImageReduced4, ho_SelectedRegions1, &ho_out_Pin_Region1,
|
||||
&ho_out_PincenterLine1, 2, 1, 23, &hv_out_Flag1, &hv_out_Ngtails1);
|
||||
|
||||
CountObj(ho_out_Pin_Region, &hv_Number);
|
||||
@@ -572,7 +572,7 @@ void sk2_Pin_Detect(HObject ho_Image, HObject ho_region, HObject* ho_Out_Line_re
|
||||
return;
|
||||
}
|
||||
|
||||
void sk2_ASR_Pin(HObject ho_Image, HTuple* hv_Out_Line, HTuple* hv_Out_ok_pin, HTuple* hv_Out_Ng_pin,
|
||||
void sk2_APEXSMALL_Pin(HObject ho_Image, HTuple* hv_Out_Line, HTuple* hv_Out_ok_pin, HTuple* hv_Out_Ng_pin,
|
||||
HTuple* hv_Out_Pins, HTuple* hv_Out_number, HTuple* hv_Make)
|
||||
{
|
||||
|
||||
@@ -612,10 +612,10 @@ void sk2_ASR_Pin(HObject ho_Image, HTuple* hv_Out_Line, HTuple* hv_Out_ok_pin, H
|
||||
sk2_Get_region(ho_Image, &ho_Out_region1, &ho_Out_region2, &hv_Make3);
|
||||
if (0 != (int(hv_Make3 == 1)))
|
||||
{
|
||||
sk2_Pin_Detect(ho_Image, ho_Out_region1, &ho_Out_Line_region, &ho_Out_Pin_region,
|
||||
sk2_APEXSMALLPin_Detect(ho_Image, ho_Out_region1, &ho_Out_Line_region, &ho_Out_Pin_region,
|
||||
&hv_Make1);
|
||||
|
||||
sk2_Pin_Detect(ho_Image, ho_Out_region2, &ho_Out_Line_region1, &ho_Out_Pin_region1,
|
||||
sk2_APEXSMALLPin_Detect(ho_Image, ho_Out_region2, &ho_Out_Line_region1, &ho_Out_Pin_region1,
|
||||
&hv_Make2);
|
||||
|
||||
if (0 != (HTuple(int(hv_Make1 == 1)).TupleAnd(int(hv_Make2 == 1))))
|
||||
|
||||
@@ -149,7 +149,6 @@ void connectSignalAndSlots(MainWindow* front, appCore* _core, detProcess* _detPr
|
||||
appCore _core;
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
oevaluate();
|
||||
if (!isRunAsAdmin())
|
||||
{
|
||||
restartAsAdmin();
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user