moved Pastie so seperate repo

This commit is contained in:
Steffen Vogel 2014-12-20 14:07:15 +01:00
commit a1893e4917
114 changed files with 6459 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
Pastie
moc_*
ui_*

119
Pastie.pro Normal file
View File

@ -0,0 +1,119 @@
#-------------------------------------------------
#
# Project created by QtCreator 2014-09-12T15:39:17
#
#-------------------------------------------------
QT += core gui opengl multimedia
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Pastie
TEMPLATE = app
ICON = resources/Mr-potato.icns
SOURCES += main.cpp\
mainwindow.cpp \
camera.cpp \
imagelist.cpp \
image.cpp \
viewer.cpp \
debugstream.cpp \
filterlist.cpp \
source.cpp \
tabcalibration.cpp \
tabimages.cpp \
tabcamera.cpp \
tabfilters.cpp \
tabpads.cpp \
console.cpp \
painter.cpp \
filters/maxchannel.cpp \
filters/normalize.cpp \
filters/shapedetect.cpp \
filters/setting.cpp \
filters/result.cpp \
filters/blur.cpp \
filters/watershed.cpp
HEADERS += mainwindow.h \
camera.h \
imagelist.h \
image.h \
viewer.h \
debugstream.h \
filterlist.h \
source.h \
tabcalibration.h \
tabimages.h \
tabcamera.h \
tabfilters.h \
tabpads.h \
console.h \
cast.h \
painter.h \
filters.h \
filters/maxchannel.h \
filters/normalize.h \
filters/shapedetect.h \
filters/setting.h \
filters/result.h \
filters/blur.h \
filters/watershed.h
SOURCES += filters/filter.cpp \
filters/undistort.cpp \
filters/threshold.cpp \
filters/kmeans.cpp \
filters/histequalize.cpp \
filters/morph.cpp \
filters/convert.cpp \
filters/pattern.cpp \
filters/padfilter.cpp \
filters/edgedetect.cpp \
filters/channel.cpp \
filters/perspective.cpp
HEADERS += filters/filter.h \
filters/kmeans.h \
filters/threshold.h \
filters/undistort.h \
filters/histequalize.h \
filters/morph.h \
filters/convert.h \
filters/pattern.h \
filters/edgedetect.h \
filters/channel.h \
filters/perspective.h \
filters/padfilter.h
FORMS += mainwindow.ui \
about.ui \
imagelist.ui \
tabcalibration.ui \
tabimages.ui \
tabcamera.ui \
tabfilters.ui \
tabpads.ui
# OpenCV
INCLUDEPATH += /usr/local/include
LIBS += -L/usr/local/lib
LIBS += -lopencv_core \
-lopencv_highgui \
-lopencv_imgproc\
-lopencv_imgcodecs \
-lopencv_videoio \
-lopencv_calib3d \
-lopencv_features2d
RESOURCES += \
images.qrc \
texts.qrc
OTHER_FILES +=
CONFIG += c++11
QMAKE_MAC_SDK = macosx10.10

263
Pastie.pro.user Normal file
View File

