Skip to content

Commit

Permalink
Added converson from QImage to cv::Mat
Browse files Browse the repository at this point in the history
  • Loading branch information
nikkonrom committed Sep 14, 2017
1 parent 9fb101f commit 8e3fd3c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 6 deletions.
17 changes: 17 additions & 0 deletions boundaries.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
#include "boundaries.h"



Boundaries::Boundaries()
{

}

QImage mat_to_qimage_ref(cv::Mat &mat, QImage::Format format)
{
return QImage(mat.data, mat.cols, mat.rows, mat.step, format);
}

cv::Mat qimage_to_mat_ref(QImage &img, int format)
{
return cv::Mat(img.height(), img.width(),
format, img.bits(), img.bytesPerLine());
}

QImage Boundaries::execute(){
return this->inputImage;
}
8 changes: 7 additions & 1 deletion boundaries.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
#define BOUNDARIES_H
#include <operation.h>

#include <opencv2/core/core.hpp>

class Boundaries : public Operation
{
public:
explicit Boundaries();
Boundaries();
QImage execute();
private:
QImage mat_to_qimage_ref(cv::Mat &mat, QImage::Format format);
cv::Mat qimage_to_mat_ref(QImage &img, int format);
};

#endif // BOUNDARIES_H
2 changes: 1 addition & 1 deletion mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void MainWindow::on_actionOpen_triggered()
while (dialog.exec() == QDialog::Accepted && !loadFile(dialog.selectedFiles().first())) {}
}

void MainWindow::on_pushButton_clicked()
void MainWindow::on_loadButton_clicked()
{
MainWindow::on_actionOpen_triggered();
}
Expand Down
2 changes: 1 addition & 1 deletion mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MainWindow : public QMainWindow
private slots:
void on_actionOpen_triggered();

void on_pushButton_clicked();
void on_loadButton_clicked();

void on_boudaries_button_clicked();

Expand Down
4 changes: 2 additions & 2 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton">
<widget class="QPushButton" name="loadButton">
<property name="text">
<string>Load</string>
</property>
Expand Down Expand Up @@ -205,7 +205,7 @@
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>pushButton</tabstop>
<tabstop>loadButton</tabstop>
<tabstop>checkBox</tabstop>
<tabstop>checkBox_2</tabstop>
</tabstops>
Expand Down
2 changes: 1 addition & 1 deletion operation.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Operation
public:
void setImage(QImage image);
virtual QImage execute();
private:
protected:
QImage inputImage;

};
Expand Down

0 comments on commit 8e3fd3c

Please sign in to comment.