当前位置: 首页>>代码示例>>C++>>正文


C++ Maze::draw_path方法代码示例

本文整理汇总了C++中Maze::draw_path方法的典型用法代码示例。如果您正苦于以下问题:C++ Maze::draw_path方法的具体用法?C++ Maze::draw_path怎么用?C++ Maze::draw_path使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Maze的用法示例。


在下文中一共展示了Maze::draw_path方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........
    const double rotation_speed = 0.3;

    double new_v_y, new_v_x;

    Point2f vehicle, end;

    preprocess(thresh_maze, color_maze, 500);

    // processing.get_point(color_maze, end, c3, 15, c1, c2);
    end = Point2f(20, 20);

    // DEMO
    if (!processing.get_triangle(color_maze, vehicle_angle, vehicle))
    {
        cout << "NO TRIANGLE" << endl;
        vehicle = Point2f(300, 300);
        imwrite("webcam.png", color_maze);
    }
    else
    {
        cout << "position " << vehicle << endl;
    }

    circle(color_maze, end, 10, Scalar(0, 0, 255));

    cout << "Destination: " << end << " start: " << vehicle << endl;

    imwrite("webcam.png", color_maze);

    cout << "Performing search" << endl;
    solver.depth_first_search(color_maze, thresh_maze, end.x, end.y);

    cout << "Drawing path" << endl;
    solver.draw_path(color_maze, vehicle.x, vehicle.y);
    imwrite("path.png", color_maze);

    cout << "Starting cycle" << endl;

    for (int step = 0; step < 500; step++)
    {
        Mat current_frame = color_maze.clone();

        // cap >> position_maze;

        // if (!processing.get_triangle(position_maze, vehicle_angle, vehicle))
        // {
        // 	cout << "Could not find triangle" << endl;
        // }

        Vec2f next_step_vector = solver.next_step(vehicle.x, vehicle.y, 5);

        if (next_step_vector == Vec2f())
        {
            cout << "Found exit!" << endl;
            break;
        }

        // Obtain the angle between the two vectors
        // double angle =
        // 	atan2(next_step_vector[1], next_step_vector[0]) -
        // 	atan2(vehicle_angle[1], vehicle_angle[0]);

        line(current_frame, vehicle, vehicle + Point2f((next_step_vector * 10)[0], (next_step_vector * 10)[1]), Scalar(0, 0, 255), 2);
        line(current_frame, vehicle, vehicle + Point2f((vehicle_angle * 20)[0], (vehicle_angle * 20)[1]), Scalar(255, 0, 0), 2);
        circle(current_frame, vehicle, 3, Scalar(0, 255, 255));
        // color_maze.at<Vec3b>(next_destination.second, next_destination.first) = Vec3b(255, 255, 0);
开发者ID:mauriciozaragoza,项目名称:maze-solver-raspberry,代码行数:67,代码来源:main.cpp


注:本文中的Maze::draw_path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。