V2 begin
This commit is contained in:
parent
cae9dc0641
commit
60ff52a6e4
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 3.0.1, 2014-07-12T22:47:40. -->
|
<!-- Written by QtCreator 3.0.1, 2014-07-18T12:19:19. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||||
@ -53,7 +53,7 @@
|
|||||||
<valuemap type="QVariantMap">
|
<valuemap type="QVariantMap">
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{463a2572-9a8f-4eb1-bda2-3a5ffe83025f}</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.ActiveBuildConfiguration">0</value>
|
||||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||||
@ -229,7 +229,7 @@
|
|||||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">CSV</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">CSV</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/andrey/workspace/ComputerVision/CSV.pro</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.CommandLineArguments"></value>
|
||||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">CSV.pro</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.UseDyldImageSuffix">false</value>
|
||||||
@ -251,7 +251,7 @@
|
|||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
|
<variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
|
||||||
<value type="QByteArray">{dedf9f3d-a494-4afd-b37a-86d04bd971d6}</value>
|
<value type="QByteArray">{35059b80-6449-4cca-8333-a4525005f807}</value>
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||||
|
44
Main.qml
44
Main.qml
@ -174,11 +174,49 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Tab {
|
Tab {
|
||||||
id: pclView
|
id: leftImageView
|
||||||
title: "PCL View"
|
title: "Left Image"
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
anchors.fill: parent
|
Flickable {
|
||||||
|
anchors.fill: parent
|
||||||
|
contentWidth: image.width
|
||||||
|
contentHeight: image.height
|
||||||
|
interactive: true
|
||||||
|
anchors.margins: 2
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
Item {
|
||||||
|
Image {
|
||||||
|
id: leftImage
|
||||||
|
source: "image://images/left"
|
||||||
|
smooth: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Tab {
|
||||||
|
id: rightImageView
|
||||||
|
title: "Right Image"
|
||||||
|
|
||||||
|
Item {
|
||||||
|
Flickable {
|
||||||
|
anchors.fill: parent
|
||||||
|
contentWidth: image.width
|
||||||
|
contentHeight: image.height
|
||||||
|
interactive: true
|
||||||
|
anchors.margins: 2
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
Item {
|
||||||
|
Image {
|
||||||
|
id: rightImage
|
||||||
|
source: "image://images/right"
|
||||||
|
smooth: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
img/left4.png
BIN
img/left4.png
Binary file not shown.
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.1 MiB |
BIN
img/right4.png
BIN
img/right4.png
Binary file not shown.
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.1 MiB |
9
main.cpp
9
main.cpp
@ -15,14 +15,15 @@ int main(int argc, char *argv[])
|
|||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
SvImageProvider imageProvider;
|
SvImageProvider imageProvider;
|
||||||
|
|
||||||
QImage imgLeft("../ComputerVision/img/left4_.png");
|
QImage imgLeft("../CSV/img/left9.png");
|
||||||
QImage imgRight("../ComputerVision/img/right4_.png");
|
QImage imgRight("../CSV/img/right.png");
|
||||||
QImage imgStereo(imgLeft.width(), imgRight.height(), QImage::Format_RGB32);
|
QImage imgStereo(imgLeft.width(), imgLeft.height(), QImage::Format_RGB32);
|
||||||
|
|
||||||
SvImage left(imgLeft);
|
SvImage left(imgLeft);
|
||||||
SvImage right(imgRight);
|
SvImage right(imgRight);
|
||||||
SvImage stereo(imgStereo);
|
SvImage stereo(imgStereo);
|
||||||
SvProcessor proc(&left, &right, &stereo, 4);
|
|
||||||
|
SvProcessor proc(&left, &right, &stereo, 4, 2);
|
||||||
|
|
||||||
imageProvider.addImage("left", &left);
|
imageProvider.addImage("left", &left);
|
||||||
imageProvider.addImage("right", &right);
|
imageProvider.addImage("right", &right);
|
||||||
|
31
svimage.cpp
31
svimage.cpp
@ -53,7 +53,23 @@ int SvImage::getPixelValue(int x, int y) {
|
|||||||
return color.value();
|
return color.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SvImage::putPixel(int x, int y, int value)
|
int SvImage::getPixelSaturation(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.saturation();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SvImage::putGrayPixel(int x, int y, int value)
|
||||||
{
|
{
|
||||||
if (y >= m_image->height() ||
|
if (y >= m_image->height() ||
|
||||||
y < 0 ||
|
y < 0 ||
|
||||||
@ -66,6 +82,19 @@ void SvImage::putPixel(int x, int y, int value)
|
|||||||
m_image->setPixel(x, y, qRgb(value, value, value));
|
m_image->setPixel(x, y, qRgb(value, value, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SvImage::putPixel(int x, int y, int red, int green, int blue)
|
||||||
|
{
|
||||||
|
if (y >= m_image->height() ||
|
||||||
|
y < 0 ||
|
||||||
|
x >= m_image->width()
|
||||||
|
|| x < 0) {
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_image->setPixel(x, y, qRgb(red, green, blue));
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int SvImage::getHeight() {
|
unsigned int SvImage::getHeight() {
|
||||||
return m_image->height();
|
return m_image->height();
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,9 @@ public:
|
|||||||
int getPixel(int x, int y, int channel);
|
int getPixel(int x, int y, int channel);
|
||||||
int getPixelHue(int x, int y);
|
int getPixelHue(int x, int y);
|
||||||
int getPixelValue(int x, int y);
|
int getPixelValue(int x, int y);
|
||||||
void putPixel(int x, int y, int val);
|
int getPixelSaturation(int x, int y);
|
||||||
|
void putGrayPixel(int x, int y, int val);
|
||||||
|
void putPixel(int x, int y, int red, int green, int blue);
|
||||||
|
|
||||||
unsigned int getHeight();
|
unsigned int getHeight();
|
||||||
unsigned int getWidth();
|
unsigned int getWidth();
|
||||||
|
@ -22,21 +22,30 @@ int SvKernelV1::getPixelColor(int cursor)
|
|||||||
|
|
||||||
int SvKernelV1::diff(int lx, int ly, int rx, int ry)
|
int SvKernelV1::diff(int lx, int ly, int rx, int ry)
|
||||||
{
|
{
|
||||||
int Rvalue, Gvalue, Bvalue, color;
|
int Red, Green, Blue, color;
|
||||||
|
|
||||||
Rvalue = abs(m_left->getPixel(lx, ly, 0) - m_right->getPixel(rx, ry, 0));
|
int Lvalue = m_left->getPixelValue(lx, ly);
|
||||||
Gvalue = abs(m_left->getPixel(lx, ly, 1) - m_right->getPixel(rx, ry, 1));
|
int Rvalue = m_right->getPixelValue(rx, ry);
|
||||||
Bvalue = abs(m_left->getPixel(lx, ly, 2) - m_right->getPixel(rx, ry, 2));
|
|
||||||
color = abs(Gvalue - Rvalue) + abs(Bvalue - Gvalue);
|
|
||||||
|
|
||||||
return (Gvalue + Rvalue + Bvalue) +
|
int dLvalue = m_left->getPixelValue(rx - 1, ry) - Lvalue;
|
||||||
color << 2;
|
int dRvalue = m_right->getPixelValue(rx - 1, ry) - Rvalue;
|
||||||
|
|
||||||
|
int dLsign = dLvalue >= 0 ? 1 : -1;
|
||||||
|
int dRsign = dRvalue >= 0 ? 1 : -1;
|
||||||
|
|
||||||
|
Red = abs(m_left->getPixel(lx, ly, 0) - m_right->getPixel(rx, ry, 0));
|
||||||
|
Green = abs(m_left->getPixel(lx, ly, 1) - m_right->getPixel(rx, ry, 1));
|
||||||
|
Blue = abs(m_left->getPixel(lx, ly, 2) - m_right->getPixel(rx, ry, 2));
|
||||||
|
color = abs(Green - Red) + abs(Blue - Green);
|
||||||
|
|
||||||
|
return ((Green + Red + Blue) +
|
||||||
|
color << 2) + (dLsign == dRsign ? 0 : 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SvKernelV1::match(int x, int y, int j)
|
int SvKernelV1::match(int x, int y, int j)
|
||||||
{
|
{
|
||||||
int error = 0;
|
int error = 0;
|
||||||
int ms = 4;
|
int ms = 5;
|
||||||
int c = diff(x, y, x + j, y),
|
int c = diff(x, y, x + j, y),
|
||||||
l = 0, r = 0, t = 0, b = 0;
|
l = 0, r = 0, t = 0, b = 0;
|
||||||
|
|
||||||
@ -73,7 +82,7 @@ void SvKernelV1::exec(int line)
|
|||||||
dist = (abs(cursor - i));
|
dist = (abs(cursor - i));
|
||||||
|
|
||||||
tmp = match(x, line, i);
|
tmp = match(x, line, i);
|
||||||
tmpSmoothed = tmp + dist;
|
tmpSmoothed = tmp;
|
||||||
|
|
||||||
if (tmpSmoothed < minErrorValue || minErrorValue == -1) {
|
if (tmpSmoothed < minErrorValue || minErrorValue == -1) {
|
||||||
minErrorValue = tmpSmoothed;
|
minErrorValue = tmpSmoothed;
|
||||||
@ -91,6 +100,6 @@ void SvKernelV1::exec(int line)
|
|||||||
cursor = closest;
|
cursor = closest;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_result->putPixel(x/* + cursor*/, line, getPixelColor(cursor));
|
m_result->putGrayPixel(x/* + cursor*/, line, getPixelColor(cursor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ class SvKernelV1: public SvAbstractKernel
|
|||||||
{
|
{
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int m_windowSize = 80;
|
int m_windowSize = 150;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void exec(int line) override;
|
void exec(int line) override;
|
||||||
|
@ -11,6 +11,94 @@ SvKernelV2::~SvKernelV2()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SvKernelV2::exec(int line)
|
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;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
dHue = _hue - hue;
|
||||||
|
dSaturation = _saturation - saturation;
|
||||||
|
dValue = _value - value;
|
||||||
|
|
||||||
|
int m1 = m_left->getPixelValue(x, line - 1);
|
||||||
|
int m2 = m_left->getPixelValue(x, line - 2);
|
||||||
|
int m3 = m_left->getPixelValue(x, line - 3);
|
||||||
|
|
||||||
|
int dY = m1-value;
|
||||||
|
int _dY = m2-m1;
|
||||||
|
int __dY = m3-m2;
|
||||||
|
|
||||||
|
int hV = 0;
|
||||||
|
|
||||||
|
if (((_dValue > dValue && _dValue > __dValue) ||
|
||||||
|
(_dValue < dValue && _dValue < __dValue))) {
|
||||||
|
|
||||||
|
hV = abs(_dValue);
|
||||||
|
m_result->putGrayPixel(x, line, abs(_dValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((_dY > dY && _dY > __dY) ||
|
||||||
|
(_dY < dY && _dY < __dY))) {
|
||||||
|
if (abs(_dY) > hV) {
|
||||||
|
m_result->putGrayPixel(x, line - 2, abs(_dY));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
__hue = _hue;
|
||||||
|
__value = _value;
|
||||||
|
__saturation = _saturation;
|
||||||
|
|
||||||
|
_hue = hue;
|
||||||
|
_value = value;
|
||||||
|
_saturation = saturation;
|
||||||
|
|
||||||
|
__dValue = _dValue;
|
||||||
|
_dValue = dValue;
|
||||||
|
|
||||||
|
__dSaturation = _dSaturation;
|
||||||
|
_dSaturation = dSaturation;
|
||||||
|
|
||||||
|
__dHue = _dHue;
|
||||||
|
_dHue = dHue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
79
svkernelv2.h
79
svkernelv2.h
@ -3,12 +3,91 @@
|
|||||||
|
|
||||||
#include "svabstractkernel.h"
|
#include "svabstractkernel.h"
|
||||||
|
|
||||||
|
#define sign(a) (a == 0 ? 0 : (a > 0 ? 1 : -1))
|
||||||
|
|
||||||
class SvKernelV2: public SvAbstractKernel
|
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:
|
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();
|
SvKernelV2();
|
||||||
virtual ~SvKernelV2();
|
virtual ~SvKernelV2();
|
||||||
void exec(int line) override;
|
void exec(int line) override;
|
||||||
|
|
||||||
|
int max(int x, int y);
|
||||||
|
unsigned int figureType(int x, int y, int level);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SVKERNELV2_H
|
#endif // SVKERNELV2_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user