Skip to content

Commit

Permalink
Initial commit of SMSLD repository
Browse files Browse the repository at this point in the history
  • Loading branch information
Big Smile committed Nov 30, 2013
1 parent 6fb0b0b commit 7e7088f
Show file tree
Hide file tree
Showing 223 changed files with 223,469 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Release/
Debug/
48 changes: 28 additions & 20 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
Copyright (c) 2013, Bart Verhagen
Copyright (c) 2013, Bart Verhagen, KU Leuven (University of Leuven, Belgium)
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the KU Leuven.
4. Neither the name of the KU Leuven nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

* Neither the name of the {organization} nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
THIS SOFTWARE IS PROVIDED BY KU LEUVEN ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
DISCLAIMED. IN NO EVENT SHALL KU LEUVEN BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.





Note: the enclosed software is based on the publication and implementation
of the MSLD descriptor by Zhiheng Wang ([email protected]), Fuchao Wu
and Zhanyi Hu.
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
SMSLD
=====
===== SOFTWARE =====
This software contains the SMSLD implementation as proposed by
Bart Verhagen, Radu Timofte ([email protected]) and
Luc Van Gool ([email protected]). The current implementation
is based on the MSLD implementation of Zhiheng Wang ([email protected]),
Fuchao Wu and Zhanyi Hu.

Repository for the SMSLD descriptor
This software contains the SMSLD descriptor. The SMSLD descriptor is a scale-invariant
line segment descriptor for wide baseline matching. More info can be found in the paper
about SMSLD.

All comments can be addressed to [email protected].

===== Requirements =====
- MATLAB
- OpenCV
- Preferably Microsoft Visual Studio

===== How to install =====
- Change the *.props files in SMSLD/opencv to point to your openCV implementation.
- Compile the SMSLD/SMSLD/SMSLD_Step2_Match/TianMatch.sln project using Visual Studio.
- Change in matlab/workspace/testbench/SMSLD/testSMSLD.m and
matlab/workspace/testbench/SMSLD/testBenchmark.m the 'path_to_exe' variable to
point to the binary created during the compilation of the TianMatch.sln project.
- Run testSMSLD using matlab.
21 changes: 21 additions & 0 deletions SMSLD/SMSLD/SMSLD_Step2_Match/810A~1/9E57~1.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//������С���˼�������
initM(MATCOM_VERSION);
Mm mMatrix = zeros(nCount,3);
for(int g1 = 0; g1 < nCount; g1++)
{
mMatrix.r(g1+1,1) = pLinePts[2*g1];
mMatrix.r(g1+1,2) = pLinePts[2*g1+1];
mMatrix.r(g1+1,3) = 1;
}

//����ֵ�ֽ��þ�ȷλ��
Mm u,s,v;
i_o_t i_o = {0,0};
svd(mMatrix,i_o,u,s,v);

//���㷽��
double a = v.r(1,3);
double b = v.r(2,3);

//�˳�
exitM();
Binary file added SMSLD/SMSLD/SMSLD_Step2_Match/810A~1/ago4500.dll
Binary file not shown.
Binary file added SMSLD/SMSLD/SMSLD_Step2_Match/810A~1/v4500v.dll
Binary file not shown.
Binary file added SMSLD/SMSLD/SMSLD_Step2_Match/810A~1/v4500v.lib
Binary file not shown.
280 changes: 280 additions & 0 deletions SMSLD/SMSLD/SMSLD_Step2_Match/Image.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
// Image.cpp -- Defination of the class Image.

#pragma once

#include "stdafx.h"
#include "Image.h"

Image::Image(void)
{
m_pixels = NULL;
}

Image::Image(int xDim, int yDim)
{
this->Allocate(xDim, yDim);
}

Image::Image(const Image &other)
{
this->Allocate(other.m_xDim, other.m_yDim);

for (int y=0; y<m_yDim; y++)
{
for (int x=0; x<m_xDim; x++)
{
m_pixels[y][x] = other.m_pixels[y][x];
}
}
}

Image::~Image(void)
{
this->DeAllocate();
}

Image & Image::operator =(const Image &other)
{
if (this == &other)
{
return *this;
}

this->ReAllocate(other.m_xDim, other.m_yDim);

for (int y=0; y<m_yDim; y++)
{
for (int x=0; x<m_xDim; x++)
{
m_pixels[y][x] = other.m_pixels[y][x];
}
}

return *this;
}

void Image::ReAllocate(int xDim, int yDim)
{
this->DeAllocate();
this->Allocate(xDim, yDim);
}

void Image::Allocate(int xDim, int yDim)
{
assert((xDim > 0) && (yDim > 0));

m_xDim = xDim;
m_yDim = yDim;

m_pixels = new double *[m_yDim];
if (m_pixels == NULL)
{
FatalError("Image -- Allocating memory fails!");
}
for (int y=0; y<m_yDim; y++)
{
m_pixels[y] = new double[m_xDim];
if (m_pixels[y] == NULL)
{
FatalError("Image -- Allocating memory fails!");
}
}
}