@ -0,0 +1,263 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.3.0, 2014-12-20T13:25:42. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{8f80b8d2-0f3b-47b3-a327-f81ae0873a3f}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">qt2</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">1</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap"/>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.4.0 clang 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.4.0 clang 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.54.clang_64_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/stv0g/workspace/rwth-dbv/code/build-Pastie-Desktop_Qt_5_4_0_clang_64bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/stv0g/workspace/rwth-dbv/code/build-Pastie-Desktop_Qt_5_4_0_clang_64bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deployment</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Lokales Deployment</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Pastie</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/Users/stv0g/workspace/rwth-dbv/code/pastie/Pastie.pro</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments">google/*</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">Pastie.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory">/Users/stv0g/workspace/rwth-dbv/data</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">18</value>
</data>
<data>
<variable>Version</variable>
<value type="int">18</value>
</data>
</qtcreator>

143
about.ui Normal file
View File

@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AboutDialog</class>
<widget class="QDialog" name="AboutDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>585</width>
<height>254</height>
</rect>
</property>
<property name="windowTitle">
<string>About</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="2">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPlainTextEdit" name="plainTextEdit">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="plainText">
<string>Seminar Bildverarbeitung und Inhaltsanalyse
Lehrstuhl für Bildverarbeitung
RWTH Aachen
Steffen Vogel
- Mail: steffen.vogel@rwth-aachen.de
- Web: http:///www.steffenvogel.de
Wintersemester 2014/15</string>
</property>
<property name="backgroundVisible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>128</width>
<height>128</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>192</width>
<height>192</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="images.qrc">:/icons/resources/Mr-potato.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="margin">
<number>10</number>
</property>
</widget>
</item>
<item row="0" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="images.qrc"/>
</resources>
<connections>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>AboutDialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>400</x>
<y>176</y>
</hint>
<hint type="destinationlabel">
<x>294</x>
<y>186</y>
</hint>
</hints>
</connection>
</connections>
</ui>

76
camera.cpp Normal file
View File

@ -0,0 +1,76 @@
#include <opencv2/calib3d.hpp>
#include <QtDebug>
#include "filters/pattern.h"
#include "camera.h"
#include "image.h"
Camera::Camera(Source *s) :
source(s),
calibrated(false)
{
reset();
}
void Camera::reset()
{
calibrated = false;
avgReprErr = 0;
distCoeffs = Mat::zeros(8, 1, CV_32F);
matrix = Mat::eye(3, 3, CV_32F);
}
bool Camera::calibrate(list<Image *> imgs, Pattern *pattern)
{
vector<vector<Point2f>> imagePoints;
vector<vector<Point3f>> objectPoints;
vector<Mat> rvecs, tvecs;
if (calibrated) {
qWarning() << "Camera is already calibrated. Reset first!";
return false;
}
for (auto img : imgs) {
img->applyFilter(pattern);
PatternResult *result = (PatternResult *) img->getResult(pattern);
if (result->isFound())
imagePoints.push_back(result->getPoints());
}
if (imagePoints.size() < 5) {
qWarning() << "Only " << imagePoints.size() << " patterns detected. This is not enough!";
return false;
}
/* Fill in vector of calibration rig points */
std::vector<Point3f> planar = pattern->getPoints();
for (unsigned i = 0; i < imagePoints.size(); i++)
objectPoints.push_back(planar);
/* Calculate camera matrix and distortion coefficients */
calibrateCamera(objectPoints, imagePoints, source->getSize(), matrix, distCoeffs, rvecs, tvecs);
/* Calculate average reprojection error */
double totalErr = 0;
int totalPoints = 0;
for (unsigned i = 0; i < imagePoints.size(); i++) {
std::vector<Point2f> imagePoints2;
projectPoints(objectPoints[i], rvecs[i], tvecs[i], matrix, distCoeffs, imagePoints2);
totalErr += pow(norm(imagePoints[i], imagePoints2, NORM_L2), 2);
totalPoints += objectPoints[i].size();
}
avgReprErr = totalErr / totalPoints;
calibrated = true;
qDebug() << "Calibration completed: Found " << imagePoints.size() << " patterns in " << imgs.size() << " images";
return true;
}

41
camera.h Normal file
View File

@ -0,0 +1,41 @@
#ifndef CAMERA_H
#define CAMERA_H
#include <opencv2/videoio.hpp>
#include <list>
#include "source.h"
#include "filters/pattern.h"
using namespace cv;
using namespace std;
class Image;
class Camera
{
public:
Camera(Source *s);
bool calibrate(list<Image *> imgs, Pattern *pattern);
/* Getters */
const Mat & getDistCoeffs() { return distCoeffs; }
const Mat & getMatrix() { return matrix; }
double getAvgReprErr() { return avgReprErr; }
bool isCalibrated() { return calibrated; }
void reset();
Source *source;
protected:
bool calibrated;
double avgReprErr;
Mat matrix;
Mat distCoeffs;
};
#endif // CAMERA_H

58
cast.h Normal file
View File

