mac 下用 qt 搭建 opencv
根據網上搭建時老是報這個錯
解決方案 報那個錯的原因就幾個 1.沒有實現函數 這個可以排除。
2.沒有包含庫 對就是這個 但不是只包含網上說的那幾個 得全包含(反正包含到不報錯為止)
macx{
INCLUDEPATH += /usr/local/opt/opencv@3/include
LIBS += -L/usr/local/Cellar/opencv/3.4.1/lib -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn -lopencv_dpm -lopencv_fuzzy -lopencv_line_descriptor -lopencv_optflow -lopencv_plot -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_rgbd -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_face -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_photo -lopencv_imgproc -lopencv_core
#------------------------------------------------- # # Project created by QtCreator 2018-03-10T18:59:53 # #------------------------------------------------- QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = testopencv TEMPLATE = app # The following define makes your compiler emit warnings if you use # any feature of Qt which as been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += main.cpp mainwindow.cpp HEADERS += mainwindow.h FORMS += mainwindow.ui #INCLUDEPATH += /usr/local/include #INCLUDEPATH += /usr/local/include/opencv #INCLUDEPATH += /usr/local/include/opencv2 #LIBS += -L/usr/local/lib # -lopencv_core # -lopencv_highgui # -lopencv_imgproc ## -lopencv_calib3d #LIBS += -L/usr/local/lib # LIBS +=-lopencv_core -lopencv_highgui -lopencv_imgproc -v macx{ INCLUDEPATH += /usr/local/opt/opencv@3/include LIBS += -L/usr/local/Cellar/opencv/3.4.1/lib -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn -lopencv_dpm -lopencv_fuzzy -lopencv_line_descriptor -lopencv_optflow -lopencv_plot -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_rgbd -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_face -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_photo -lopencv_imgproc -lopencv_core }
//#include "mainwindow.h" //#include <QApplication> //int main(int argc, char *argv[]) //{ // QApplication a(argc, argv); // MainWindow w; // w.show(); // return a.exec(); //} #include <iostream> #include <string> #include <vector> using namespace std; #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> using namespace cv; int main(int argc, char *argv[]) { // Mat src = imread("Users/allenboy/Desktop/allen.jpeg"); // if(src.empty()) // { // cerr << "Please check the path of input image!" << endl; // return -1; // } // const string winname = "src"; // namedWindow(winname, WINDOW_AUTOSIZE); // imshow(winname, src); // waitKey(0); // destroyWindow(winname); // cv::Mat img = cv::imread("/Users/tianzhaixing/Pictures/jurassic_world.jpg"); // cv::imshow("Image", img); // cv::waitKey(0); VideoCapture capture(0); //打開攝像頭 Mat frame; //定義儲存圖像的mat類型變量 //double rate = capture.get(CAP_PROP_FPS); //定義幀率,如果是打開視頻文件 Size videoSize(capture.get(CAP_PROP_FRAME_WIDTH), capture.get(CAP_PROP_FRAME_HEIGHT)); VideoWriter writer("Users/allenboy/Desktop/VideoTest.avi", CV_FOURCC(‘M‘, ‘J‘, ‘P‘, ‘G‘), 20, videoSize); //(5個參數分別為文件名,視頻格式,幀率,幀尺寸,bool isColortrue(默認的)如果想保存一個彩色視頻,這個值為true,否則為false。)20相當於rate,表示幀率 if (!writer.isOpened()) //測試是否打開寫文件成功 { cout << "寫入視頻文件打開失敗!" << endl; return -1; } int kernel=0; //定義一個變量存儲內核值 for (int i = 0; i <200;i++) //拍攝一個10秒的視頻,因為上面定義的幀率為20,所以循環200次正好是10秒 { capture >> frame; //讀入幀 imshow("原圖", frame); //顯示 kernel = (i /10)+1; //設置濾波的內核尺寸kernel,使逐漸增大,內核最小為1,不能為0 blur(frame, frame, Size(kernel,kernel)); //采用一次均值濾波 writer << frame; //寫入視頻文件 //cvtColor(frame, frame, CV_BGR2GRAY); //彩色轉為灰度圖 imshow("中值濾波圖", frame); //顯示 waitKey(30); //等待顯示 } return 0; }
mac 下用 qt 搭建 opencv