赞
踩
- #include <opencv2/opencv.hpp>
- #include <opencv2/viz.hpp>
-
- using namespace std;
- using namespace cv;
-
- int main(int argc, char const *argv[]) {
- cv::Mat img_in(200, 750, CV_8UC1, cv::Scalar(0));
- std::vector<cv::Vec3f> cloud;
- std::vector<cv::Vec3b> color;
-
- cv::putText(img_in, "Hello World !", cv::Point(75, 150), 0, 3, cv::Scalar(255), 2);
-
- for (int x = -200; x < 0; x++) {
- for (int y = 0; y < 750; y++) {
- cloud.push_back(cv::Vec3f(x, y, img_in.at<uchar>(x + 200, y)));
- color.push_back(cv::Vec3b(255, 0, 0));
- }
- }
-
- viz::WCoordinateSystem world_coor(1.0);
- viz::WPlane plane(cv::Size(200, 200));
- viz::WCloud cloud_widget(cloud, color);
-
- //初始化
- cv::viz::Viz3d window("window");
-
- window.showWidget("World",world_coor);
- window.showWidget("plane", plane);
-
- while (1) {
- window.showWidget("pnt_cloud", cloud_widget);
- window.spinOnce(10, false);
- }
-
- return 0;
- }
效果图:
安装包和源码:
OpenCV4.5 + OpenCV4.5 Contribut 源码 + 安装包 (Win64 Debug VS2017)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。