Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Remote Modules
fast-lsd
Commits
387dc721
Commit
387dc721
authored
Feb 06, 2018
by
Yannick TANGUY
Browse files
Unused files are removed -> they may be part of another RM
parent
7b4c31b1
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/CMakeLists.txt
View file @
387dc721
...
...
@@ -2,8 +2,6 @@ OTB_CREATE_APPLICATION(
NAME LsdCmla
SOURCES
otbLSDCMLA.cxx
ParallelSegmentsDetector.cxx
RightAnglesDetector.cxx
LINK_LIBRARIES
${${
otb-module
}
_LIBRARIES
}
${
OTBCommon_LIBRARIES
}
${
OTBApplicationEngine_LIBRARIES
}
}
)
...
...
app/ParallelSegmentsDetector.cxx
deleted
100644 → 0
View file @
7b4c31b1
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "otbVectorData.h"
#include "otbVectorDataFileReader.h"
#include "otbVectorDataFileWriter.h"
#include "otbVectorDataToAlignVectorDataFilter.h"
#include "otbStandardWriterWatcher.h"
#include <time.h>
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
6
)
{
std
::
cerr
<<
"Usage: "
<<
argv
[
0
]
<<
"infname alignshape_name "
;
std
::
cerr
<<
"angleThreshold distanceThreshold lengthThreshold"
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
const
char
*
infname
=
argv
[
1
];
const
char
*
alignshape_name
=
argv
[
2
];
double
angleThreshold
=
atof
(
argv
[
3
]);
double
distanceThreshold
=
atof
(
argv
[
4
]);
double
lengthThreshold
=
atof
(
argv
[
5
]);
//double ratioThreshold = atof(argv[7]);
time_t
begin
,
end
;
time
(
&
begin
);
const
unsigned
int
Dimension
=
2
;
typedef
unsigned
char
PixelType
;
typedef
double
PrecisionType
;
typedef
otb
::
VectorData
<
PrecisionType
>
VectorDataType
;
typedef
otb
::
VectorDataFileReader
<
VectorDataType
>
VectorDataReaderType
;
typedef
otb
::
VectorDataFileWriter
<
VectorDataType
>
VectorDataWriterType
;
VectorDataReaderType
::
Pointer
vreader
=
VectorDataReaderType
::
New
();
vreader
->
SetFileName
(
infname
);
vreader
->
GenerateOutputInformation
();
VectorDataWriterType
::
Pointer
shapeWriter
=
VectorDataWriterType
::
New
();
typedef
otb
::
VectorDataToAlignVectorDataFilter
<
VectorDataType
>
AlignFilterType
;
AlignFilterType
::
Pointer
alignFilter
=
AlignFilterType
::
New
();
alignFilter
->
SetInput
(
vreader
->
GetOutput
());
alignFilter
->
SetAngleThreshold
(
angleThreshold
);
alignFilter
->
SetDistanceThreshold
(
distanceThreshold
);
alignFilter
->
SetLengthThreshold
(
lengthThreshold
);
//alignFilter->SetRatioThreshold(ratioThreshold);
shapeWriter
->
SetInput
(
alignFilter
->
GetOutput
());
shapeWriter
->
SetFileName
(
alignshape_name
);
shapeWriter
->
Update
();
time
(
&
end
);
double
temps
=
difftime
(
end
,
begin
);
int
heures
=
temps
/
3600
;
int
minutes
=
heures
*
60
;
int
secondes
=
minutes
*
60
;
std
::
cout
<<
"
\n
l'execution du programme "
<<
argv
[
0
]
<<
" à duré "
<<
temps
<<
" secondes
\n
"
<<
std
::
endl
;
return
EXIT_SUCCESS
;
}
app/RightAnglesDetector.cxx
deleted
100644 → 0
View file @
7b4c31b1
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "otbVectorData.h"
#include "otbVectorDataFileReader.h"
#include "otbVectorDataFileWriter.h"
#include "otbVectorDataToRightAngleVectorDataFilter.h"
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
5
)
{
std
::
cerr
<<
"Usage: "
<<
argv
[
0
]
<<
" infname outfname "
;
std
::
cerr
<<
"angleThreshold distanceThreshold"
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
const
char
*
infname
=
argv
[
1
];
const
char
*
outfname
=
argv
[
2
];
double
angleThreshold
=
atof
(
argv
[
3
]);
double
distanceThreshold
=
atof
(
argv
[
4
]);
typedef
otb
::
VectorData
<>
VectorDataType
;
typedef
otb
::
VectorDataFileReader
<
VectorDataType
>
ReaderType
;
typedef
otb
::
VectorDataFileWriter
<
VectorDataType
>
WriterType
;
ReaderType
::
Pointer
reader
=
ReaderType
::
New
();
reader
->
SetFileName
(
infname
);
reader
->
GenerateOutputInformation
();
WriterType
::
Pointer
writer
=
WriterType
::
New
();
typedef
otb
::
VectorDataToRightAngleVectorDataFilter
<
VectorDataType
>
RightAngleFilterType
;
RightAngleFilterType
::
Pointer
rightAngleFilter
=
RightAngleFilterType
::
New
();
rightAngleFilter
->
SetInput
(
reader
->
GetOutput
());
rightAngleFilter
->
SetAngleThreshold
(
angleThreshold
);
rightAngleFilter
->
SetDistanceThreshold
(
distanceThreshold
);
writer
->
SetInput
(
rightAngleFilter
->
GetOutput
());
writer
->
SetFileName
(
outfname
);
writer
->
Update
();
return
EXIT_SUCCESS
;
}
include/otbVectorDataToAlignVectorDataFilter.h
deleted
100644 → 0
View file @
7b4c31b1
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbVectorDataToAlignVectorDataFilter_h
#define __otbVectorDataToAlignVectorDataFilter_h
#include "otbVectorDataToVectorDataFilter.h"
#include "itkPreOrderTreeIterator.h"
#include "otbMath.h"
namespace
otb
{
/** \class VectorDataToAlignVectorDataFilter
* \brief parallels segments detector
*
* This filter aims at detecting parallels segments
* included in the input VectorData. It outputs a vector data
* containing parallels segments.
*
* The entire input vector data will be processed concidering the two
* firsts vertex of each line features as a segment.
*
*
*/
template
<
class
TVectorData
>
class
ITK_EXPORT
VectorDataToAlignVectorDataFilter
:
public
otb
::
VectorDataToVectorDataFilter
<
TVectorData
,
TVectorData
>
{
public:
/** Standard class typedefs. */
typedef
VectorDataToAlignVectorDataFilter
Self
;
typedef
VectorDataToVectorDataFilter
<
TVectorData
,
TVectorData
>
Superclass
;
typedef
itk
::
SmartPointer
<
Self
>
Pointer
;
typedef
itk
::
SmartPointer
<
const
Self
>
ConstPointer
;
/** Method for creation through the object factory. */
itkNewMacro
(
Self
);
/** Run-time type information (and related methods). */
itkTypeMacro
(
VectorDataToAlignVectorDataFilter
,
VectorDataToVectorDataFilter
);
/** Typedef support for ProcessObject*/
typedef
itk
::
ProcessObject
ProcessObjectType
;
/** Typdedef support for the VectroData*/
typedef
TVectorData
VectorDataType
;
typedef
typename
VectorDataType
::
DataNodeType
DataNodeType
;
typedef
typename
VectorDataType
::
LineType
LineType
;
typedef
typename
VectorDataType
::
PointType
PointType
;
typedef
typename
LineType
::
VertexType
VertexType
;
typedef
typename
LineType
::
VertexListType
VertexListType
;
typedef
itk
::
PreOrderTreeIterator
<
typename
VectorDataType
::
DataTreeType
>
TreeIteratorType
;
/** Set/Get the thresholds*/
itkGetMacro
(
DistanceThreshold
,
double
);
itkSetMacro
(
DistanceThreshold
,
double
);
itkGetMacro
(
AngleThreshold
,
double
);
itkSetMacro
(
AngleThreshold
,
double
);
itkGetMacro
(
LengthThreshold
,
double
);
itkSetMacro
(
LengthThreshold
,
double
);
itkGetMacro
(
RatioThreshold
,
double
);
itkSetMacro
(
RatioThreshold
,
double
);
protected:
/** Constructor.*/
VectorDataToAlignVectorDataFilter
();
/**Destructor.*/
virtual
~
VectorDataToAlignVectorDataFilter
(){}
/** Standard PrintSelf method.*/
virtual
void
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
;
/**Main computation method.*/
virtual
void
GenerateData
();
/**Angle computation.*/
virtual
double
ComputeAngleFormedBySegments
(
LineType
*
lineDst
,
LineType
*
lineSrc
);
/**Compute the orientation of a segment*/
virtual
double
ComputeOrientation
(
LineType
*
line
);
/**Minimum and maximum Distance between two segment lines.*/
virtual
std
::
pair
<
double
,
double
>
ComputeDistanceFromSegmentToSegment
(
LineType
*
lineDst
,
LineType
*
lineSrc
);
/**Compute the length of a segment line*/
virtual
double
ComputeSegmentLength
(
LineType
*
line
);
private:
VectorDataToAlignVectorDataFilter
(
const
Self
&
);
//purposely not implemented
void
operator
=
(
const
Self
&
);
//purposely not implemented
double
m_DistanceThreshold
;
double
m_AngleThreshold
;
double
m_LengthThreshold
;
double
m_RatioThreshold
;
};
}
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbVectorDataToAlignVectorDataFilter.txx"
#endif
#endif
include/otbVectorDataToAlignVectorDataFilter.txx
deleted
100644 → 0
View file @
7b4c31b1
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbVectorDataToAlignVectorDataFilter_txx
#define __otbVectorDataToAlignVectorDataFilter_txx
#include "otbVectorDataToAlignVectorDataFilter.h"
#include "otbVectorData.h"
namespace otb
{
template <class TVectorData>
VectorDataToAlignVectorDataFilter<TVectorData>
::VectorDataToAlignVectorDataFilter()
{
this->SetNumberOfRequiredInputs(1);
this->SetNumberOfRequiredOutputs(1);
m_DistanceThreshold = 20.;
m_AngleThreshold = CONST_PI / 30.; //we want a threshold at 6 degrees
m_LengthThreshold = 7;
m_RatioThreshold = 10;
}
template <class TVectorData>
void
VectorDataToAlignVectorDataFilter<TVectorData>
::GenerateData()
{
// Get the input segments
typename VectorDataType::Pointer vData = const_cast<VectorDataType *>(this->GetInput());
// Output
this->GetOutput(0)->SetMetaDataDictionary(vData->GetMetaDataDictionary());
// Retrieving root node
typename DataNodeType::Pointer root = this->GetOutput(0)->GetDataTree()->GetRoot()->Get();
// Create the document node
typename DataNodeType::Pointer document = DataNodeType::New();
document->SetNodeType(otb::DOCUMENT);
// Adding the layer to the data tree
this->GetOutput(0)->GetDataTree()->Add(document, root);
// Create the folder node
typename DataNodeType::Pointer folder = DataNodeType::New();
folder->SetNodeType(otb::FOLDER);
this->GetOutput(0)->GetDataTree()->Add(folder, document);
this->GetOutput(0)->SetProjectionRef(vData->GetProjectionRef());
// Itterate on the vector data
TreeIteratorType itVectorRef(vData->GetDataTree()); // Reference
itVectorRef.GoToBegin();
unsigned int nb_couple=0;
while (!itVectorRef.IsAtEnd())
{
if (!itVectorRef.Get()->IsLineFeature())
{
++itVectorRef;
continue; // do not process if it's not a line
}
else
{
double RefLength = this->ComputeSegmentLength(itVectorRef.Get()->GetLine());
if (RefLength <= m_LengthThreshold)
{
++itVectorRef;
continue; // do not process if Segment too small
}
}
TreeIteratorType itVectorCur = itVectorRef; // Current
while (!itVectorCur.IsAtEnd())
{
if (!itVectorCur.Get()->IsLineFeature())
{
++itVectorCur;
continue; // do not process if it's not a line
}
else
{
double CurLength = this->ComputeSegmentLength(itVectorCur.Get()->GetLine());
if (CurLength <= m_LengthThreshold)
{
++itVectorCur;
continue; // do not process if Segment too small
}
}
// Compute the angle formed by the two segments
double Angle = this->ComputeAngleFormedBySegments(itVectorRef.Get()->GetLine(),
itVectorCur.Get()->GetLine());
// Turn the angle on the right range
if (vcl_abs(Angle) > CONST_PI_2)
{
Angle = CONST_PI - vcl_abs(Angle); //Always positive value
}
// Check if the angle is a near to 0
if (vcl_abs(Angle) <= m_AngleThreshold)
{
// Compute the minimum and maximum distance between the two segments
std::pair<double,double> Dist = this->ComputeDistanceFromSegmentToSegment(itVectorRef.Get()->GetLine(),
itVectorCur.Get()->GetLine());
double MinDist = Dist.first;
double MaxDist = Dist.second;
double RefLength = this->ComputeSegmentLength(itVectorRef.Get()->GetLine());
double CurLength = this->ComputeSegmentLength(itVectorCur.Get()->GetLine());
double TotalLength = (RefLength + CurLength - MinDist);
// The maximum distance between segments shall not exced the sum of both segment length
double DistRatio = RefLength / CurLength;
if (MinDist <= m_DistanceThreshold && MinDist > 0 && MaxDist < TotalLength && DistRatio <= m_RatioThreshold)
{
// If the two segments are not so far: Add to the output
//std::cout<<"\nTotalLength: "<<TotalLength<<" RefLength: "<<RefLength<<" CurLength: "<<CurLength<<" MinDist: "<<MinDist<<" MaxDist: "<<MaxDist<<std::endl;
nb_couple++;
typename DataNodeType::Pointer CurrentGeometry = DataNodeType::New();
CurrentGeometry->SetNodeId("FEATURE_LINE");
CurrentGeometry->SetNodeType(otb::FEATURE_LINE);
CurrentGeometry->SetLine(itVectorCur.Get()->GetLine());
this->GetOutput(0)->GetDataTree()->Add(CurrentGeometry, folder);
typename DataNodeType::Pointer ReferenceGeometry = DataNodeType::New();
ReferenceGeometry->SetNodeId("FEATURE_LINE");
ReferenceGeometry->SetNodeType(otb::FEATURE_LINE);
ReferenceGeometry->SetLine(itVectorRef.Get()->GetLine());
this->GetOutput(0)->GetDataTree()->Add(ReferenceGeometry, folder);
}//end if dist
}//end if Angle
++itVectorCur;
}//end while itvectorCur
++itVectorRef;
}//end while itvectorRef
std::cout<<"\nNombre de couples de Segments Parallèles détectés: "<<nb_couple<<"\n"<<std::endl;
}//end GenerateData
//*******************************************************************************************
template <class TVectorData>
std::pair<double,double>
VectorDataToAlignVectorDataFilter<TVectorData>
::ComputeDistanceFromSegmentToSegment(LineType * lineDst, LineType * lineSrc)
{
VertexListType * vertexListDst = const_cast<VertexListType *>(lineDst->GetVertexList());
VertexListType * vertexListSrc = const_cast<VertexListType *>(lineSrc->GetVertexList());
VertexType vp1 = vertexListDst->GetElement(0);
VertexType vp2 = vertexListDst->GetElement(1);
VertexType vq1 = vertexListSrc->GetElement(0);
VertexType vq2 = vertexListSrc->GetElement(1);
std::vector <double> distances;
distances.push_back(std::sqrt(vp1.SquaredEuclideanDistanceTo(vq1)));
distances.push_back(std::sqrt(vp1.SquaredEuclideanDistanceTo(vq2)));
distances.push_back(std::sqrt(vp2.SquaredEuclideanDistanceTo(vq1)));
distances.push_back(std::sqrt(vp2.SquaredEuclideanDistanceTo(vq2)));
double min = distances[0];
double max = distances[0];
unsigned int i=0;
unsigned int j=0;
for(std::vector<double>::iterator it=distances.begin() ; it!=distances.end() ; it++)
{
if(*it<min)
{
min=*it;
i=j;
}
j++;
} //end for
switch (i)
{ case 0:
{
max=distances[3];
break;
}
case 1:
{
max=distances[2];
break;
}
case 2:
{
max=distances[1];
break;
}
case 3:
{
max=distances[0];
}
}//end switch
return std::make_pair(min, max);
}
//*******************************************************************************************
template <class TVectorData>
double
VectorDataToAlignVectorDataFilter<TVectorData>
::ComputeSegmentLength(LineType * line)
{
VertexListType * vertexList = const_cast<VertexListType *>(line->GetVertexList());
double length=line->GetLength();
return length;
}
//*******************************************************************************************
template <class TVectorData>
double
VectorDataToAlignVectorDataFilter<TVectorData>
::ComputeAngleFormedBySegments(LineType * lineDst, LineType * lineSrc)
{
double oriDst = this->ComputeOrientation(lineDst);
double oriSrc = this->ComputeOrientation(lineSrc);
return vcl_abs(oriDst - oriSrc);
}
//*******************************************************************************************
template <class TVectorData>
double
VectorDataToAlignVectorDataFilter<TVectorData>
::ComputeOrientation(LineType * line)
{
VertexListType * vertexList = const_cast<VertexListType *>(line->GetVertexList());
double Xp1 = vertexList->GetElement(0)[0];
double Yp1 = vertexList->GetElement(0)[1];
double Xp2 = vertexList->GetElement(1)[0];
double Yp2 = vertexList->GetElement(1)[1];
//Compute the orientation (angle in rad)
double dx = Xp1 - Xp2;
double dy = Yp1 - Yp2;
double orientation = vcl_atan2(dy, dx);
if (orientation < 0) orientation += CONST_PI;
return orientation;
}
//*******************************************************************************************
template <class TVectorData>
void
VectorDataToAlignVectorDataFilter<TVectorData>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
}
} // end namespace otb
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment