From 6605643a3ffb384acd91fa3693d0965999db8ec5 Mon Sep 17 00:00:00 2001 From: Nash Date: Sat, 30 Aug 2014 21:08:11 +0700 Subject: Added OpenCV-Qt code sample --- opencv-qt-integration-1/ImageViewer.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 opencv-qt-integration-1/ImageViewer.cpp (limited to 'opencv-qt-integration-1/ImageViewer.cpp') diff --git a/opencv-qt-integration-1/ImageViewer.cpp b/opencv-qt-integration-1/ImageViewer.cpp new file mode 100644 index 0000000..780f221 --- /dev/null +++ b/opencv-qt-integration-1/ImageViewer.cpp @@ -0,0 +1,28 @@ +#include +#include +#include +#include "ImageViewer.h" + +ImageViewer::ImageViewer() +{ + img = cv::imread("../assets/flughahn.jpg"); + + imageLabel = new QLabel(); + if (img.empty()) { + imageLabel->setText("Cannot load the input image!"); + } else { + cv::cvtColor(img, img, cv::COLOR_BGR2RGB); + QImage _img(img.data, img.cols, img.rows, QImage::Format_RGB888); + imageLabel->setPixmap(QPixmap::fromImage(_img)); + } + + quitButton = new QPushButton("Quit"); + connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); + + mainLayout = new QVBoxLayout(); + mainLayout->addWidget(imageLabel); + mainLayout->addWidget(quitButton); + + setLayout(mainLayout); + setWindowTitle("OpenCV - Qt Integration"); +} -- cgit v1.2.3