Commit 77cb9360 authored by Julien Michel's avatar Julien Michel

Merge branch 'develop' into cookbook

parents 20e42e3a 424d7781
......@@ -58,6 +58,9 @@ macro(otb_module_check otb-module _needed_by stack)
foreach(dep IN LISTS OTB_MODULE_${otb-module}_DEPENDS)
otb_module_check(${dep} ${otb-module} "${otb-module};${stack}")
endforeach()
foreach(dep IN LISTS OTB_MODULE_${otb-module}_OPTIONAL_DEPENDS)
otb_module_check(${dep} ${otb-module} "${otb-module};${stack}")
endforeach()
set(check_finished_${otb-module} 1)
endif()
endmacro()
......
......@@ -28,5 +28,10 @@ export OTB_APPLICATION_PATH
# avoid numerical issues caused by locale
export LC_NUMERIC=C
# Source GDAL_DATA, EPSG_CSV
if [ -f $CURRENT_SCRIPT_DIR/env_exports ]; then
. $CURRENT_SCRIPT_DIR/env_exports
fi
# start the application
$OTB_CLI_LAUNCHER "$@"
......@@ -28,5 +28,10 @@ export OTB_APPLICATION_PATH
# avoid numerical issues caused by locale
export LC_NUMERIC=C
# Source GDAL_DATA, EPSG_CSV
if [ -f $CURRENT_SCRIPT_DIR/env_exports ]; then
. $CURRENT_SCRIPT_DIR/env_exports
fi
# start the application
$OTB_GUI_LAUNCHER "$@"
......@@ -131,7 +131,7 @@ private:
SetParameterDescription("interpolator.bco", "Bicubic interpolation leads to very good image quality but is slow.");
AddParameter(ParameterType_Radius, "interpolator.bco.radius", "Radius for bicubic interpolation");
SetParameterDescription("interpolator.bco.radius","This parameter allows controling the size of the bicubic interpolation filter. If the target pixel size is higher than the input pixel size, increasing this parameter will reduce aliasing artefacts.");
SetParameterDescription("interpolator.bco.radius","This parameter allows controlling the size of the bicubic interpolation filter. If the target pixel size is higher than the input pixel size, increasing this parameter will reduce aliasing artefacts.");
SetDefaultParameterInt("interpolator.bco.radius", 2);
AddChoice("interpolator.nn", "Nearest Neighbor interpolation");
......
......@@ -37,7 +37,7 @@ bool
Spot6ImageMetadataInterface::CanRead() const
{
std::string sensorID = GetSensorID();
if (sensorID.find("SPOT 6") != std::string::npos)
if (sensorID.find("SPOT 6") != std::string::npos || sensorID.find("SPOT 7") != std::string::npos)
return true;
else
return false;
......@@ -789,7 +789,7 @@ Spot6ImageMetadataInterface
if (nbBands == 1)
{
//if (sensorId.find("PHR") != std::string::npos)
if (sensorId == "SPOT 6") // todo
if (sensorId == "SPOT 6" || sensorId == "SPOT 7") // todo: updated values for Spot7
{
const float pan[601] =
{
......@@ -1406,7 +1406,7 @@ Spot6ImageMetadataInterface
}
else if (nbBands > 1 && nbBands < 5)
{
if (sensorId == "SPOT 6") // todo
if (sensorId == "SPOT 6" || sensorId == "SPOT 7") // todo: updated values for Spot7
{
//band B0 (blue band)
const float b0[601] =
......
......@@ -226,12 +226,6 @@ PersistentMatrixTransposeMatrixImageFilter<TInputImage, TInputImage2>
// support progress methods/callbacks
itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels());
input1Ptr->SetRequestedRegion(outputRegionForThread);
input2Ptr->SetRequestedRegion(outputRegionForThread);
input1Ptr->PropagateRequestedRegion();
input1Ptr->UpdateOutputData();
input2Ptr->PropagateRequestedRegion();
input2Ptr->UpdateOutputData();
itk::ImageRegionConstIterator<TInputImage> it1(input1Ptr, outputRegionForThread);
itk::ImageRegionConstIterator<TInputImage2> it2(input2Ptr, outputRegionForThread);
......
......@@ -173,7 +173,7 @@ private :
std::vector< adhocStruct > m_VAllowedVarNameAddedByUser;
std::vector< adhocStruct > m_VFinalAllowedVarName; // m_VFinalAllowedVarName = m_VAllowedVarNameAuto + m_VAllowedVarNameAddedByUser
std::vector< adhocStruct > m_VNotAllowedVarName;
std::vector< int > m_outputsDimensions;
std::vector< unsigned int > m_outputsDimensions;
unsigned int m_SizeNeighbourhood;
......
......@@ -73,7 +73,7 @@ public:
* It interfaces with an ImageIO class to read in the data and
* supports streaming (partial reading) if the source dataset does so.
*
* ImageFileReader supports extended filenames, which allow controling
* ImageFileReader supports extended filenames, which allow controlling
* how the source dataset is read. See
* http://wiki.orfeo-toolbox.org/index.php/ExtendedFileName for more
* information.
......@@ -179,6 +179,9 @@ private:
*/
bool GetGdalReadImageFileName(const std::string& filename, std::string& GdalFileName);
// Retrieve the real source file name if derived dataset */
std::string GetDerivedDatasetSourceFileName(const std::string& filename) const;
ImageFileReader(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented
......
......@@ -24,6 +24,7 @@
#include "otbSystem.h"
#include <itksys/SystemTools.hxx>
#include <fstream>
#include <string>
#include "itkImageIOFactory.h"
#include "itkPixelTraits.h"
......@@ -40,6 +41,9 @@
namespace otb
{
static const char DerivedSubdatasetPrefix[] = "DERIVED_SUBDATASET:";
static const size_t DerivedSubdatasetPrefixLength = sizeof(DerivedSubdatasetPrefix);
template<class T>
bool PixelIsComplex(const std::complex<T>& /*dummy*/)
{
......@@ -258,8 +262,8 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
}
// Update FileName
this->m_FileName = lFileName;
std::string lFileNameOssimKeywordlist = this->m_FileName;
std::string lFileNameOssimKeywordlist = GetDerivedDatasetSourceFileName(m_FileName);
// Test if the file exists and if it can be opened.
// An exception will be thrown otherwise.
......@@ -524,6 +528,27 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
}
template <class TOutputImage, class ConvertPixelTraits>
std::string
ImageFileReader<TOutputImage, ConvertPixelTraits>
::GetDerivedDatasetSourceFileName(const std::string & filename) const
{
const size_t dsds_pos = filename.find(DerivedSubdatasetPrefix);
if(dsds_pos != std::string::npos)
{
// Derived subdataset from gdal
const size_t alg_pos = filename.find(":",dsds_pos+DerivedSubdatasetPrefixLength);
if (alg_pos != std::string::npos)
{
std::string sourceFilename = filename.substr(alg_pos+1,filename.size() - alg_pos);
return sourceFilename;
}
}
return filename;
}
template <class TOutputImage, class ConvertPixelTraits>
void
ImageFileReader<TOutputImage, ConvertPixelTraits>
......@@ -536,13 +561,15 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
return;
}
std::string fileToCheck = GetDerivedDatasetSourceFileName(m_FileName);
// Test if the file exists.
if (!itksys::SystemTools::FileExists(this->m_FileName.c_str()))
if (!itksys::SystemTools::FileExists(fileToCheck.c_str()))
{
otb::ImageFileReaderException e(__FILE__, __LINE__);
std::ostringstream msg;
msg << "The file doesn't exist. "
<< std::endl << "Filename = " << this->m_FileName
<< std::endl << "Filename = " << fileToCheck
<< std::endl;
e.SetDescription(msg.str().c_str());
throw e;
......@@ -551,16 +578,16 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
// Test if the file can be open for reading access.
//Only if m_FileName specify a filename (not a dirname)
if (itksys::SystemTools::FileExists(this->m_FileName.c_str(), true) == true)
if (itksys::SystemTools::FileExists(fileToCheck.c_str(), true))
{
std::ifstream readTester;
readTester.open(this->m_FileName.c_str());
readTester.open(fileToCheck.c_str());
if (readTester.fail())
{
readTester.close();
std::ostringstream msg;
msg << "The file couldn't be opened for reading. "
<< std::endl << "Filename: " << this->m_FileName
<< std::endl << "Filename: " << fileToCheck
<< std::endl;
otb::ImageFileReaderException e(__FILE__, __LINE__, msg.str().c_str(), ITK_LOCATION);
throw e;
......@@ -619,7 +646,6 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
//Supprime l'extension
GdalFileName = System::GetRootName(strFileName);
}
else
{
// Sinon le filename est le nom du fichier a ouvrir
......@@ -627,6 +653,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
}
fic_trouve = true;
}
otbMsgDevMacro(<< "lFileNameGdal : " << GdalFileName.c_str());
otbMsgDevMacro(<< "fic_trouve : " << fic_trouve);
return (fic_trouve);
......
......@@ -43,7 +43,7 @@ namespace otb
* ImageFileWriter will write directly the streaming buffer in the image file, so
* that the output image never needs to be completely allocated
*
* ImageFileWriter supports extended filenames, which allow controling
* ImageFileWriter supports extended filenames, which allow controlling
* some properties of the output file. See
* http://wiki.orfeo-toolbox.org/index.php/ExtendedFileName for more
* information.
......
......@@ -241,7 +241,7 @@ OGRDataSourceToLabelImageFilter<TOutputImage>::GenerateData()
{
std::vector<std::string> options;
std::vector<double> foreground(nbBands,m_ForegroundValue);
std::vector<double> foreground(nbBands*m_SrcDataSetLayers.size(),m_ForegroundValue);
if(m_BurnAttributeMode)
{
......
......@@ -1693,7 +1693,10 @@ namespace ossimplugins
ossimString metadataProfile;
if ( (nodeValue != "S6_SENSOR")
&& (nodeValue != "S6_ORTHO")
&& (nodeValue != "S6_MOSAIC") )
&& (nodeValue != "S6_MOSAIC")
&& (nodeValue != "S7_SENSOR")
&& (nodeValue != "S7_ORTHO")
&& (nodeValue != "S7_MOSAIC") )
{
if (traceDebug())
{
......@@ -1717,7 +1720,7 @@ namespace ossimplugins
if ((nodeValue == "PRODUCT"))
theMetadataSubProfile = OSSIM_Spot6_METADATA_SUBPROFILE_PRODUCT;
else if ( (nodeValue == "RPC") && (metadataProfile == "S6_SENSOR") )
else if ( (nodeValue == "RPC") && ((metadataProfile == "S6_SENSOR") || (metadataProfile == "S7_SENSOR")) )
theMetadataSubProfile = OSSIM_Spot6_METADATA_SUBPROFILE_RPC;
else
{
......@@ -2156,7 +2159,9 @@ namespace ossimplugins
}
if (nodeValue == "6")
theSensorID = "SPOT 6";
theSensorID = "SPOT 6";
else if (nodeValue == "7")
theSensorID = "SPOT 7";
else
{
setErrorStatus();
......
......@@ -5,12 +5,15 @@ otb_module_test()
#include_directories(${PROJECT_SOURCE_DIR}/Modules/ThirdParty/OssimPlugins/src/ossim ${OSSIM_INCLUDE_DIR})
#==== UT for utilities
if (Boost_UNIT_TEST_FRAMEWORK_FOUND)
add_executable(ossimStringUtilitiesTest ossimStringUtilitiesTest.cpp)
target_link_libraries(ossimStringUtilitiesTest
otbossimplugins
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
otb_module_target_label(ossimStringUtilitiesTest)
otb_add_test(NAME ossimStringUtilitiesTest COMMAND ossimStringUtilitiesTest )
#this test is failing on osx due to a bug in AppleClang stdc++ (Luc Hermitte)
if(NOT APPLE)
add_executable(ossimStringUtilitiesTest ossimStringUtilitiesTest.cpp)
target_link_libraries(ossimStringUtilitiesTest
otbossimplugins
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
otb_module_target_label(ossimStringUtilitiesTest)
otb_add_test(NAME ossimStringUtilitiesTest COMMAND ossimStringUtilitiesTest )
endif()
add_executable(ossimTimeUtilitiesTest ossimTimeUtilitiesTest.cpp)
target_link_libraries(ossimTimeUtilitiesTest
......
......@@ -26,6 +26,7 @@
#include "itkLogger.h"
#include "otbWrapperMacros.h"
#include "otbWrapperInputImageParameter.h"
#include "otbWrapperInputImageListParameter.h"
#include "otbWrapperOutputImageParameter.h"
#include "otbWrapperComplexInputImageParameter.h"
#include "otbWrapperComplexOutputImageParameter.h"
......@@ -402,6 +403,93 @@ public:
*/
std::vector<std::string> GetParameterStringList(std::string parameter);
/**
* Set the input image parameter as an ImageBase * instead
* of filename. Useful to connect pipelines between different
* application instances.
* \in parameter The parameter key
* \in inputImage ImageBase pointer to use as input
* \throw itk::Exception if parameter is not found or not an
* InputImageParameter
*/
void SetParameterInputImage(std::string parameter, InputImageParameter::ImageBaseType * inputImage);
/**
* Get the output image parameter as an ImageBase * instead
* of writing to disk. Useful to connect pipelines between different
* application instances.
* \in parameter The parameter key
* \return The ImageBase * to the output image
* \throw itk::Exception if parameter is not found or not an
* OutputImageParameter
*/
OutputImageParameter::ImageBaseType * GetParameterOutputImage(std::string parameter);
/**
* Set the input complex image parameter as an ImageBase * instead
* of filename. Useful to connect pipelines between different
* application instances.
* \in parameter The parameter key
* \in inputImage ImageBase pointer to use as input
* \throw itk::Exception if parameter is not found or not an
* ComplexInputImageParameter
*/
void SetParameterComplexInputImage(std::string parameter, ComplexInputImageParameter::ImageBaseType * inputImage);
/**
* Get the complex output image parameter as an ImageBase * instead
* of writing to disk. Useful to connect pipelines between different
* application instances.
* \in parameter The parameter key
* \return The ImageBase * pointer to the output image
* \throw itk::Exception if parameter is not found or not an
* ComplexOutputImageParameter
*/
ComplexOutputImageParameter::ImageBaseType * GetParameterComplexOutputImage(std::string parameter);
/**
* Add an image to an InputImageList parameter as an ImageBase
* pointer instead of reading from file. Useful to connect pipelines
* between different application instances.
* \in parameter The parameter key
* \in img The ImageBase * of the image to add
* \throw itk::Exception if parameter is not found or not an
* InputImageList parameter
*/
void AddImageToParameterInputImageList(std::string parameter, InputImageListParameter::ImageBaseType * img);
/**
* Set the nth image of an InputImageList parameter as an ImageBase pointer
* instead of reading from file. Useful to connect pipelines
* between different application instances.
* \in parameter The parameter key
* \in id Position at which to set the ImageBase pointer
* \in img The ImageBase * of the image to add
* \throw itk::Exception if parameter is not found or not an
* InputImageList parameter or if id is out of bounds
*/
void SetNthParameterInputImageList(std::string parameter, const unsigned int &id, InputImageListParameter::ImageBaseType * img);
/**
* Clear all images from an InputImageList parameter.
*
* \in parameter The parameter key
* \throw itk::Exception if parameter is not found or not an
* InputImageList parameter
*/
void ClearParameterInputImageList(std::string parameter);
/**
* Get the number of images in an InputImageList parameter.
* \in parameter The parameter key
* \return The number of images
* \throw itk::Exception if parameter is not found or not an
* InputImageList parameter
*/
unsigned int GetNumberOfElementsInParameterInputImageList(std::string parameter);
/* Get an image value
*
* Can be called for types :
......
......@@ -166,6 +166,15 @@ ComplexInputImageParameter::CastVectorImageFromImage()
return caster->GetOutput();
}
template <class TComplexInputImage>
void
ComplexInputImageParameter::SetImage(TComplexInputImage* image)
{
m_UseFilename = false;
m_Image = image;
}
} // End namespace Wrapper
} // End namespace otb
......
......@@ -18,10 +18,8 @@
#ifndef otbWrapperInputImageListParameter_h
#define otbWrapperInputImageListParameter_h
#include "otbImageFileReader.h"
#include "otbWrapperParameter.h"
#include "otbObjectList.h"
#include "otbWrapperInputImageParameter.h"
namespace otb
{
......@@ -42,9 +40,10 @@ public:
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
typedef otb::ImageFileReader<FloatVectorImageType> ImageFileReaderType;
typedef otb::ObjectList<ImageFileReaderType> ImageFileReaderListType;
typedef std::vector<InputImageParameter::Pointer> InputImageParameterVectorType;
typedef itk::ImageBase<2> ImageBaseType;
/** Defining ::New() static method */
itkNewMacro(Self);
......@@ -63,7 +62,6 @@ public:
/** Set one specific stored image filename. */
bool SetNthFileName( const unsigned int id, const std::string & filename );
/** Get the stored image filename list */
std::vector<std::string> GetFileNameList() const;
......@@ -76,11 +74,14 @@ public:
/** Get one specific stored image. */
FloatVectorImageType* GetNthImage(unsigned int i) const;
/** Set one specific image. */
void SetNthImage(unsigned int i, ImageBaseType * img);
/** Set the list of image. */
void SetImageList(FloatVectorImageListType* imList);
/** Add an image to the list. */
void AddImage(FloatVectorImageType* image);
void AddImage(ImageBaseType* image);
bool HasValue() const ITK_OVERRIDE;
......@@ -91,7 +92,9 @@ public:
/** Clear all the list. */
void ClearValue() ITK_OVERRIDE;
/** Retrieve number of elements */
unsigned int Size() const;
protected:
/** Constructor */
InputImageListParameter();
......@@ -100,13 +103,14 @@ protected:
~InputImageListParameter() ITK_OVERRIDE;
FloatVectorImageListType::Pointer m_ImageList;
ImageFileReaderListType::Pointer m_ReaderList;
private:
InputImageListParameter(const Parameter &); //purposely not implemented
void operator =(const Parameter&); //purposely not implemented
InputImageParameterVectorType m_InputImageParameterVector;
FloatVectorImageListType::Pointer m_ImageList;
}; // End class InputImage Parameter
} // End namespace Wrapper
......
......@@ -26,7 +26,8 @@ otb_module(OTBApplicationEngine
OTBCommandLine
OTBEdge
OTBAppImageUtils
OTBAppFiltering
DESCRIPTION
"${DOCUMENTATION}"
)
......@@ -1137,6 +1137,140 @@ std::vector<std::string> Application::GetParameterStringList(std::string paramet
return ret;
}
void Application::SetParameterInputImage(std::string parameter, InputImageParameter::ImageBaseType * inputImage)
{
Parameter* param = GetParameterByKey(parameter);
InputImageParameter* paramDown = dynamic_cast<InputImageParameter*> (param);
if (paramDown)
{
paramDown->SetImage(inputImage);
}
else
{
itkExceptionMacro(<<parameter << "parameter can't be casted to InputImageParameter");
}
}
OutputImageParameter::ImageBaseType * Application::GetParameterOutputImage(std::string parameter)
{
Parameter* param = GetParameterByKey(parameter);
OutputImageParameter* paramDown = dynamic_cast<OutputImageParameter*> (param);
if (paramDown)
{
return paramDown->GetValue();
}
else
{
itkExceptionMacro(<<parameter << "parameter can't be casted to OutputImageParameter");
}
}
void Application::SetParameterComplexInputImage(std::string parameter, ComplexInputImageParameter::ImageBaseType * inputImage)
{
Parameter* param = GetParameterByKey(parameter);
ComplexInputImageParameter* paramDown = dynamic_cast<ComplexInputImageParameter*> (param);
if (paramDown)
{
paramDown->SetImage(inputImage);
}
else
{
itkExceptionMacro(<<parameter << "parameter can't be casted to ComplexInputImageParameter");
}
}
ComplexOutputImageParameter::ImageBaseType * Application::GetParameterComplexOutputImage(std::string parameter)
{
Parameter* param = GetParameterByKey(parameter);
ComplexOutputImageParameter* paramDown = dynamic_cast<ComplexOutputImageParameter*> (param);
if (paramDown)
{
return paramDown->GetValue();
}
else
{
itkExceptionMacro(<<parameter << "parameter can't be casted to ComplexOutputImageParameter");
}
}
void Application::AddImageToParameterInputImageList(std::string parameter, InputImageListParameter::ImageBaseType * img)
{
Parameter* param = GetParameterByKey(parameter);
InputImageListParameter * paramDown = dynamic_cast<InputImageListParameter *>(param);
if(paramDown)
{
paramDown->AddImage(img);
}
else
{
itkExceptionMacro(<<parameter << "parameter can't be casted to InputImageListParameter");
}
}
void Application::SetNthParameterInputImageList(std::string parameter, const unsigned int &id, InputImageListParameter::ImageBaseType * img)
{
Parameter* param = GetParameterByKey(parameter);
InputImageListParameter * paramDown = dynamic_cast<InputImageListParameter *>(param);
if(paramDown)
{
paramDown->SetNthImage(id,img);
}
else
{
itkExceptionMacro(<<parameter << "parameter can't be casted to InputImageListParameter");
}
}
void Application::ClearParameterInputImageList(std::string parameter)
{
Parameter* param = GetParameterByKey(parameter);
InputImageListParameter * paramDown = dynamic_cast<InputImageListParameter *>(param);
if(paramDown)
{
paramDown->ClearValue();
}
else
{
itkExceptionMacro(<<parameter << "parameter can't be casted to InputImageListParameter");
}
}
unsigned int Application::GetNumberOfElementsInParameterInputImageList(std::string parameter)
{
Parameter* param = GetParameterByKey(parameter);
InputImageListParameter * paramDown = dynamic_cast<InputImageListParameter *>(param);
if(paramDown)
{
return paramDown->Size();
}
else
{
itkExceptionMacro(<<parameter << "parameter can't be casted to InputImageListParameter");
}
}
FloatVectorImageType* Application::GetParameterImage(std::string parameter)
{
......
......@@ -127,15 +127,6 @@ ComplexInputImageParameter::SetImage(ComplexFloatVectorImageType* image)
this->SetImage<ComplexFloatVectorImageType>( image );
}
template <class TComplexInputImage>
void
ComplexInputImageParameter::SetImage(TComplexInputImage* image)
{
m_Image = image;
}