系统 mac qt 库 5.8 ide 4.21 opencv 3.4.1

根据网上搭建时老是报这个错 解决方案 报那个错的原因就几个 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;
}