summaryrefslogtreecommitdiff
path: root/opencv-qt-integration-2/ImageApp.cpp
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2016-11-26 12:40:34 +0100
committerPatrick Simianer <p@simianer.de>2016-11-26 12:40:34 +0100
commit162187608bbaf1f79d38c88803754c8e58359129 (patch)
tree24a10ed5f715585215377854af6c0cbde276ca83 /opencv-qt-integration-2/ImageApp.cpp
parent89ec4030ba4e426e6e7992336a6665ef9d37ec48 (diff)
cleanup
Diffstat (limited to 'opencv-qt-integration-2/ImageApp.cpp')
-rw-r--r--opencv-qt-integration-2/ImageApp.cpp92
1 files changed, 0 insertions, 92 deletions
diff --git a/opencv-qt-integration-2/ImageApp.cpp b/opencv-qt-integration-2/ImageApp.cpp
deleted file mode 100644
index 5833bd8..0000000
--- a/opencv-qt-integration-2/ImageApp.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-#include <opencv2/imgproc/imgproc.hpp>
-#include <opencv2/highgui/highgui.hpp>
-#include <QtWidgets>
-#include "ImageApp.h"
-
-ImageApp::ImageApp()
-{
- originalImage = cv::imread("../assets/The_Chapter_House.jpg");
- if (originalImage.data) {
- cv::cvtColor(originalImage, originalImage, cv::COLOR_BGR2RGB);
- }
- setupUi();
- showImage(originalImage);
-}
-
-/**
- * Setup the widgets
- */
-void ImageApp::setupUi()
-{
- imageLabel = new QLabel();
-
- originalButton = new QPushButton("Original");
- connect(originalButton, SIGNAL(clicked()), this, SLOT(showOriginalImage()));
-
- blurButton = new QPushButton("Gaussian Blur");
- connect(blurButton, SIGNAL(clicked()), this, SLOT(doGaussianBlur()));
-
- cannyButton = new QPushButton("Canny");
- connect(cannyButton, SIGNAL(clicked()), this, SLOT(doCanny()));
-
- quitButton = new QPushButton("Quit");
- connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
-
- buttonsLayout = new QVBoxLayout();
- buttonsLayout->addWidget(originalButton);
- buttonsLayout->addWidget(blurButton);
- buttonsLayout->addWidget(cannyButton);
- buttonsLayout->addStretch();
- buttonsLayout->addWidget(quitButton);
-
- mainLayout = new QHBoxLayout();
- mainLayout->addWidget(imageLabel);
-
- if (originalImage.data) {
- mainLayout->addLayout(buttonsLayout);
- }
- setLayout(mainLayout);
- setWindowTitle("Image Processing with Qt and OpenCV");
-}
-
-/**
- * Redraw original image
- */
-void ImageApp::showOriginalImage()
-{
- showImage(originalImage);
-}
-
-/**
- * Perform Canny edge detection on original image and display the result
- */
-void ImageApp::doCanny()
-{
- cv::Mat gray;
- cv::cvtColor(originalImage, gray, cv::COLOR_RGB2GRAY);
- cv::Canny(gray, processedImage, 150, 150);
- cv::cvtColor(processedImage, processedImage, cv::COLOR_GRAY2RGB);
- showImage(processedImage);
-}
-
-/**
- * Perform Gaussian blurring on original image and display the result
- */
-void ImageApp::doGaussianBlur()
-{
- cv::GaussianBlur(originalImage, processedImage, cv::Size(15, 15), 0, 0);
- showImage(processedImage);
-}
-
-/**
- * Draw OpenCV matrix using QLabel
- */
-void ImageApp::showImage(cv::Mat img)
-{
- if (img.data) {
- QImage _img(img.data, img.cols, img.rows, QImage::Format_RGB888);
- imageLabel->setPixmap(QPixmap::fromImage(_img));
- } else {
- imageLabel->setText("Cannot load the input image!");
- }
-}