@ -0,0 +1,58 @@
#ifndef CAST_H
#define CAST_H
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <QtDebug>
#include <QTransform>
#include <QSize>
#include <QPoint>
#include <QRect>
#include <QImage>
using namespace cv;
inline QImage toQImage(const Mat &mat)
{
Mat *conv = new Mat;
switch (mat.channels()) {
case 3: cvtColor(mat, *conv, COLOR_RGB2RGBA); break;
case 1: cvtColor(mat, *conv, COLOR_GRAY2RGBA); break;
}
return QImage((const unsigned char *) conv->data, conv->cols, conv->rows, conv->step,
QImage::Format_RGB32, [] (void * data) { ((Mat *) data)->release(); }, conv);
}
inline QTransform toQTransform(const Mat &m)
{
return QTransform(
m.at<float>(0,0), m.at<float>(0,1), m.at<float>(0,2),
m.at<float>(1,0), m.at<float>(1,1), m.at<float>(1,2),
m.at<float>(2,0), m.at<float>(2,1), m.at<float>(2,2));
}
inline QSize toQt(const Size2i &s) { return QSize (s.width, s.height); }
inline QSizeF toQt(const Size2d &s) { return QSizeF(s.width, s.height); }
inline QPoint toQt(const Point2i &p) { return QPoint (p.x, p.y); }
inline QPointF toQt(const Point2d &p) { return QPointF(p.x, p.y); }
inline QRect toQt(const Rect2i &r) { return QRect (r.x, r.y, r.width, r.height); }
inline QRectF toQt(const Rect2d &r) { return QRectF(r.x, r.y, r.width, r.height); }
inline Size2i toCv(const QSize &s) { return Size2i(s.width(), s.height()); }
inline Size2d toCv(const QSizeF &s) { return Size2d(s.width(), s.height()); }
inline Point2i toCv(const QPoint &p) { return Point2i(p.x(), p.y()); }
inline Point2d toCv(const QPointF &p) { return Point2d(p.x(), p.y()); }
inline Rect2i toCv(const QRect &r) { return Rect2i(r.x(), r.y(), r.width(), r.height()); }
inline Rect2d toCv(const QRectF &r) { return Rect2d(r.x(), r.y(), r.width(), r.height()); }
#endif // CAST_H

25
console.cpp Normal file
View File

@ -0,0 +1,25 @@
#include <QtDebug>
#include <QScrollBar>
#include "console.h"
Console::Console(QWidget *parent) :
QPlainTextEdit(parent),
qcout(std::cout, QtDebugMsg), /* redirect standard outputs to console */
qcerr(std::cerr, QtCriticalMsg)
{
DebugStream::registerConsole(this);
DebugStream::registerHandler();
}
void Console::setup()
{
QFile intro(":/resources/intro.html");
if (!intro.open(QFile::ReadOnly))
qCritical() << "Failed to open intro.html resource";
appendHtml(intro.readAll());
moveCursor(QTextCursor::Start);
}

20
console.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef CONSOLE_H
#define CONSOLE_H
#include <QPlainTextEdit>
#include "debugstream.h"
class Console : public QPlainTextEdit
{
public:
Console(QWidget *parent = 0);
void setup();
protected:
DebugStream qcout;
DebugStream qcerr;
};
#endif // CONSOLE_H

98
debugstream.cpp Normal file
View File

