Commit 0dcf5924 authored by Cédric Traizet's avatar Cédric Traizet

Merge branch 'develop' into local_rx_detector

parents 9a681f17 b8695a74
......@@ -118,6 +118,8 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION
".*LaTeX Warning:.*"
".*Package tabulary Warning:.*"
".*Package rerunfilecheck Warning:.*"
# Silent warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas] from GCC 4.9
".*warning: unknown option after \\‘\\#pragma GCC diagnostic\\’ kind \\[-Wpragmas\\]"
# Silent warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas] from GCC 5.2
".*warning: unknown option after.*pragma GCC diagnostic.*kind.*-Wpragmas.*"
# Silent warning: unknown warning group '-Wexpansion-to-defined', ignored [-Wunknown-pragmas] on clang 3.8
"warning: unknown warning group.*-Wexpansion-to-defined.*ignored.*-Wunknown-pragmas.*"
)
......@@ -29,32 +29,13 @@ function(AssureOutOfSourceBuilds)
if("${srcdir}" STREQUAL "${bindir}")
message("######################################################")
message("# OTB should not be configured & built in the OTB source directory")
message("# You must run cmake in a build directory.")
message("# For example:")
message("# mkdir OTB-Sandbox ; cd OTB-Sandbox")
message("# hg clone http://hg.orfeo-toolbox.org/OTB # or download & unpack the source tarball")
message("# mkdir OTB-Binary ")
message("# this will create the following directory structure ")
message("# ")
message("# OTB-Sandbox")
message("# +--OTB ")
message("# +--OTB-Binary ")
message("# ")
message("# Then you can proceed to configure and build ")
message("# by using the following commands ")
message("# ")
message("# cd OTB-Binary")
message("# ccmake ../OTB")
message("# make ")
message("# ")
message("# You must run cmake in a build directory outside of the source tree.")
message("# See the software guide documentation for example build commands.")
message("# ")
message("# NOTE: Given that you already tried to make an in-source build")
message("# CMake have already created several files & directories")
message("# in your source tree. run 'hg status' to find them and")
message("# remove them by doing:")
message("# ")
message("# cd OTB-Sandbox/OTB")
message("# hg purge ")
message("# ")
message("# CMake has already created several files & directories")
message("# in your source tree. Run 'git status' to find them and")
message("# remove them.")
message("######################################################")
message(FATAL_ERROR "Quitting configuration")
endif()
......
......@@ -22,54 +22,19 @@ otb_module_test()
set(OTBDescriptorsTests
otbDescriptorsTestDriver.cxx
otbImageToSURFKeyPointSetFilterOutputDescriptorAscii.cxx
otbImageToSIFTKeyPointSetFilterOutputInterestPointAscii.cxx
otbHistogramOfOrientedGradientCovariantImageFunction.cxx
otbImageToSURFKeyPointSetFilterOutputInterestPointAscii.cxx
otbKeyPointSetsMatchingFilter.cxx
otbImageToSIFTKeyPointSetFilterOutputDescriptorAscii.cxx
otbImageToSIFTKeyPointSetFilterOutputAscii.cxx
otbFourierMellinImageFilter.cxx
otbImageToHessianDeterminantImageFilter.cxx
otbImageToSIFTKeyPointSetFilterOutputImage.cxx
otbFourierMellinDescriptors.cxx
otbImageToSIFTKeyPointSetFilterDistanceMap.cxx
otbKeyPointsAlgorithmsTest.cxx
)
if(OTB_USE_SIFTFAST)
list(APPEND OTBDescriptorsTests
otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii.cxx
otbImageToFastSIFTKeyPointSetFilterOutputDescriptorAscii.cxx
)
endif()
add_executable(otbDescriptorsTestDriver ${OTBDescriptorsTests})
target_link_libraries(otbDescriptorsTestDriver ${OTBDescriptors-Test_LIBRARIES})
otb_module_target_label(otbDescriptorsTestDriver)
# Tests Declaration
otb_add_test(NAME feTvImageToSURFKeyPointSetFilterSceneOutputDescriptorAscii COMMAND otbDescriptorsTestDriver
--compare-ascii ${EPSILON_3}
${BASELINE_FILES}/feTvImageToSURFKeyPointSetFilterSceneKeysOutputDescriptor.txt
${TEMP}/feTvImageToSURFKeyPointSetFilterSceneKeysOutputDescriptor.txt
otbImageToSURFKeyPointSetFilterOutputDescriptorAscii
${INPUTDATA}/scene.png
${TEMP}/feTvImageToSURFKeyPointSetFilterSceneKeysOutputDescriptor.txt
3 3
)
otb_add_test(NAME feTvImageToSIFTKeyPointSetFilterSceneOutputInterestPointAscii COMMAND otbDescriptorsTestDriver
--ignore-order --compare-ascii ${EPSILON_3}
${BASELINE_FILES}/feTvImageToSIFTKeyPointSetFilterSceneKeysOutputInterestPoint.txt
${TEMP}/feTvImageToSIFTKeyPointSetFilterSceneKeysOutputInterestPoint.txt
otbImageToSIFTKeyPointSetFilterOutputInterestPointAscii
${INPUTDATA}/scene.png
${TEMP}/feTvImageToSIFTKeyPointSetFilterSceneKeysOutputInterestPoint.txt
6 3 0.08 10.0
)
otb_add_test(NAME feTvHistogramOfOrientedGradientCovariantImageFunction COMMAND otbDescriptorsTestDriver
--compare-ascii ${EPSILON_8}
${BASELINE_FILES}/feTvHistogramOfOrientedGradientCovariantImageFunction.txt
......@@ -80,94 +45,7 @@ otb_add_test(NAME feTvHistogramOfOrientedGradientCovariantImageFunction COMMAND
5 273 64
)
otb_add_test(NAME feTvImageToSURFKeyPointSetFilterSceneOutputInterestPointAscii COMMAND otbDescriptorsTestDriver
--compare-ascii ${EPSILON_3}
${BASELINE_FILES}/feTvImageToSURFKeyPointSetFilterSceneKeysOutputInterestPoint.txt
${TEMP}/feTvImageToSURFKeyPointSetFilterSceneKeysOutputInterestPoint.txt
otbImageToSURFKeyPointSetFilterOutputInterestPointAscii
${INPUTDATA}/scene.png
${TEMP}/feTvImageToSURFKeyPointSetFilterSceneKeysOutputInterestPoint.txt
3 3
)
otb_add_test(NAME feTvKeyPointSetsMatchingFilter COMMAND otbDescriptorsTestDriver
--compare-ascii ${EPSILON_3}
${BASELINE_FILES}/feTvKeyPointSetsMatchingFilterOutputAscii.txt
${TEMP}/feTvKeyPointSetsMatchingFilterOutputAscii.txt
otbKeyPointSetsMatchingFilter
${TEMP}/feTvKeyPointSetsMatchingFilterOutputAscii.txt
0.6 0
)
otb_add_test(NAME feTvImageToSIFTKeyPointSetFilterSceneDescriptorAscii COMMAND otbDescriptorsTestDriver
--ignore-order --compare-ascii ${EPSILON_3}
${BASELINE_FILES}/feTvImageToSIFTKeyPointSetFilterSceneKeysOutputDescriptor.txt
${TEMP}/feTvImageToSIFTKeyPointSetFilterSceneKeysOutputDescriptor.txt
otbImageToSIFTKeyPointSetFilterOutputDescriptorAscii
${INPUTDATA}/scene.png
${TEMP}/feTvImageToSIFTKeyPointSetFilterSceneKeysOutputDescriptor.txt
6 3 0.08 10.0
)
otb_add_test(NAME feTvImageToSIFTKeyPointSetFilterGridOutputAscii COMMAND otbDescriptorsTestDriver
--compare-ascii ${EPSILON_3}
${BASELINE_FILES}/feTvImageToSIFTKeyPointSetFilterGridKeysOutput.txt
${TEMP}/feTvImageToSIFTKeyPointSetFilterGridKeysOutput.txt
otbImageToSIFTKeyPointSetFilterOutputAscii
${INPUTDATA}/damier.png
${TEMP}/feTvImageToSIFTKeyPointSetFilterGridKeysOutput.txt
7 3 0.01 10.0
)
otb_add_test(NAME feTvImageToSIFTKeyPointSetFilterSquareRotatedOutputAscii COMMAND otbDescriptorsTestDriver
--compare-ascii ${EPSILON_3}
${BASELINE_FILES}/feTvImageToSIFTKeyPointSetFilterSquareRotatedKeysOutput.txt
${TEMP}/feTvImageToSIFTKeyPointSetFilterSquareRotatedKeysOutput.txt
otbImageToSIFTKeyPointSetFilterOutputAscii
${INPUTDATA}/carre_ori.png
${TEMP}/feTvImageToSIFTKeyPointSetFilterSquareRotatedKeysOutput.txt
7 3 0.01 10.0
)
otb_add_test(NAME feTvImageToSIFTKeyPointSetFilterSquare2OutputAscii COMMAND otbDescriptorsTestDriver
--compare-ascii ${EPSILON_3}
${BASELINE_FILES}/feTvImageToSIFTKeyPointSetFilterSquareKeysOutput2.txt
${TEMP}/feTvImageToSIFTKeyPointSetFilterSquareKeysOutput2.txt
otbImageToSIFTKeyPointSetFilterOutputAscii
${INPUTDATA}/carre.png
${TEMP}/feTvImageToSIFTKeyPointSetFilterSquareKeysOutput2.txt
1 3 0.2 0.9
)
otb_add_test(NAME feTvImageToSIFTKeyPointSetFilterSquareRotated2OutputAscii COMMAND otbDescriptorsTestDriver
--compare-ascii ${EPSILON_3}
${BASELINE_FILES}/feTvImageToSIFTKeyPointSetFilterSquareRotatedKeysOutput2.txt
${TEMP}/feTvImageToSIFTKeyPointSetFilterSquareRotatedKeysOutput2.txt
otbImageToSIFTKeyPointSetFilterOutputAscii
${INPUTDATA}/carre_ori.png
${TEMP}/feTvImageToSIFTKeyPointSetFilterSquareRotatedKeysOutput2.txt
1 3 0.215 10.0
)
otb_add_test(NAME feTvImageToSIFTKeyPointSetFilterSquareOutputAscii COMMAND otbDescriptorsTestDriver
--compare-ascii ${EPSILON_3}
${BASELINE_FILES}/feTvImageToSIFTKeyPointSetFilterSquareKeysOutput.txt
${TEMP}/feTvImageToSIFTKeyPointSetFilterSquareKeysOutput.txt
otbImageToSIFTKeyPointSetFilterOutputAscii
${INPUTDATA}/carre.png
${TEMP}/feTvImageToSIFTKeyPointSetFilterSquareKeysOutput.txt
7 3 0.01 10.0
)
otb_add_test(NAME feTvImageToSIFTKeyPointSetFilterQB_SuburbOutputAscii COMMAND otbDescriptorsTestDriver
--compare-ascii ${EPSILON_3}
${BASELINE_FILES}/feTvImageToSIFTKeyPointSetFilterQB_SuburbOutputAscii.txt
${TEMP}/feTvImageToSIFTKeyPointSetFilterQB_SuburbOutputAscii.txt
otbImageToSIFTKeyPointSetFilterOutputAscii
${INPUTDATA}/QB_Suburb.png
${TEMP}/feTvImageToSIFTKeyPointSetFilterQB_SuburbOutputAscii.txt
2 3 5.0 0.0
)
otb_add_test(NAME feTvForwardFourierMellinImageFilter COMMAND otbDescriptorsTestDriver
--compare-n-images ${EPSILON_6} 2
......@@ -190,26 +68,6 @@ otb_add_test(NAME feTvImageToHessianDeterminantImageFilter COMMAND otbDescriptor
1.5
)
otb_add_test(NAME feTvImageToSIFTKeyPointSetFilterSquareOutputImage COMMAND otbDescriptorsTestDriver
--compare-image ${EPSILON_8}
${BASELINE}/feTvImageToSIFTKeyPointSetFilterSquareImageOutput.png
${TEMP}/feTvImageToSIFTKeyPointSetFilterSquareImageOutput.png
otbImageToSIFTKeyPointSetFilterOutputImage
${INPUTDATA}/carre.png
${TEMP}/feTvImageToSIFTKeyPointSetFilterSquareImageOutput.png
7 3 0.01 10.0
)
otb_add_test(NAME feTvImageToSIFTKeyPointSetFilterGridOutputImage COMMAND otbDescriptorsTestDriver
--compare-image ${EPSILON_8}
${BASELINE}/feTvImageToSIFTKeyPointSetFilterGridImageOutput.png
${TEMP}/feTvImageToSIFTKeyPointSetFilterGridImageOutput.png
otbImageToSIFTKeyPointSetFilterOutputImage
${INPUTDATA}/damier.png
${TEMP}/feTvImageToSIFTKeyPointSetFilterGridImageOutput.png
7 3 0.01 10.0
)
otb_add_test(NAME feTvFourierMellinDescriptorsRotationInvariant COMMAND otbDescriptorsTestDriver
otbFourierMellinDescriptorsRotationInvariant
${INPUTDATA}/poupees.png
......@@ -237,41 +95,7 @@ otb_add_test(NAME feTvFourierMellinDescriptors COMMAND otbDescriptorsTestDriver
${TEMP}/feTvFourierMellinDescriptors.txt
)
otb_add_test(NAME feTvImageToSIFTKeyPointSetFilterDistanceMap COMMAND otbDescriptorsTestDriver
--compare-ascii ${EPSILON_3}
${BASELINE_FILES}/feTvImageToSIFTKeyPointSetFilterDistanceMap.txt
${TEMP}/feTvImageToSIFTKeyPointSetFilterDistanceMap.txt
--ignore-lines-with 2 INFO DEBUG
otbImageToSIFTKeyPointSetFilterDistanceMap
${INPUTDATA}/scene.png
6 3 0.08 10.0
15.0 # rotation
1.2 # zoom factor
10 255
${TEMP}/feTvImageToSIFTKeyPointSetFilterDistanceMap.txt
)
if(OTB_USE_SIFTFAST)
otb_add_test(NAME feTvImageToFastSIFTKeyPointSetFilterSceneOutputInterestPointAscii COMMAND otbDescriptorsTestDriver
--ignore-order --compare-ascii ${EPSILON_3}
${BASELINE_FILES}/feTvImageToFastSIFTKeyPointSetFilterSceneKeysOutputInterestPoint.txt
${TEMP}/feTvImageToFastSIFTKeyPointSetFilterSceneKeysOutputInterestPoint.txt
otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii
${INPUTDATA}/ROI_IKO_PAN_LesHalles_sub.tif
${TEMP}/feTvImageToFastSIFTKeyPointSetFilterSceneKeysOutputInterestPoint.txt
6
)
# RK: 06/2016. the root cause of this test having different output on platforms comes from libsiftfast (3rd party code)
# Until there is a fix, that failure cannot be attributed to OTB or dashboard results
# --ignore-order --epsilon-boundary 0.01 --compare-ascii ${EPSILON_2}
# ${BASELINE_FILES}/feTvImageToFastSIFTKeyPointSetFilterSceneKeysOutputDescriptor.txt
# ${TEMP}/feTvImageToFastSIFTKeyPointSetFilterSceneKeysOutputDescriptor.txt
otb_add_test(NAME feTvImageToFastSIFTKeyPointSetFilterSceneOutputDescriptorAscii COMMAND otbDescriptorsTestDriver
otbImageToFastSIFTKeyPointSetFilterOutputDescriptorAscii
${INPUTDATA}/ROI_IKO_PAN_LesHalles_sub.tif
${TEMP}/feTvImageToFastSIFTKeyPointSetFilterSceneKeysOutputDescriptor.txt
6
)
endif()
otb_add_test(NAME feTvKeyPointsAlgorithmsTest COMMAND otbDescriptorsTestDriver
otbKeyPointsAlgorithmsTest
${INPUTDATA}/QB_TOULOUSE_RpcTag_100_100.tif
)
......@@ -22,22 +22,11 @@
void RegisterTests()
{
REGISTER_TEST(otbImageToSURFKeyPointSetFilterOutputDescriptorAscii);
REGISTER_TEST(otbImageToSIFTKeyPointSetFilterOutputInterestPointAscii);
REGISTER_TEST(otbHistogramOfOrientedGradientCovariantImageFunction);
REGISTER_TEST(otbImageToSURFKeyPointSetFilterOutputInterestPointAscii);
REGISTER_TEST(otbKeyPointSetsMatchingFilter);
REGISTER_TEST(otbImageToSIFTKeyPointSetFilterOutputDescriptorAscii);
REGISTER_TEST(otbImageToSIFTKeyPointSetFilterOutputAscii);
REGISTER_TEST(otbFourierMellinImageFilter);
REGISTER_TEST(otbImageToHessianDeterminantImageFilter);
REGISTER_TEST(otbImageToSIFTKeyPointSetFilterOutputImage);
REGISTER_TEST(otbFourierMellinDescriptors);
REGISTER_TEST(otbFourierMellinDescriptorsScaleInvariant);
REGISTER_TEST(otbFourierMellinDescriptorsRotationInvariant);
REGISTER_TEST(otbImageToSIFTKeyPointSetFilterDistanceMap);
#ifdef OTB_USE_SIFTFAST
REGISTER_TEST(otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii);
REGISTER_TEST(otbImageToFastSIFTKeyPointSetFilterOutputDescriptorAscii);
#endif
REGISTER_TEST(otbKeyPointsAlgorithmsTest);
}
/*
* Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <iomanip>
#include <iostream>
#include <fstream>
#include <algorithm>
#include "otbSiftFastImageFilter.h"
#include "otbImageFileReader.h"
#include "itkPointSet.h"
#include "itkVariableLengthVector.h"
#include "itkRGBPixel.h"
#include "itkImageRegionIterator.h"
bool CMPData(std::vector<float> a, std::vector<float> b)
{
return lexicographical_compare(a.begin(), a.begin() + 2, b.begin(), b.begin() + 2);
}
int otbImageToFastSIFTKeyPointSetFilterOutputDescriptorAscii(int itkNotUsed(argc), char * argv[])
{
const char * infname = argv[1];
const char * outfname = argv[2];
const unsigned int scales = atoi(argv[3]);
typedef float RealType;
const unsigned int Dimension = 2;
typedef otb::Image<RealType, Dimension> ImageType;
typedef itk::VariableLengthVector<RealType> RealVectorType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef itk::PointSet<RealVectorType, Dimension> PointSetType;
typedef otb::SiftFastImageFilter<ImageType, PointSetType> ImageToFastSIFTKeyPointSetFilterType;
// Iterator types
typedef PointSetType::PointsContainer PointsContainerType;
typedef PointsContainerType::Iterator PointsIteratorType;
typedef PointSetType::PointDataContainer PointDataContainerType;
typedef PointDataContainerType::Iterator PointDataIteratorType;
typedef std::vector<float> siftDataVector;
typedef std::vector<siftDataVector> ImageDataType; //Kind of PointSet with vectors
// Instantiating object
ReaderType::Pointer reader = ReaderType::New();
ImageToFastSIFTKeyPointSetFilterType::Pointer filter = ImageToFastSIFTKeyPointSetFilterType::New();
//Instantiation of std::vector for lexicographiacal sorting
ImageDataType imageData;
reader->SetFileName(infname);
filter->SetInput(reader->GetOutput());
filter->SetScalesNumber(scales);
filter->Update();
PointsIteratorType pIt = filter->GetOutput()->GetPoints()->Begin();
PointDataIteratorType pDataIt = filter->GetOutput()->GetPointData()->Begin();
std::ofstream outfile(outfname);
outfile << "Number of scales: " << scales << std::endl;
outfile << "Number of SIFT key points: " << filter->GetOutput()->GetNumberOfPoints() << std::endl;
if (filter->GetOutput()->GetPointData()->Size() != filter->GetOutput()->GetPoints()->Size()) return EXIT_FAILURE;
if (filter->GetOutput()->GetPointData()->Size() == 0) return EXIT_FAILURE;
// Copy the PointSet to std::vector< std::vector >
while (pIt != filter->GetOutput()->GetPoints()->End() && pDataIt != filter->GetOutput()->GetPointData()->End())
{
siftDataVector siftData;
siftData.push_back(pIt.Value()[0]);
siftData.push_back(pIt.Value()[1]);
unsigned int lIterDesc = 0;
while (lIterDesc < pDataIt.Value().Size())
{
siftData.push_back(pDataIt.Value()[lIterDesc]);
lIterDesc++;
}
imageData.push_back(siftData);
++pIt;
++pDataIt;
}
//Sorting the vectors
ImageDataType::iterator itData;
sort(imageData.begin(), imageData.end(), CMPData);
itData = imageData.begin();
unsigned int stopVal = static_cast<unsigned int>(filter->GetOutput()->GetPointData()->Begin().Value().Size());
while (itData != imageData.end())
{
unsigned int itDescriptor = 0;
outfile << "[ ";
while (itDescriptor < stopVal)
//while (itDescriptor < static_cast<int>((*itData).size()-2) )
{
outfile << std::fixed << std::setprecision(4) << (*itData)[itDescriptor + 2] << " ";
itDescriptor++;
}
outfile << "]" << std::endl;
++itData;
}
outfile.close();
return EXIT_SUCCESS;
}
/*
* Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <iomanip>
#include <iostream>
#include <fstream>
#include <algorithm>
#include "otbSiftFastImageFilter.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "itkPointSet.h"
#include "itkVariableLengthVector.h"
#include "itkRGBPixel.h"
#include "itkImageRegionIterator.h"
bool CMP(std::vector<float> a, std::vector<float> b)
{
return lexicographical_compare(a.begin(), a.begin() + 2, b.begin(), b.begin() + 2);
}
int
otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii( int itkNotUsed( argc ), char * argv[] )
{
const char * infname = argv[1];
const char * outfname = argv[2];
const unsigned int scales = atoi(argv[3]);
typedef float RealType;
const unsigned int Dimension = 2;
typedef otb::Image<RealType, Dimension> ImageType;
typedef itk::VariableLengthVector<RealType> RealVectorType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef itk::PointSet<RealVectorType, Dimension> PointSetType;
typedef otb::SiftFastImageFilter<ImageType, PointSetType> ImageToFastSIFTKeyPointSetFilterType;
// PointSet iterator types
typedef PointSetType::PointsContainer PointsContainerType;
typedef PointsContainerType::Iterator PointsIteratorType;
typedef PointSetType::PointDataContainer PointDataContainerType;
typedef PointDataContainerType::Iterator PointDataIteratorType;
typedef std::vector< RealType > siftDataVector;
typedef std::vector<siftDataVector> ImageDataType; //Kind of PointSet with vectors
// Instantiating object
ReaderType::Pointer reader = ReaderType::New();
ImageToFastSIFTKeyPointSetFilterType::Pointer filter = ImageToFastSIFTKeyPointSetFilterType::New();
//Instantiation of std::vector for lexicographiacal sorting
ImageDataType imageData;
reader->SetFileName(infname);
filter->SetInput(reader->GetOutput());
filter->SetScalesNumber(scales);
filter->Update();
PointsIteratorType pIt = filter->GetOutput()->GetPoints()->Begin();
PointDataIteratorType pDataIt = filter->GetOutput()->GetPointData()->Begin();
assert(
filter->GetOutput()->GetPoints()->Size() ==
filter->GetOutput()->GetPointData()->Size() );
std::ofstream outfile(outfname);
outfile << "Number of scales: " << scales << std::endl;
outfile << "Number of SIFT key points: "
<< filter->GetOutput()->GetNumberOfPoints()
<< std::endl;
outfile << "Number of points: "
<< filter->GetOutput()->GetPoints()->Size()
<< std::endl;
outfile << "Number of points data: "
<< filter->GetOutput()->GetPointData()->Size()
<< std::endl;
if( filter->GetOutput()->GetPoints()->Size() !=
filter->GetOutput()->GetPointData()->Size() )
return EXIT_FAILURE;
// Copy the PointSet to std::vector< std::vector >
while (pIt != filter->GetOutput()->GetPoints()->End())
{
siftDataVector siftData;
siftData.push_back(pIt.Value()[0]);
siftData.push_back(pIt.Value()[1]);
unsigned int lIterDesc = 0;
while (lIterDesc < pDataIt.Value().Size())
{
siftData.push_back(pDataIt.Value()[lIterDesc]);
lIterDesc++;
}
imageData.push_back(siftData);
++pIt;
++pDataIt;
}
//Sorting the vectors
ImageDataType::iterator itData;
sort(imageData.begin(), imageData.end(), CMP);
itData = imageData.begin();
while (itData != imageData.end())
{
outfile << "[" << std::fixed << std::setprecision(1) << (*itData)[0] << ", " << std::setprecision(1) <<
(*itData)[1] << "]" << std::endl;
++itData;
}
outfile.close();
return EXIT_SUCCESS;
}
/*
* Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <iomanip>
#include <iostream>
#include <fstream>
#include "otbImageToSIFTKeyPointSetFilter.h"
#include "otbImage.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "itkPointSet.h"
#include "itkVariableLengthVector.h"
#include "itkRGBPixel.h"
#include "itkImageRegionIterator.h"
int otbImageToSIFTKeyPointSetFilterOutputAscii(int itkNotUsed(argc), char * argv[])
{
const char * infname = argv[1];
const char * outfname = argv[2];
const unsigned int octaves = atoi(argv[3]);
const unsigned int scales = atoi(argv[4]);
const float threshold = atof(argv[5]);
const float ratio = atof(argv[6]);
typedef float RealType;
const unsigned int Dimension = 2;
typedef otb::Image<RealType, Dimension> ImageType;
typedef itk::VariableLengthVector<RealType> RealVectorType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef itk::PointSet<RealVectorType, Dimension> PointSetType;
typedef otb::ImageToSIFTKeyPointSetFilter<ImageType, PointSetType> ImageToSIFTKeyPointSetFilterType;
// PointSet iterator type
typedef PointSetType::PointsContainer PointsContainerType;
typedef PointsContainerType::Iterator PointsIteratorType;
typedef PointSetType::PointDataContainer PointDataContainerType;
typedef PointDataContainerType::Iterator PointDataIteratorType;
// Instantiating object
ReaderType::Pointer reader = ReaderType::New();
ImageToSIFTKeyPointSetFilterType::Pointer filter = ImageToSIFTKeyPointSetFilterType::New();
reader->SetFileName(infname);
filter->SetInput(reader->GetOutput());
filter->SetOctavesNumber(octaves);
filter->SetScalesNumber(scales);
filter->SetDoGThreshold(threshold);
filter->SetEdgeThreshold(ratio);
filter->Update();
PointsIteratorType pIt = filter->GetOutput()->GetPoints()->Begin();
if (filter->GetOutput()->GetPointData() == nullptr)
{
std::cerr << "No sift point found!" << std::endl;
return EXIT_FAILURE; //Avoid the subsequent segfault, but need to check if that what the test want to do
}
PointDataIteratorType pDataIt = filter->GetOutput()->GetPointData()->Begin();
std::ofstream outfile(outfname);
outfile << "Number of octaves: " << octaves << std::endl;
outfile << "Number of scales: " << scales << std::endl;
outfile << "Number of SIFT key points: " << filter->GetOutput()->GetNumberOfPoints() << std::endl;
while (pIt != filter->GetOutput()->GetPoints()->End())
{
outfile << "[" << std::fixed << std::setprecision(2) << pIt.Value()[0] << ", " << std::setprecision(2) <<
pIt.Value()[1] << "][";
unsigned int lIterDesc = 0;
while (lIterDesc < pDataIt.Value().Size())
{
outfile << std::setprecision(3) << pDataIt.Value()[lIterDesc] << " ";
lIterDesc++;
}
outfile << "]" << std::endl;
++pIt;
++pDataIt;
}
outfile.close();
return EXIT_SUCCESS;
}
/*
* Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/