This commit is contained in:
Andrey Tkachenko 2014-07-22 20:37:29 +04:00
parent 16cd697457
commit 5ab294bfa8
23 changed files with 251 additions and 428 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
CSV.pro.user

15
CSV.pro
View File

@ -9,6 +9,7 @@ TEMPLATE = app
TARGET = CSV
CONFIG += c++11
CONFIG += j4
CONFIG -= console
SOURCES += main.cpp \
@ -17,7 +18,12 @@ SOURCES += main.cpp \
svprocessor.cpp \
svkernelv1.cpp \
svkernelv2.cpp \
svimageprovider.cpp
svimageprovider.cpp \
svpoint.cpp \
svcurve.cpp \
svsimplepoint.cpp \
svfigure.cpp \
svobject.cpp
HEADERS += \
svimage.h \
@ -26,7 +32,12 @@ HEADERS += \
svabstractkernel.h \
svkernelv1.h \
svkernelv2.h \
svimageprovider.h
svimageprovider.h \
svpoint.h \
svcurve.h \
svsimplepoint.h \
svfigure.h \
svobject.h
RESOURCES += \
resource.qrc

View File

@ -1,260 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.0.1, 2014-07-18T12:19:19. -->
<qtcreator>
<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">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</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="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</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</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{7246c6ab-7a87-4118-a487-ab344a31d36b}</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">/home/andrey/workspace/build-CSV-Desktop-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>
</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">Clean</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">/home/andrey/workspace/build-CSV-Desktop-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>
</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">Clean</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">Deploy</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">Deploy locally</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">CSV</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/andrey/workspace/CSV/CSV.pro</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">CSV.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"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</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.EnvironmentId</variable>
<value type="QByteArray">{35059b80-6449-4cca-8333-a4525005f807}</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">15</value>
</data>
</qtcreator>

View File