@ -0,0 +1,98 @@
#include <QtDebug>
#include "debugstream.h"
QPlainTextEdit *DebugStream::console;
DebugStream::DebugStream(std::ostream &s, QtMsgType t) :
stream(s),
type(t)
{
oldBuf = s.rdbuf();
s.rdbuf(this);
}
DebugStream::~DebugStream()
{
if (!string.empty())
handler(type, QString::fromStdString(string));
stream.rdbuf(oldBuf);
}
std::streamsize DebugStream::xsputn(const char *p, std::streamsize n)
{
string.append(p, p + n);
size_t pos = 0;
while (pos != std::string::npos) {
pos = string.find('\n');
if (pos != std::string::npos) {
std::string tmp(string.begin(), string.begin() + pos);
handler(type, QString::fromStdString(tmp));
string. erase(string.begin(), string.begin() + pos + 1);
}
}
return n;
}
int DebugStream::overflow(int v)
{
if (v == '\n') {
handler(type, QString::fromStdString(string));
string.clear();
}
else
string += v;
return v;
}
QString DebugStream::format(QString msg, QtMsgType type)
{
QString out("<pre><div style='font-weight: bold; color: %1'>[%2]</div> %3</pre>");
switch (type) {
case QtDebugMsg: out = out.arg("Gray").arg("Debug "); break;
case QtWarningMsg: out = out.arg("Orange").arg("Warning "); break;
case QtCriticalMsg: out = out.arg("DarkRed").arg("Critical"); break;
case QtFatalMsg: out = out.arg("Magenta").arg("Fatal "); break;
}
return out.arg(msg);
}
void DebugStream::registerHandler()
{
qInstallMessageHandler(DebugStream::handler);
}
void DebugStream::registerConsole(QPlainTextEdit *pte)
{
console = pte;
}
void DebugStream::handler(QtMsgType type, const QString &msg)
{
static int dropped;
static int next = 1;
if (msg == "Camera dropped frame!") {
if (++dropped == next) {
next = next + next*2;
printf("Camera dropped %u frames! Next %u\n\n", dropped, next);
}
return;
}
if (console)
console->appendHtml(format(msg, type));
else
printf("%s\n", (const char *) QByteArray(msg.toLocal8Bit().constData()));
}
void DebugStream::handler(QtMsgType type, const QMessageLogContext &, const QString &msg)
{
handler(type, msg);
}

36
debugstream.h Normal file
View File

@ -0,0 +1,36 @@
#ifndef DEBUGSTREAM_H
#define DEBUGSTREAM_H
#include <QtGlobal>
#include <QPlainTextEdit>
#include <iostream>
class DebugStream : public std::basic_streambuf<char>
{
public:
DebugStream(std::ostream &stream, QtMsgType type);
~DebugStream();
static QString format(QString msg, QtMsgType type = QtDebugMsg);
static void registerConsole(QPlainTextEdit *);
static void registerHandler();
protected:
int overflow(int_type v);
std::streamsize xsputn(const char *p, std::streamsize n);
private:
std::ostream &stream;
std::streambuf *oldBuf;
std::string string;
QtMsgType type;
static void handler(QtMsgType type, const QString &msg);
static void handler(QtMsgType type, const QMessageLogContext &, const QString &str);
static QPlainTextEdit *console;
};
#endif // DEBUGSTREAM_H

131
filterlist.cpp Normal file
View File

@ -0,0 +1,131 @@
#include "mainwindow.h"
#include "filterlist.h"
FilterList::FilterList(QObject *parent) :
QAbstractTableModel(parent),
selection(this)
{
connect(&selection, &QItemSelectionModel::currentChanged, [&] (QModelIndex i, QModelIndex) {
emit filterSelected(at(i.row()));
});
}
int FilterList::rowCount(const QModelIndex &) const
{
return size();
}
int FilterList::columnCount(const QModelIndex &) const
{
return 5;
}
QVariant FilterList::data(const QModelIndex &index, int role) const
{
Filter *filter = at(index.row());
Result *result = filter->getLastResult();
switch (role) {
case Qt::DisplayRole:
case Qt::EditRole:
switch (index.column()) {
case 2: return filter->getName();
case 3: return (filter->isEnabled() && result) ? result->getResult() : QVariant();
case 4: return (filter->isEnabled()) ? QString::number(filter->getTime() * 1e-6, 'g', 3) : QVariant();
}
break;
case Qt::CheckStateRole:
switch (index.column()) {
case 0: return (filter->isEnabled()) ? Qt::Checked: Qt::Unchecked;
case 1: return (filter->isShown()) ? Qt::Checked: Qt::Unchecked;
}
}
return QVariant();
}
bool FilterList::setData(const QModelIndex &index, const QVariant &value, int role)
{
Filter *filter = at(index.row());
switch (role) {
case Qt::CheckStateRole:
switch (index.column()) {
case 0: filter->setEnabled(value == Qt::Checked);
case 1: filter->setShow(value == Qt::Checked); break;
}
break;
}
emit filtersChanged();
return true;
}
QVariant FilterList::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role == Qt::DisplayRole) {
if (orientation == Qt::Horizontal) {
switch (section) {
case 0: return QString(tr("Enabled"));
case 1: return QString(tr("Show"));
case 2: return QString(tr("Filter"));
case 3: return QString(tr("Result"));
case 4: return QString(tr("Time [mSec]"));
}
}
}
return QVariant();
}
Qt::ItemFlags FilterList::flags(const QModelIndex &index) const
{
Qt::ItemFlags flags = Qt::ItemIsEnabled;
switch (index.column()) {
case 0:
case 1: flags |= Qt::ItemIsUserCheckable; break;
case 2: flags |= Qt::ItemIsSelectable; break;
}
return flags;
}
void FilterList::add(Filter *filter)
{
beginInsertRows(QModelIndex(), size(), size());
push_back(filter);
endInsertRows();
connect(filter, SIGNAL(filterChanged()), this, SIGNAL(filtersChanged()));
emit filterAdded(filter);
}
void FilterList::execute(Image *img)
{
img->filtered = img->original.clone();
try {
for (auto filter : *this) {
img->applyFilter(filter);
}
} catch (Exception e) {
qCritical("%s", e.msg.c_str());
}
/* Update times and results */
emit dataChanged(
createIndex(0, 4),
createIndex(size(), 4)
);
}
void FilterList::reset()
{
for (Filter *filter : *this)
filter->reset();
}