void Image::DeAllocate(void)
{
if (m_pixels != NULL)
{
for (int y=0; y<m_yDim; y++)
{
delete [] m_pixels[y];
}
delete []m_pixels;
}
}

/********************************************************************
So we can just use image(x, y) to indicate the pixel value
at position (x, y).
********************************************************************/
double & Image::operator ()(int x, int y)
{
assert((x >= 0) && (x < m_xDim) && (y >= 0) && (y < m_yDim));

return m_pixels[y][x];
}

int Image::GetXDim(void) const
{
return m_xDim;
}

int Image::GetYDim(void) const
{
return m_yDim;
}

/********************************************************************
Find the minimum to maximum range, then stretch and limit those
to exactly 0.0 to 1.0.
If both the minimum and maximum values are equal, no normalization
takes place.
********************************************************************/
void Image::Normalize(void)
{
double min = 1.0;
double max = 0.0;

for (int y=0; y<m_yDim; ++y)
{
for (int x=0; x<m_xDim; ++x)
{
if (min > m_pixels[y][x])
{
min = m_pixels[y][x];
}

if (max < m_pixels[y][x])
{
max = m_pixels[y][x];
}
}
}

if (min == max)
{
return;
}

double diff = max - min;

for (int y=0; y<m_yDim; ++y)
{
for (int x=0 ; x<m_xDim; ++x)
{
m_pixels[y][x] = (m_pixels[y][x] - min) / diff;
}
}
}

/********************************************************************
Downscale the image from size (x, y) to (x / 2, y / 2),
sampling pixels by a factor of 2.
********************************************************************/
Image Image::HalfScale(void)
{
if ((m_xDim / 2 == 0) || (m_yDim / 2 == 0))
{
//return *this;
FatalError("Too small image size, cannot half.");
}

Image res(m_xDim / 2, m_yDim / 2);

for (int y=0; y<res.m_yDim; y++)
{
for (int x=0; x<res.m_xDim; x++)
{
res.m_pixels[y][x] = this->m_pixels[2 * y][2 * x];
}
}

return res;
}

/********************************************************************
Double the image from size (x, y) to (x * 2 - 1, y * 2 - 1),
using linear interpolation.
********************************************************************/
Image Image::DoubleScale(void)
{
if ((m_xDim <= 1) || (m_yDim <= 1))
{
//return *this;
FatalError("Too small image size for doubling.");
}

Image res(m_xDim * 2 - 1, m_yDim * 2 - 1);

for (int y=0; y<(m_yDim-1); y++)
{
for (int x=0; x<(m_xDim-1); x++)
{
res(x * 2, y * 2) = this->m_pixels[y][x];
res(x * 2 + 1, y * 2) = 0.5 *
(this->m_pixels[y][x] + this->m_pixels[y][x + 1]);
res(x * 2, y * 2 + 1) = 0.5 *
(this->m_pixels[y][x] + this->m_pixels[y + 1][x]);
res(x * 2 + 1, y * 2 + 1) = 0.25 *
(this->m_pixels[y][x] + this->m_pixels[y + 1][x + 1] +
this->m_pixels[y][x + 1] + this->m_pixels[y + 1][x]);
}
}

for (int y=0; y<(m_yDim-1); y++)
{
res(m_xDim * 2 - 2, y * 2) = this->m_pixels[y][m_xDim - 1];
res(m_xDim * 2 - 2, y * 2 + 1) = 0.5 *
(this->m_pixels[y][m_xDim - 1] +
this->m_pixels[y + 1][m_xDim - 1]);
}

for (int x=0; x<(m_xDim-1); x++)
{
res(x * 2, m_yDim * 2 - 2) = this->m_pixels[m_yDim - 1][x];
res(x * 2 + 1, m_yDim * 2 - 2) = 0.5 *
(this->m_pixels[m_yDim - 1][x] +
this->m_pixels[m_yDim - 1][x + 1]);
}

res(m_xDim * 2 - 2, m_yDim * 2 - 2) =
this->m_pixels[m_yDim - 1][m_xDim - 1];

return res;
}

/*
Image operator -(Image &img1, Image &img2)
{
if ((img1.m_xDim != img2.m_xDim) || (img1.m_yDim != img2.m_yDim))
{
cerr << "Images have different sizes, can not subtract.\n";
exit(1);
}
Image res(img1.m_xDim, img1.m_yDim);
for (int y=0; y<img1.m_yDim; y++)
{
for (int x=0; x<img1.m_xDim; x++)
{
res(x, y) = img1(x, y) - img2(x, y);
}
}
return res;
}
*/

Image operator -(Image &img1, Image &img2)
{
int dimX = img1.GetXDim();
int dimY = img1.GetYDim();

if ((dimX != img2.GetXDim()) || (dimY != img2.GetYDim()))
{
FatalError("Images have different sizes, can not subtract.");
}

Image res(dimX, dimY);

for (int y=0; y<dimY; y++)
{
for (int x=0; x<dimX; x++)
{
res(x, y) = img1(x, y) - img2(x, y);
}
}

return res;
}
Loading

0 comments on commit 7e7088f

Please sign in to comment.