QT + OpenCV Example

Source

  1. #include <QCoreApplication>
  2.  
  3. #include <opencv2/opencv.hpp>
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7.     //QCoreApplication a(argc, argv);
  8.  
  9.     using namespace cv;
  10.     Mat image = imread("/Users/water/Downloads/Share.jpg");
  11.     imshow("Output", image);
  12.  
  13.     waitKey(1000);
  14.  
  15.     return 0;
  16.  
  17.     //return a.exec();
  18. }

pro

  1. QT -= gui
  2.  
  3. CONFIG += c++11 console
  4. CONFIG -= app_bundle
  5.  
  6. # The following define makes your compiler emit warnings if you use
  7. # any Qt feature that has been marked deprecated (the exact warnings
  8. # depend on your compiler). Please consult the documentation of the
  9. # deprecated API in order to know how to port your code away from it.
  10. DEFINES += QT_DEPRECATED_WARNINGS
  11.  
  12. # You can also make your code fail to compile if it uses deprecated APIs.
  13. # In order to do so, uncomment the following line.
  14. # You can also select to disable deprecated APIs only up to a certain version of Qt.
  15. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
  16.  
  17. SOURCES += \
  18.         main.cpp
  19.  
  20. # Default rules for deployment.
  21. qnx: target.path = /tmp/$${TARGET}/bin
  22. else: unix:!android: target.path = /opt/$${TARGET}/bin
  23. !isEmpty(target.path): INSTALLS += target
  24.  
  25. INCLUDEPATH += /usr/local/include
  26. INCLUDEPATH += /usr/local/include/opencv
  27. INCLUDEPATH += /usr/local/include/opencv2
  28. LIBS += -L/usr/local/lib \
  29.  -lopencv_core \
  30.  -lopencv_highgui \
  31.  -lopencv_imgproc \
  32.   -lopencv_imgcodecs \

Leave a Reply

Your email address will not be published. Required fields are marked *