|
@@ -1262,8 +1262,8 @@ void CTeaSort::calculate_stem_grab_position_opt(
|
|
|
//在指定方向的矩形框内,找到内部点最多的方向,作为主方向
|
|
|
double target_angle = ref_angle_init + i*step_angle;
|
|
|
cv::Point center_pt;
|
|
|
- center_pt.x = p5.x + static_cast<int>(radius * sin(target_angle));
|
|
|
- center_pt.y = p5.y + static_cast<int>(radius * cos(target_angle));
|
|
|
+ center_pt.x = p4.x + static_cast<int>(radius * sin(target_angle));
|
|
|
+ center_pt.y = p4.y + static_cast<int>(radius * cos(target_angle));
|
|
|
calc_bottom_vertex(center_pt, target_angle, delta_angle, radius, pt0, pt1);
|
|
|
calc_bottom_vertex(center_pt, target_angle + CV_PI, delta_angle, radius, pt2, pt3);
|
|
|
|
|
@@ -1317,7 +1317,7 @@ void CTeaSort::calculate_stem_grab_position_opt(
|
|
|
if (m_cp.image_show) {
|
|
|
cv::Mat bin_tmp = ske_img.clone();
|
|
|
|
|
|
- cv::circle(bin_tmp, p5, 4, cv::Scalar(156, 0, 255), 1, 3, 0);
|
|
|
+ cv::circle(bin_tmp, p4, 4, cv::Scalar(156, 0, 255), 1, 3, 0);
|
|
|
cv::circle(bin_tmp, pt0_opt, 4, cv::Scalar(156, 0, 255), 1, 3, 0);
|
|
|
cv::circle(bin_tmp, pt1_opt, 4, cv::Scalar(156, 0, 255), 1, 3, 0);
|
|
|
cv::circle(bin_tmp, pt2_opt, 4, cv::Scalar(156, 0, 255), 1, 3, 0);
|
|
@@ -1368,20 +1368,20 @@ void CTeaSort::calculate_stem_grab_position_opt(
|
|
|
}*/
|
|
|
|
|
|
|
|
|
- //遍历所有点,找到距离等于指定距离的点的位置, 以及距离p5最近的骨架上的点
|
|
|
+ //遍历所有点,找到距离等于指定距离的点的位置, 以及距离p4最近的骨架上的点
|
|
|
std::vector<cv::Point> candidate_pts;
|
|
|
- cv::Point p5_nearst;
|
|
|
+ cv::Point p4_nearst;
|
|
|
double dist_th = 5;
|
|
|
double dist_min = 1.0e6;
|
|
|
for (auto& pt : ske_pixels_opt) {
|
|
|
int c = int(pt.x);
|
|
|
int r = int(pt.y);
|
|
|
- double dist = std::powf((p5.x - c), 2) + std::powf((p5.y - r), 2);
|
|
|
+ double dist = std::powf((p4.x - c), 2) + std::powf((p4.y - r), 2);
|
|
|
dist = std::sqrtf(dist);
|
|
|
if (dist < dist_min) {
|
|
|
dist_min = dist;
|
|
|
- p5_nearst.x = c;
|
|
|
- p5_nearst.y = r;
|
|
|
+ p4_nearst.x = c;
|
|
|
+ p4_nearst.y = r;
|
|
|
}
|
|
|
if (std::fabs(dist - m_cp.offset_grab) < dist_th) {
|
|
|
candidate_pts.push_back(cv::Point(c, r));
|
|
@@ -1415,7 +1415,7 @@ void CTeaSort::calculate_stem_grab_position_opt(
|
|
|
for (auto&p : valid_candidate_pts) {
|
|
|
ske_img_tmp.at<unsigned char>(p) = 100;
|
|
|
}
|
|
|
- cv::circle(ske_img_tmp, p5, 4, cv::Scalar(255, 0, 255), 1, 3, 0);
|
|
|
+ cv::circle(ske_img_tmp, p4, 4, cv::Scalar(255, 0, 255), 1, 3, 0);
|
|
|
if (grab_x > 0 && grab_y > 0) {
|
|
|
cv::circle(ske_img_tmp, cv::Point(int(grab_x), int(grab_y)), 4, cv::Scalar(156, 0, 255), 1, 3, 0);
|
|
|
}
|
|
@@ -1429,7 +1429,7 @@ void CTeaSort::calculate_stem_grab_position_opt(
|
|
|
|
|
|
//重新得到grab_x,grab_y的坐标
|
|
|
if (grab_x > 0 && grab_y > 0) {
|
|
|
- int real_padding_y = p5.y - int(b.ppoint[9] - b.y1);
|
|
|
+ int real_padding_y = p4.y - int(b.ppoint[7] - b.y1);
|
|
|
grab_y -= real_padding_y;
|
|
|
grab_y += b.y1;
|
|
|
grab_x += b.x1;
|