OpenCV cv::viz: How to show World coordinate and Camera coordinate?

Share:
# 目标: - 使用OpenCV cv::viz模块来绘制世界坐标系 - cv::viz: How to show World coordinate and Camera coordinate? # Sample Code ```cpp #include #include <opencv2/calib3d.hpp> #include <opencv2/viz/types.hpp> #include <opencv2/viz/vizcore.hpp> using namespace cv; using namespace std; int main() { // Create a window viz::Viz3d myWindow("Viz Demo"); // add widget myWindow.showWidget("world", viz::WCoordinateSystem()); // Draw line viz::WLine axis(Point3f(0.f, 0.f, 0.f), Point3f(2.f, 2.f, 2.f), viz::Color::yellow()); axis.setRenderingProperty(viz::LINE_WIDTH, 1.0); myWindow.showWidget("Line Widget", axis); // Camera coordinate Vec3f cam_pos(2.0f, 2.0f, 2.0f), cam_focal_point(3.0f, 3.0f, 3.0f), cam_y_dir(-0.f, 0.0f, -1.0f); Affine3f cam_pose = viz::makeCameraPose(cam_pos, cam_focal_point, cam_y_dir); // Affine3f transform = viz::makeTransformToGlobal(Vec3f(0.0f, -1.0f, 0.0f), Vec3f(-1.0f, 0.0f, 0.0f), Vec3f(0.0f, 0.0f, -1.0f), cam_pos); viz::WCameraPosition cpw(1); // Coordinate axes viz::WCameraPosition cpw_frustum(Vec2f(0.889484, 0.523599)); // Camera frustum myWindow.showWidget("CPW", cpw, cam_pose); myWindow.showWidget("CPW_FRUSTUM", cpw_frustum, cam_pose); // Start event loop myWindow.spin(); return 0; } ``` # Result:

No comments