41
filterlist.h Normal file
View File

@ -0,0 +1,41 @@
#ifndef FILTERLIST_H
#define FILTERLIST_H
#include <QAbstractTableModel>
#include <QItemSelection>
#include "filters/filter.h"
class FilterList :
public QAbstractTableModel,
public QList<Filter *>
{
Q_OBJECT
public:
FilterList(QObject *parent = 0);
int rowCount(const QModelIndex &) const;
int columnCount(const QModelIndex &) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
Qt::ItemFlags flags(const QModelIndex & index) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
void add(Filter *filt);
void execute(Image *img);
QItemSelectionModel selection;
public slots:
void reset();
signals:
void filtersChanged();
void filterSelected(Filter *filter);
void filterAdded(Filter *filter);
void filterRemoved(Filter *filter);
};
#endif // FILTERLIST_H

22
filters.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef FILTERS_H
#define FILTERS_H
#include "filters/blur.h"
#include "filters/channel.h"
#include "filters/convert.h"
#include "filters/edgedetect.h"
#include "filters/fourier.h"
#include "filters/histequalize.h"
#include "filters/kmeans.h"
#include "filters/maxchannel.h"
#include "filters/morph.h"
#include "filters/normalize.h"
#include "filters/pattern.h"
#include "filters/perspective.h"
#include "filters/shapedetect.h"
#include "filters/threshold.h"
#include "filters/undistort.h"
#include "filters/watershed.h"
#endif // FILTERS_H

55
filters/blur.cpp Normal file
View File

@ -0,0 +1,55 @@
#include <opencv2/imgproc.hpp>
#include "blur.h"
Blur::Blur(enum Type t, Size ks, double sp, double clr, double si, int bdr) :
type(t),
size(ks),
border(bdr),
sigma(si),
color(clr),
space(sp)
{
QMap<int, QString> mapType;
QMap<int, QString> mapBorder;
mapType[BILATERAL] = "Bilateral";
//mapType[BILATERAL_ADAPTIVE] = "Adaptive Bilateral";
mapType[BOX] = "Box";
mapType[BOX_NORMALIZED] = "Box Normalized";
mapType[GAUSSIAN] = "Gaussian";
mapType[MEDIAN] = "Median";
mapBorder[BORDER_DEFAULT] = "Default";
//mapBorder[BORDER_CONSTANT] = "Constant";
//mapBorder[BORDER_REPLICATE] = "Replicate";
mapBorder[BORDER_ISOLATED] = "Isolated";
mapBorder[BORDER_REFLECT] = "Reflect";
mapBorder[BORDER_REFLECT_101] = "Reflect 101";
mapBorder[BORDER_WRAP] = "Wrap";
settings["Type"] = new EnumSetting(this, (int&) type, mapType);
settings["Border"] = new EnumSetting(this, (int&) border, mapBorder);
settings["Kernel Size"] = new SizeSetting(this, size);
settings["Space"] = new DoubleSetting(this, space);
settings["Color"] = new DoubleSetting(this, color);
settings["Sigma"] = new DoubleSetting(this, sigma);
}
Result * Blur::applyInternal(Image *img)
{
Mat m = img->filtered.clone();
Mat &n = img->filtered;
switch (type) {
case BILATERAL: bilateralFilter(m, n, -1, space, color); break;
case BILATERAL_ADAPTIVE: break; // FIXME adaptiveBilateralFilter(m, n, size, color, space); break;
case BOX: boxFilter(m, n, -1, size, anchor, true, border); break;
case BOX_NORMALIZED: blur(m, n, size, anchor, border); break;
case GAUSSIAN: GaussianBlur(m, n, size, sigma, 0, border); break;
case MEDIAN: medianBlur(m, n, size.width); break;
}
return NULL;
}

