Exemplo n.º 1
0
void Target::debug_draw_paths(cv::Mat &rgb, cv::Scalar &color, int n) const
{
    cv::Scalar path_color = color;
    for (int i = 0; i < (int)layers_[0].size() && i < n; i++) {
        PATH path = get_path(i);
        if (distance(path) > 5.0) {
            debug_draw_path(rgb, path, path_color);
        }
    }

    // 画第一层的外接,和最后一层的外接
    if (layers_.size() >= 2) {
        cv::rectangle(rgb, cv::boundingRect(layers_.front()), cv::Scalar(0, 0, 127));
        cv::rectangle(rgb, cv::boundingRect(layers_.back()), cv::Scalar(0, 128, 0));

        // 最后一层点,检查是否离散 ...
        std::vector<bool> status;
        const PTS &back = layers_.back();
#if 0
        if (check_alone_pts(back, status)) {
            for (size_t i = 0; i < back.size(); i++) {
                if (status[i]) {
                    cv::circle(rgb, back[i], 1, cv::Scalar(255, 32, 0));
                }
                else {
                    cv::circle(rgb, back[i], 1, cv::Scalar(0, 200, 200));
                }
            }
        }
#else
        std::vector<std::vector<cv::Point2f> > clusters;
        cluster_builder cb(40);
        cb.calc(back, clusters);
        std::sort(clusters.begin(), clusters.end(), op_more_pts);

        /// 仅仅画前三类 ...
        cv::Scalar colors[3] = { cv::Scalar(0, 200, 200), cv::Scalar(255, 64, 0), cv::Scalar(0, 255, 0) };
        for (int i = 0; i < (int)clusters.size() && i < 3; i++) {
            if (clusters[i].size() < 3)
                break;
            draw_pts(rgb, clusters[i], colors[i]);
            cv::rectangle(rgb, cv::boundingRect(clusters[i]), colors[i]);
        }

#endif //
    }

    char info[64];
    sprintf(info, "%d", id_);
    cv::putText(rgb, info, brc_.br(), cv::FONT_HERSHEY_COMPLEX_SMALL, 1.0, cv::Scalar(128, 255, 255));
    cv::rectangle(rgb, brc_, cv::Scalar(0, 255, 255));
}
Exemplo n.º 2
0
static void	oct_8(t_env *e, t_pts p1, t_pts p2)
{
	float	dx;
	float	dy;
	float	a;

	dx = p2.x_i - p1.x_i;
	dy = p2.y_i - p1.y_i;
	a = dx;
	dx *= 2;
	dy *= 2;
	while (1)
	{
		draw_pts(e, p1, p2);
		if (++p1.x_i == p2.x_i)
			break ;
		if ((a += dy) < 0)
		{
			p1.y_i--;
			a += dx;
		}
	}
}