@ -20,7 +20,7 @@ ApplicationWindow {
Connections {
target: processor
onFinished: {
statusBarState.text = "Ready";
statusBarState.text = "Ready " + elapsedTime;
}
}

View File

@ -15,8 +15,8 @@ int main(int argc, char *argv[])
QQmlApplicationEngine engine;
SvImageProvider imageProvider;
QImage imgLeft("../CSV/img/left9.png");
QImage imgRight("../CSV/img/right.png");
QImage imgLeft("../ComputerVision/img/left.png");
QImage imgRight("../ComputerVision/img/right4.png");
QImage imgStereo(imgLeft.width(), imgLeft.height(), QImage::Format_RGB32);
SvImage left(imgLeft);

5
svcurve.cpp Normal file
View File

@ -0,0 +1,5 @@
#include "svcurve.h"
SvCurve::SvCurve()
{
}

19
svcurve.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef SVCURVE_H
#define SVCURVE_H
#include "svpoint.h"
class SvPoint;
class SvCurve
{
protected:
SvPoint *m_ends;
SvPoint *m_points;
SvSimplePoint *m_keyPoints;
public:
SvCurve();
};
#endif // SVCURVE_H

5
svfigure.cpp Normal file
View File

@ -0,0 +1,5 @@
#include "svfigure.h"
SvFigure::SvFigure()
{
}

17
svfigure.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef SVFIGURE_H
#define SVFIGURE_H
#include "svpoint.h"
#include "svcurve.h"
class SvFigure
{
protected:
SvPoint ends[2];
public:
SvFigure();
};
#endif // SVFIGURE_H

View File

@ -1,6 +1,6 @@
#include "svimage.h"
int SvImage::getPixel(int x, int y, int channel = -1) {
int SvImage::getPixel(int x, int y, int channel) {
if (y >= m_image->height() ||
y < 0 ||
x >= m_image->width()
@ -23,6 +23,21 @@ int SvImage::getPixel(int x, int y, int channel = -1) {
}
}
int SvImage::getPixelNormalizedHue(int x, int y) {
if (y >= m_image->height() ||
y < 0 ||
x >= m_image->width()
|| x < 0) {
return 0;
}
QRgb rgb = m_image->pixel(x, y);
QColor color(rgb);
return (color.hsvHue() * getPixelSaturation(x, y)) / 255;
}
int SvImage::getPixelHue(int x, int y) {
if (y >= m_image->height() ||
y < 0 ||
@ -35,7 +50,7 @@ int SvImage::getPixelHue(int x, int y) {
QRgb rgb = m_image->pixel(x, y);
QColor color(rgb);
return color.hue();
return color.hsvHue();
}
int SvImage::getPixelValue(int x, int y) {
@ -69,6 +84,19 @@ int SvImage::getPixelSaturation(int x, int y)
return color.saturation();
}
QRgb SvImage::getPixelRGB(int x, int y)
{
if (y >= m_image->height() ||
y < 0 ||
x >= m_image->width()
|| x < 0) {
return 0;
}
return m_image->pixel(x, y);
}
void SvImage::putGrayPixel(int x, int y, int value)
{
if (y >= m_image->height() ||
@ -79,6 +107,10 @@ void SvImage::putGrayPixel(int x, int y, int value)
return;
}
if (value > 255) {
value = 255;
}
m_image->setPixel(x, y, qRgb(value, value, value));
}

View File

@ -11,10 +11,12 @@ protected:
QImage* m_image;
public:
int getPixel(int x, int y, int channel);
int getPixel(int x, int y, int channel = -1);
int getPixelHue(int x, int y);
int getPixelNormalizedHue(int x, int y);
int getPixelValue(int x, int y);
int getPixelSaturation(int x, int y);
QRgb getPixelRGB(int x, int y);
void putGrayPixel(int x, int y, int val);
void putPixel(int x, int y, int red, int green, int blue);

View File

@ -74,7 +74,7 @@ void SvKernelV1::exec(int line)
cursor = 0;
for (x = 0; x < m_result->getWidth(); x++) {
for (x = 0; x < m_result->getWidth(); x+=1) {
closest = -1; minErrorValue = -1;matched=0;
minErrorValue=-1;

View File

@ -7,7 +7,7 @@ class SvKernelV1: public SvAbstractKernel
{
protected:
int m_windowSize = 150;
int m_windowSize = 160;
public:
void exec(int line) override;

View File

@ -10,95 +10,71 @@ SvKernelV2::~SvKernelV2()
}
int SvKernelV2::rgbDiff(QRgb left, QRgb right)
{
QColor cLeft(left);
QColor cRight(right);
int leftDiff = max(qBlue(left), qRed(left), qGreen(left)) -
min(qBlue(left), qRed(left), qGreen(left));
int rightDiff = max(qBlue(right), qRed(right), qGreen(right)) -
min(qBlue(right), qRed(right), qGreen(right));
int minDiff= leftDiff < rightDiff ? rightDiff : leftDiff;
int diff = cLeft.value() - cRight.value();
int hsvDiff = abs(cLeft.hsvHue() - cRight.hsvHue());
if (hsvDiff > 180) {
hsvDiff = 360 - hsvDiff;
}
return (rightDiff - leftDiff) + diff; /*diff + (minDiff > 20 ? sign(diff) * hsvDiff : 0)*/;
}
void SvKernelV2::exec(int line)
{
int hue, value, saturation;
int _hue, _value, _saturation;
int __hue, __value, __saturation;
int dValue, dHue, dSaturation;
int tValue, tHue, tSaturation;
int _dValue, __dValue;
int _dSaturation, __dSaturation;
int _dHue, __dHue;
QRgb vtop, top, right, bottom, _xy, xy;
int dX, _dX, dX_,
dY, _dY, dY_;
int value;
for (int x = 0; x < m_result->getWidth(); x++) {
hue = m_left->getPixelHue(x, line);
value = m_left->getPixelValue(x, line);
saturation = m_left->getPixelSaturation(x, line);
value = 0;
dHue = _hue - hue;
dSaturation = _saturation - saturation;
dValue = _value - value;
vtop = m_left->getPixelRGB(x - 1, line - 3);
top = m_left->getPixelRGB(x - 1, line - 2);
right = m_left->getPixelRGB(x, line - 1);
bottom = m_left->getPixelRGB(x - 1, line);
xy = m_left->getPixelRGB(x - 1, line - 1);
int m1 = m_left->getPixelValue(x, line - 1);
int m2 = m_left->getPixelValue(x, line - 2);
int m3 = m_left->getPixelValue(x, line - 3);
dX_ = rgbDiff(_xy, right);
dY_ = rgbDiff(vtop, top);
dY = rgbDiff(top, _xy);
_dY = rgbDiff(_xy, bottom);
int dY = m1-value;
int _dY = m2-m1;
int __dY = m3-m2;
int hV = 0;
if ( dX > _dX && dX > dX_ ||
dX < _dX && dX < dX_) {
if (((_dValue > dValue && _dValue > __dValue) ||
(_dValue < dValue && _dValue < __dValue))) {
hV = abs(_dValue);
m_result->putGrayPixel(x, line, abs(_dValue));
value += abs(dX);
}
if (((_dY > dY && _dY > __dY) ||
(_dY < dY && _dY < __dY))) {
if (abs(_dY) > hV) {
m_result->putGrayPixel(x, line - 2, abs(_dY));
}
if ( dY > _dY && dY > dY_ ||
dY < _dY && dY < dY_) {
value += abs(dY);
}
__hue = _hue;
__value = _value;
__saturation = _saturation;
if (value > 0) {
m_result->putGrayPixel(x - 1, line - 1, value);
}
_hue = hue;
_value = value;
_saturation = saturation;
__dValue = _dValue;
_dValue = dValue;
__dSaturation = _dSaturation;
_dSaturation = dSaturation;
__dHue = _dHue;
_dHue = dHue;
_dX = dX;
dX = dX_;
_xy = right;
}
}
int SvKernelV2::getPixelValueByBit(int bit)
{
}
unsigned int SvKernelV2::figureType(int x, int y, int level)
{
unsigned char typeCode, resultType;
int result, error = -1;
for (int type = 1; type < 20; type++) {
typeCode = m_figures[type - 1];
result = 0;
for (int bit = 0; bit < 9; bit++) {
value = getPixelValueByBit(bit);
if (typeCode & (1 << bit)) {
result += abs(level - value);
} else {
result += value;
}
}
if (error > result || error == -1) {
resultType = type;
error = result;
}
}
return (error << 5) | resultType;
}

View File

@ -2,92 +2,18 @@
#define SVKERNELV2_H
#include "svabstractkernel.h"
#include <QDebug>
#define sign(a) (a == 0 ? 0 : (a > 0 ? 1 : -1))
#define max(a,b,c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define min(a,b,c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
class SvKernelV2: public SvAbstractKernel
{
private:
unsigned short* m_figures = {
0b000111000, // TYPE_0
0b100011000, // TYPE_11_1
0b110011000, // TYPE_22_2_1
0b000110011, // TYPE_22_2_2
0b000110001, // TYPE_33_3
0b100010001, // TYPE_45
0b010010001, // TYPE_56_1
0b100110010, // TYPE_67_2_1
0b010011001, // TYPE_67_2_2
0b100010010, // TYPE_78_3
0b010010010, // TYPE_90
0b001010010, // TYPE_101_1
0b001011010, // TYPE_112_2_1
0b010110100, // TYPE_112_2_2
0b010010100, // TYPE_123_3
0b001010100, // TYPE_135
0b000011100, // TYPE_146_1
0b000011110, // TYPE_157_2_1
0b011110000, // TYPE_157_2_2
0b001110000, // TYPE_168_3
};
public:
enum FigureType {
TYPE_NONE = 0,
TYPE_0, // 000
// 111
// 000
TYPE_11_1, // 100
// 011
// 000
TYPE_22_2_1,// 110
// 011
// 000
TYPE_22_2_2,// 000
// 110
// 011
TYPE_33_3, // 000
// 110
// 001
TYPE_45, // 100
// 010
// 001
TYPE_56_1, // 010
// 010
// 001
TYPE_67_2_1,
TYPE_67_2_2,
TYPE_78_3,
TYPE_90,
TYPE_101_1,
TYPE_112_2_1,
TYPE_112_2_2,
TYPE_123_3,
TYPE_135,
TYPE_146_1,
TYPE_157_2_1,
TYPE_157_2_2,
TYPE_168_3
};
SvKernelV2();
virtual ~SvKernelV2();
void exec(int line) override;
int max(int x, int y);
unsigned int figureType(int x, int y, int level);
int rgbDiff(QRgb left, QRgb right);
};
#endif // SVKERNELV2_H

5
svobject.cpp Normal file
View File

@ -0,0 +1,5 @@
#include "svobject.h"
SvObject::SvObject()
{
}

15
svobject.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef SVOBJECT_H
#define SVOBJECT_H
#include "svfigure.h"
class SvObject
{
protected:
SvFigure *m_figures;
public:
SvObject();
};
#endif // SVOBJECT_H

5
svpoint.cpp Normal file
View File

@ -0,0 +1,5 @@
#include "svpoint.h"
SvPoint::SvPoint()
{
}

34
svpoint.h Normal file
View File

@ -0,0 +1,34 @@
#ifndef SVPOINT_H
#define SVPOINT_H
#include "svsimplepoint.h"
#include "svcurve.h"
class SvCurve;
class SvPoint: public SvSimplePoint
{
public:
enum Sides {
TOP,
BOTTOM,
RIGHT,
LEFT
};
enum FlowType {
HORIZONTAL,
VERTICAL,
SLASH,
BACK_SLASH
};
protected:
SvCurve* m_curves;
FlowType m_type;
public:
SvPoint();
};
#endif // SVPOINT_H

View File

@ -49,7 +49,7 @@ void SvProcessor::workerFinished(int workerId)
m_workersFinished++;
if (m_workersFinished == m_numberOfWorkers) {
qDebug() << "finished";
emit finished(m_startTime - 0);
emit finished(time(NULL) - m_startTime);
}
}
@ -57,15 +57,15 @@ void SvProcessor::start()
{
unsigned int i;
m_startTime = 0;
m_startTime = time(NULL);
m_workersFinished = 0;
for (i = 0; i < m_numberOfWorkers; i++) {
m_threads[i].start();
m_threads[i].start(QThread::HighestPriority);
}
}
void SvProcessor::stop()
{
emit stopped(m_startTime - 0);
emit stopped(time(NULL) - m_startTime);
}

View File

@ -1,6 +1,8 @@
#ifndef SVPROCESSOR_H
#define SVPROCESSOR_H
#include <time.h>
#include<QObject>
#include<QThread>
#include<QDebug>
@ -21,7 +23,7 @@ protected:
SvAbstractKernel* m_kernel;
unsigned int m_numberOfWorkers;
unsigned int m_workersFinished;
int m_startTime;
unsigned int m_startTime;
public:
explicit SvProcessor(QObject *parent = 0);

5
svsimplepoint.cpp Normal file
View File

@ -0,0 +1,5 @@
#include "svsimplepoint.h"
SvSimplePoint::SvSimplePoint()
{
}

23
svsimplepoint.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef SVSIMPLEPOINT_H
#define SVSIMPLEPOINT_H
class SvSimplePoint
{
protected:
int m_px, m_py, m_pz;
public:
int x() {return m_px;}
int y() {return m_py;}
int z() {return m_pz;}
int setX(int px) {return m_px = px;}
int setY(int py) {return m_py = py;}
int setZ(int pz) {return m_pz = pz;}
SvSimplePoint();
};
#endif // SVSIMPLEPOINT_H