36
filters/blur.h Normal file
View File

@ -0,0 +1,36 @@
#ifndef BLUR_H
#define BLUR_H
#include "filter.h"
class Blur : public Filter
{
public:
enum Type {
BILATERAL,
BILATERAL_ADAPTIVE,
BOX,
BOX_NORMALIZED,
GAUSSIAN,
MEDIAN
};
Blur(enum Type t, Size ks, double sp = 10, double clr = 20, double sigma = 2, int bdr = BORDER_DEFAULT);
QString getName() const { return "Blur"; }
protected:
Result * applyInternal(Image *img);
enum Blur::Type type;
Size size;
Point anchor = Point(-1, -1);
int border;
double sigma;
double color;
double space;
};
#endif // BLUR_H

22
filters/channel.cpp Normal file
View File

@ -0,0 +1,22 @@
#include <opencv2/imgproc.hpp>
#include "channel.h"
using namespace cv;
Channel::Channel(int ch) :
channel(ch)
{
settings["Channel"] = new IntegerSetting(this, channel);
}
Result * Channel::applyInternal(Image *img)
{
Mat channels[3];
split(img->filtered, channels);
img->filtered = channels[(int) channel];
return NULL;
}

19
filters/channel.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef CHANNEL_H
#define CHANNEL_H
#include "filter.h"
class Channel : public Filter
{
public:
Channel(int ch);
QString getName() const { return "Channel"; }
protected:
Result * applyInternal(Image *img);
int channel;
};
#endif // CHANNEL_H

28
filters/convert.cpp Normal file
View File

@ -0,0 +1,28 @@
#include "convert.h"
Convert::Convert(int c) :
Filter(),
code(c)
{
QMap<int, QString> mapCode;
mapCode[COLOR_BGR2HSV] = "BGR to HSV";
mapCode[COLOR_BGR2GRAY] = "BGR to Gray";
mapCode[COLOR_BGR2Lab] = "BGR to Lab";
mapCode[COLOR_BGR2Luv] = "BGR to Luv";
mapCode[COLOR_BGR2HLS] = "BGR to HLS";
mapCode[COLOR_BGR2YUV] = "BGR to YUV";
mapCode[COLOR_BGR2YCrCb]= "BGR to YCrCb";
// FIXME add more codes
settings["Code"] = new EnumSetting(this, code, mapCode);
}
Result * Convert::applyInternal(Image *img)
{
Mat dest;
cvtColor(img->filtered, dest, code);
img->filtered = dest;
return NULL;
}

19
filters/convert.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef CONVERT_H
#define CONVERT_H
#include "filter.h"
class Convert : public Filter
{
public:
Convert(int code);
QString getName() const { return "Convert"; }
protected:
Result * applyInternal(Image *img);
int code;
};
#endif // CONVERT_H

19
filters/edgedetect.cpp Normal file
View File

@ -0,0 +1,19 @@
#include "edgedetect.h"
#include <opencv2/imgproc.hpp>
EdgeDetect::EdgeDetect(double t, double r) :
threshold(t),
ratio(r)
{
settings["Threshold"] = new DoubleSetting(this, threshold);
settings["Ratio"] = new DoubleSetting(this, ratio);
}
Result * EdgeDetect::applyInternal(Image *img)
{
Canny(img->filtered, img->filtered, threshold, threshold * ratio);
return NULL;
}

