赞
踩
环境:macos+Qt5.15.0+opencv4.4.0+pcl1.9.1
安装
2、brew安装
打开:https://www.ipaddress.com/
在搜索框输入:raw.githubusercontent.com
修改系统文件hosts文件
在/etc/文件下找到hosts文件打开,添加自己对应内容,例如:199.232.68.133 raw.githubusercontent.com
安装brew:/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
安装wget:brew install wget
安装cmake:brew install cmake
2、 安装Qt
下载:官网下载
安装:直接根据需求安装即可
*3、 安装opencv4.4.0:*终端执行brew install opencv
*4、 安装pcl1.9.1:*参考 https://blog.csdn.net/OEMT_301/article/details/104250207
配置
1、 首先新建Qt项目
2、 Opencv项目:
在.pro文件中添加
INCLUDEPATH += /usr/local/Cellar/opencv/4.4.0/include
INCLUDEPATH += /usr/local/Cellar/opencv/4.4.0/include/opencv4
INCLUDEPATH += /usr/local/Cellar/opencv/4.4.0/include/opencv4/opencv2
LIBS += -L/usr/local/Cellar/opencv/4.4.0/lib -lopencv_gapi \
-lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired \
-lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm \
-lopencv_highgui -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs \
-lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg \
-lopencv_rgbd -lopencv_saliency -lopencv_sfm -lopencv_stereo -lopencv_structured_light \
-lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching \
-lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot \
-lopencv_videostab -lopencv_videoio -lopencv_xfeatures2d -lopencv_shape -lopencv_ml \
-lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect \
-lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto \
-lopencv_photo -lopencv_imgproc -lopencv_core
实例:
// main.cpp
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat img = Mat::zeros(Size(400,400), CV_8UC3);
imshow("img", img);
waitKey(0);
cout << "hello" << endl;
return 0;
}
3、 pcl项目:
在.pro文件中添加
INCLUDEPATH += /usr/local/Cellar/flann/1.9.1_9/include
INCLUDEPATH += /usr/local/Cellar/eigen/3.3.7/include/eigen3
INCLUDEPATH += /usr/local/Cellar/vtk/8.2.0_10/include/vtk-8.2
LIBS += /usr/local/Cellar/vtk/8.2.0_10/lib/libvtk*.dylib
INCLUDEPATH += /usr/local/Cellar/boost/1.73.0/include
LIBS += /usr/local/Cellar/boost/1.73.0/lib/libboost_*.dylib
INCLUDEPATH += /usr/local/Cellar/pcl/1.9.1_9/include/pcl-1.9
LIBS += /usr/local/Cellar/pcl/1.9.1_9/lib/libpcl_*.dylib
实例
// main.cpp #include <iostream> #include <pcl/point_types.h> #include <pcl/io/pcd_io.h> #include <pcl/visualization/pcl_visualizer.h> #include <pcl/io/io.h> using namespace std; using namespace pcl; using namespace io; int main() { PointCloud<PointXYZ>::Ptr cloud (new PointCloud<PointXYZ>); io::loadPCDFile("pcd文件路径", *cloud); if (cloud==NULL) { cerr << "can't read file bunny.pcd" << endl; return -1; } boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer(new pcl::visualization::PCLVisualizer("3D Viewer")); pcl::visualization::PointCloudColorHandlerGenericField<pcl::PointXYZ> fildColor(cloud, "z"); // 按照z字段进行渲染 viewer->addPointCloud<pcl::PointXYZ>(cloud, fildColor, "sample cloud"); viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "sample cloud"); // 设置点云大小 while (!viewer->wasStopped()) { viewer->spinOnce(100); boost::this_thread::sleep(boost::posix_time::microseconds(100000)); } return 0; }
合并:
INCLUDEPATH += /usr/local/Cellar/flann/1.9.1_9/include INCLUDEPATH += /usr/local/Cellar/eigen/3.3.7/include/eigen3 INCLUDEPATH += /usr/local/Cellar/vtk/8.2.0_10/include/vtk-8.2 LIBS += /usr/local/Cellar/vtk/8.2.0_10/lib/libvtk*.dylib INCLUDEPATH += /usr/local/Cellar/boost/1.73.0/include LIBS += /usr/local/Cellar/boost/1.73.0/lib/libboost_*.dylib INCLUDEPATH += /usr/local/Cellar/pcl/1.9.1_9/include/pcl-1.9 LIBS += /usr/local/Cellar/pcl/1.9.1_9/lib/libpcl_*.dylib INCLUDEPATH += /usr/local/Cellar/opencv/4.4.0/include INCLUDEPATH += /usr/local/Cellar/opencv/4.4.0/include/opencv4 INCLUDEPATH += /usr/local/Cellar/opencv/4.4.0/include/opencv4/opencv2 LIBS += -L/usr/local/Cellar/opencv/4.4.0/lib -lopencv_gapi \ -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired \ -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm \ -lopencv_highgui -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs \ -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg \ -lopencv_rgbd -lopencv_saliency -lopencv_sfm -lopencv_stereo -lopencv_structured_light \ -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching \ -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot \ -lopencv_videostab -lopencv_videoio -lopencv_xfeatures2d -lopencv_shape -lopencv_ml \ -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect \ -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto \ -lopencv_photo -lopencv_imgproc -lopencv_core
注:.pro中要添加自己对应的文件路径
———————————————————————————
2021年5月12日
INCLUDEPATH += /usr/local/Cellar/flann/1.9.1_10/include INCLUDEPATH += /usr/local/Cellar/eigen/3.3.9/include/eigen3 INCLUDEPATH += /usr/local/Cellar/vtk@8.2/8.2.0_4/include/vtk-8.2 LIBS += /usr/local/Cellar/vtk@8.2/8.2.0_4/lib/libvtk*.dylib INCLUDEPATH += /usr/local/Cellar/boost/1.75.0_2/include LIBS += /usr/local/Cellar/boost/1.75.0_2/lib/libboost_*.dylib INCLUDEPATH += /usr/local/include/pcl-1.11 LIBS += /usr/local/lib/libpcl_*.dylib INCLUDEPATH += /usr/local/include INCLUDEPATH += /usr/local/include/opencv4 INCLUDEPATH += /usr/local/include/opencv4/opencv2 LIBS += -L/usr/local/lib -lopencv_gapi \ -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired \ -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm \ -lopencv_highgui -lopencv_face -lopencv_fuzzy -lopencv_hfs \ -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg \ -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light \ -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching \ -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot \ -lopencv_videostab -lopencv_videoio -lopencv_xfeatures2d -lopencv_shape -lopencv_ml \ -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect \ -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto \ -lopencv_photo -lopencv_imgproc -lopencv_core
头文件
#include <iostream>
#include <string>
#include <fstream>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
//#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/io/io.h>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace pcl;
using namespace io;
using namespace cv;
修改:
项目->Run->Environment->DYLD_LIBRARY_PATH删除配置项
———————————————————————————
2021年7月31日
INCLUDEPATH += /usr/local/Cellar/flann/1.9.1_11/include INCLUDEPATH += /usr/local/Cellar/eigen/3.3.9/include/eigen3 INCLUDEPATH += /usr/local/Cellar/vtk@8.2/8.2.0_6/include/vtk-8.2 LIBS += /usr/local/Cellar/vtk@8.2/8.2.0_6/lib/libvtk*.dylib INCLUDEPATH += /usr/local/Cellar/boost/1.76.0/include LIBS += /usr/local/Cellar/boost/1.76.0/lib/libboost_*.dylib INCLUDEPATH += /usr/local/include/pcl-1.11 LIBS += /usr/local/lib/libpcl_*.dylib INCLUDEPATH += /usr/local/include INCLUDEPATH += /usr/local/include/opencv4 INCLUDEPATH += /usr/local/include/opencv4/opencv2 LIBS += -L/usr/local/lib -lopencv_gapi \ -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired \ -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm \ -lopencv_highgui -lopencv_face -lopencv_fuzzy -lopencv_hfs \ -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg \ -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light \ -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching \ -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot \ -lopencv_videostab -lopencv_videoio -lopencv_xfeatures2d -lopencv_shape -lopencv_ml \ -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect \ -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto \ -lopencv_photo -lopencv_imgproc -lopencv_core
#include <iostream>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/io/io.h>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace pcl;
using namespace io;
using namespace cv;
2021年8月1日:macos10.13.6
opencv4
pcl1.11
vtk-8.2
cmake
TEMPLATE = app CONFIG += console c++14 CONFIG -= app_bundle CONFIG -= qt SOURCES += \ main.cpp INCLUDEPATH += /usr/local/Cellar/flann/1.9.1_11/include INCLUDEPATH += /usr/local/Cellar/eigen/3.3.9/include/eigen3 INCLUDEPATH += /usr/local/include/vtk-8.2 LIBS += /usr/local/lib/libvtk*.dylib INCLUDEPATH += /usr/local/Cellar/boost/1.76.0/include LIBS += /usr/local/Cellar/boost/1.76.0/lib/libboost_*.dylib INCLUDEPATH += /usr/local/include/pcl-1.11 LIBS += /usr/local/lib/libpcl_*.dylib INCLUDEPATH += /usr/local/include INCLUDEPATH += /usr/local/include/opencv4 INCLUDEPATH += /usr/local/include/opencv4/opencv2 LIBS += -L/usr/local/lib -lopencv_gapi \ -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired \ -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm \ -lopencv_highgui -lopencv_face -lopencv_fuzzy -lopencv_hfs \ -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg \ -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light \ -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching \ -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot \ -lopencv_videostab -lopencv_videoio -lopencv_xfeatures2d -lopencv_shape -lopencv_ml \ -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect \ -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto \ -lopencv_photo -lopencv_imgproc -lopencv_core
#include <iostream>
#include <iostream>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/io/io.h>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace pcl;
using namespace io;
using namespace cv;
2021.8.13
INCLUDEPATH += /usr/local/Cellar/flann/1.9.1_11/include INCLUDEPATH += /usr/local/Cellar/eigen/3.3.9/include/eigen3 INCLUDEPATH += /usr/local/Cellar/vtk@8.2/8.2.0_7/include/vtk-8.2 LIBS += /usr/local/Cellar/vtk@8.2/8.2.0_7/lib/libvtk*.dylib INCLUDEPATH += /usr/local/Cellar/boost/1.76.0/include LIBS += /usr/local/Cellar/boost/1.76.0/lib/libboost_*.dylib INCLUDEPATH += /usr/local/include/pcl-1.11 LIBS += /usr/local/lib/libpcl_*.dylib INCLUDEPATH += /usr/local/include INCLUDEPATH += /usr/local/include/opencv4 INCLUDEPATH += /usr/local/include/opencv4/opencv2 LIBS += -L/usr/local/lib -lopencv_gapi \ -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired \ -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm \ -lopencv_highgui -lopencv_face -lopencv_fuzzy -lopencv_hfs \ -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg \ -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light \ -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching \ -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot \ -lopencv_videostab -lopencv_videoio -lopencv_xfeatures2d -lopencv_shape -lopencv_ml \ -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect \ -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto \ -lopencv_photo -lopencv_imgproc -lopencv_core
#include <iostream> #include <pcl/common/common_headers.h> #include <pcl/io/pcd_io.h> #include <pcl/visualization/pcl_visualizer.h> #include <pcl/console/parse.h> int main() { std::cout << "Test PCL !!!" << std::endl; pcl::PointCloud<pcl::PointXYZRGB>::Ptr point_cloud_ptr (new pcl::PointCloud<pcl::PointXYZRGB>); uint8_t r(255), g(15), b(15); for (float z(-1.0); z <= 1.0; z += 0.05) { for (float angle(0.0); angle <= 360.0; angle += 5.0) { pcl::PointXYZRGB point; point.x = 0.5 * cosf (pcl::deg2rad(angle)); point.y = sinf (pcl::deg2rad(angle)); point.z = z; uint32_t rgb = (static_cast<uint32_t>(r) << 16 | static_cast<uint32_t>(g) << 8 | static_cast<uint32_t>(b)); point.rgb = *reinterpret_cast<float*>(&rgb); point_cloud_ptr->points.push_back (point); } if (z < 0.0) { r -= 12; g += 12; } else { g -= 12; b += 12; } } point_cloud_ptr->width = (int) point_cloud_ptr->points.size (); point_cloud_ptr->height = 1; boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer(new pcl::visualization::PCLVisualizer("3D Viewer")); pcl::visualization::PointCloudColorHandlerGenericField<pcl::PointXYZRGB> fildColor(point_cloud_ptr, "z"); // 按照z字段进行渲染 viewer->addPointCloud<pcl::PointXYZRGB>(point_cloud_ptr, fildColor, "sample cloud"); viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "sample cloud"); // 设置点云大小 while (!viewer->wasStopped()) { viewer->spinOnce(100); } return 0; }
2022.1.24
macbook M1
安装brew:
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/joemt/.zprofile
INCLUDEPATH += /opt/homebrew/Cellar/flann/1.9.1_11/include INCLUDEPATH += /opt/homebrew/Cellar/eigen/3.4.0_1/include/eigen3 INCLUDEPATH += /opt/homebrew/Cellar/vtk@8.2/8.2.0_7/include/vtk-8.2 LIBS += /opt/homebrew/Cellar/vtk@8.2/8.2.0_7/lib/libvtk*.dylib INCLUDEPATH += /opt/homebrew/Cellar/boost/1.76.0/include LIBS += /opt/homebrew/Cellar/boost/1.76.0/lib/libboost_*.dylib INCLUDEPATH += /usr/local/include/pcl-1.11 LIBS += /usr/local/lib/libpcl_*.dylib INCLUDEPATH += /usr/local/include INCLUDEPATH += /usr/local/include/opencv4 INCLUDEPATH += /usr/local/include/opencv4/opencv2 LIBS += -L/usr/local/lib -lopencv_gapi \ -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired \ -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm \ -lopencv_highgui -lopencv_face -lopencv_fuzzy -lopencv_hfs \ -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg \ -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light \ -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching \ -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot \ -lopencv_videostab -lopencv_videoio -lopencv_xfeatures2d -lopencv_shape -lopencv_ml \ -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect \ -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto \ -lopencv_photo -lopencv_imgproc -lopencv_core
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。