20
filters/edgedetect.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef EDGEDETECT_H
#define EDGEDETECT_H
#include "filter.h"
class EdgeDetect : public Filter
{
public:
EdgeDetect(double t, double r);
QString getName() const { return "EdgeDetect"; }
protected:
Result * applyInternal(Image *img);
double threshold;
double ratio;
};
#endif // EDGEDETECT_H

40
filters/filter.cpp Normal file
View File

@ -0,0 +1,40 @@
#include <QElapsedTimer>
#include <QFormLayout>
#include "cast.h"
#include "filter.h"
using namespace cv;
Filter::~Filter()
{
delete widget;
}
QWidget * Filter::getWidget(QWidget *parent)
{
if (!widget) {
widget = new QWidget(parent);
QFormLayout *layout = new QFormLayout(widget);
layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
for (QString key : settings.keys())
layout->addRow(key, settings[key]->getWidget(widget));
}
return widget;
}
Result * Filter::apply(Image *img)
{
QElapsedTimer timer;
if (enabled) {
timer.start();
result = applyInternal(img); /* Virtual call */
time = timer.nsecsElapsed();
}
return result;
}

57
filters/filter.h Normal file
View File

@ -0,0 +1,57 @@
#ifndef FILTER_H
#define FILTER_H
#include <string>
#include <opencv2/core.hpp>
#include <QVector>
#include <QPainter>
#include <QWidget>
#include "painter.h"
#include "image.h"
#include "result.h"
#include "setting.h"
using namespace cv;
class Filter : public QObject
{
Q_OBJECT
public:
virtual ~Filter();
Result * apply(Image *img);
QWidget * getWidget(QWidget *parent = 0);
/* Setter */
void setEnabled(bool e) { enabled = e; }
void setShow(bool s) { show = s; }
/* Getter */
bool isEnabled() const { return enabled; }
bool isShown() const { return show; }
long getTime() const { return time; }
Result * getLastResult() const { return result; }
virtual QString getName() const = 0;
public slots:
virtual void reset() { }
signals:
void filterChanged();
protected:
bool enabled = true;
bool show = true;
long time = 0; /* in uSecs */
Result *result = NULL;
QWidget *widget = NULL;
QMap<QString, Setting*> settings;
virtual Result * applyInternal(Image *img) = 0;
};
#endif // FILTER_H

14
filters/fourier.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef FOURIER_H
#define FOURIER_H
#include "filter.h"
class Fourier : public Filter
{
public:
void apply(Image *img);
QString getName() const { return "Fourier"; }
};
#endif // FOURIER_H

8
filters/histequalize.cpp Normal file
View File

@ -0,0 +1,8 @@
#include "histequalize.h"
Result * HistEqualize::applyInternal(Image *img)
{
equalizeHist(img->filtered, img->filtered);
return NULL;
}

16
filters/histequalize.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef HISTEQUALIZE_H
#define HISTEQUALIZE_H
#include "filter.h"
class HistEqualize : public Filter
{
public:
QString getName() const { return "HistEqualize"; }
protected:
Result * applyInternal(Image *img);
};
#endif // HISTEQUALIZE_H

60
filters/kmeans.cpp Normal file
View File

@ -0,0 +1,60 @@
#include <QtDebug>
#include "kmeans.h"
using namespace std;
KMeans::KMeans(int km) :
k(km),
low(0),
high(k)
{
settings["K"] = new IntegerSetting(this, k, 1, 2*k);
settings["Low"] = new IntegerSetting(this, low, 0, 2*k-1,
"Only set pixels with a label higher or equal to this value.");
settings["High"] = new IntegerSetting(this, high, 0, 2*k,
"Only set Pixels with a label lower or equal to this value.");
}
void KMeans::reset()
{
labels.release();
}
Result * KMeans::applyInternal(Image *img)
{
Mat m = img->filtered.clone();
Mat reshaped_image, reshaped_image32f;
Mat centers, centers_u8;
int flags = KMEANS_RANDOM_CENTERS; //KMEANS_PP_CENTERS;
TermCriteria criteria = TermCriteria(TermCriteria::COUNT | TermCriteria::EPS, 4, 0.1);
reshaped_image = m.reshape(1, m.cols * m.rows);
reshaped_image.conv