Commit 638bbccc authored by Julien Michel's avatar Julien Michel
Browse files

MRG

parents 9e2a8cfa 76189ec2
......@@ -136,8 +136,8 @@ namespace otb
<<m_determinantImage->GetLargestPossibleRegion().GetSize() );
/** For each octave, we fill the imageList for the extremum search*/
m_ImageList->PushBack(m_determinantImage);
/** For each octave, we fill the imageList for the extremum search*/
m_ImageList->PushBack(m_determinantImage);
}
/*----------------------------------------------------*/
......@@ -280,10 +280,10 @@ namespace otb
while (i!=(int)neigh.Size()){
if(i != centerIndex ){
if( centerValue> neigh[i] & flag_max == 0) max = true;
if( centerValue> neigh[i] && flag_max == 0) max = true;
else { max = false; flag_max = 1; }
if(centerValue < neigh[i] & flag_min == 0 & centerValue <0) min = true;
if(centerValue < neigh[i] && flag_min == 0 && centerValue <0) min = true;
else { min = false; flag_min = 1; }
}
++i;
......@@ -307,10 +307,10 @@ namespace otb
while (i!=(int)neigh.Size()){
if( CenterValue> neigh[i] & flag_max == 0) max = true;
if( CenterValue> neigh[i] && flag_max == 0) max = true;
else { max = false; flag_max = 1; }
if(CenterValue < neigh[i] & flag_min == 0) min = true;
if(CenterValue < neigh[i] && flag_min == 0) min = true;
else { min = false; flag_min = 1; }
++i;
......@@ -341,17 +341,17 @@ namespace otb
// Gradient orientation histogram
double angle;
int bin = 0 , Pi = 180;
int LengthBin = 60;
int NbBins = (2*Pi/LengthBin);
double tab[NbBins*2];
int bin = 0 ;
int Pi = 180;
int LengthBin = 60;
int NbBins = (2*Pi/LengthBin);
std::vector<double> tab(NbBins*2 , 0.);
while (i < (int)neigh.Size())
{
col = i%Largeur - rayon ;
raw = i/Largeur - rayon ;
dist = sqrt(col *col + raw * raw );
dist = vcl_sqrt(col *col + raw * raw );
col +=rayon;
raw +=rayon; // Backup to the image coordinate axes
......@@ -391,7 +391,7 @@ namespace otb
//Detection de l'orientation du point courant
for (int i = 0 ; i < NbBins*2 ; i = i+2){
length = sqrt( tab[i]*tab[i] + tab[i+1]*tab[i+1] );
length = vcl_sqrt( tab[i]*tab[i] + tab[i+1]*tab[i+1] );
if( length > max){
max = length ;
indice = i/2;
......@@ -442,8 +442,7 @@ namespace otb
ParamVec[3] = 0;
ParamVec[4] = 0;
eulerTransform->SetParameters(ParamVec);
int accumulator = 0;
while (i < (int)neigh.Size())
{
col = i % Largeur ;
......@@ -469,10 +468,8 @@ namespace otb
if(raw==0) raw =+1;
if(col ==0) col +=1;
xx = static_cast<int> (pSrc[1]/rayon);
yy = static_cast<int> (pSrc[0]/rayon);
//Nbin = static_cast<int> ( vcl_floor(xx + 4 * yy) ) ;
xx = static_cast<int> (pSrc[1]/rayon);
yy = static_cast<int> (pSrc[0]/rayon);
Nbin = xx + 4*yy ;
if( Nbin < 16) //because 64 descriptor length
......@@ -481,8 +478,7 @@ namespace otb
double distanceYcompensee_2 = (pSrc[1] - r)*(pSrc[1] - r);
w = vcl_exp(-( distanceXcompensee_2 + distanceYcompensee_2 ) / (2*3.3*3.3*S*S) );
//w = vcl_exp(-( (pSrc[0] - r)*(pSrc[0] -r) + (pSrc[1] - r)*(pSrc[1] - r) )/(2*3.3*3.3/**S*S*/));
dx = 0.5 * (neigh[(col+pas) + raw * Largeur] - neigh[(col-pas) + raw *Largeur]) * w ;
dy = 0.5 * (neigh[col + (raw+ pas)* Largeur] - neigh[col + (raw-pas)*Largeur]) * w;
......@@ -491,19 +487,11 @@ namespace otb
descriptorVector[4*Nbin+2] += vcl_abs(dx) ;
descriptorVector[4*Nbin+3] += vcl_abs(dy) ;
}
else
{
accumulator++;
//std::cout << " xx "<< xx << " yy " << yy << " Nbin " << Nbin << " rayon "<< rayon << " pSrc[1] " << pSrc[1] << " pSrc[0] " <<pSrc[0] << " pDst[0] " << pDst[0] <<" pDst[1] " << pDst[1] << " Largeur "<< Largeur << std::endl;
}
}
}
i++;
}
if(accumulator > 0 ) std::cout << " accumulator "<< accumulator << " / "<< i << std::endl;
double accu = 0;
for (int i = 0 ; i < 64 ; i++)
accu += descriptorVector[i]*descriptorVector[i];
......
......@@ -49,11 +49,11 @@ public:
itkGetMacro( Lon, double );
itkGetMacro( Lat, double );
itkGetMacro( PlaceName, string );
itkGetMacro( PlaceName, std::string );
itkSetMacro( Lon, double );
itkSetMacro( Lat, double );
itkSetMacro( PlaceName, string );
itkSetMacro( PlaceName, std::string );
virtual bool Evaluate();
......@@ -71,7 +71,7 @@ private:
double m_Lon;
double m_Lat;
string m_PlaceName;
std::string m_PlaceName;
};
......
......@@ -54,8 +54,8 @@ PlaceNameToLonLat
bool PlaceNameToLonLat::Evaluate()
{
string::size_type loc = m_PlaceName.find(" ", 0 );
while (loc != string::npos)
std::string::size_type loc = m_PlaceName.find(" ", 0 );
while (loc != std::string::npos)
{
m_PlaceName.replace(loc, 1, "+");
loc = m_PlaceName.find(" ", loc);
......@@ -100,6 +100,21 @@ bool PlaceNameToLonLat::Evaluate()
return true;
}
static size_t
curlHandlerWriteMemoryCallback(void *ptr, size_t size, size_t nmemb,
void *data)
{
register int realsize = (int)(size * nmemb);
std::vector<char> *vec
= static_cast<std::vector<char>*>(data);
const char* chPtr = static_cast<char*>(ptr);
vec->insert(vec->end(), chPtr, chPtr + realsize);
return realsize;
}
void PlaceNameToLonLat::RetrieveXML(std::ostringstream& urlStream)
{
......@@ -109,7 +124,7 @@ void PlaceNameToLonLat::RetrieveXML(std::ostringstream& urlStream)
FILE* output_file = fopen("out.xml","w");
curl = curl_easy_init();
std::cout << "URL data " << urlStream.str().data() << std::endl;
// std::cout << "URL data " << urlStream.str().data() << std::endl;
char url[256];
......@@ -117,7 +132,13 @@ void PlaceNameToLonLat::RetrieveXML(std::ostringstream& urlStream)
// std::cout << url << std::endl;
if(curl) {
std::vector<char> chunk;
curl_easy_setopt(curl, CURLOPT_URL, url);
/*
//Step needed to handle curl without temporary file
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,this->curlHandlerWriteMemoryCallback);
curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
*/
curl_easy_setopt(curl, CURLOPT_WRITEDATA, output_file);
res = curl_easy_perform(curl);
......
......@@ -18,6 +18,10 @@ TARGET_LINK_LIBRARIES(SensorModelExample OTBProjections OTBCommon OTBIO ITKCommo
ADD_EXECUTABLE(OrthoRectificationExample OrthoRectificationExample.cxx )
TARGET_LINK_LIBRARIES(OrthoRectificationExample OTBProjections OTBCommon OTBIO ITKCommon ITKIO)
IF( OTB_USE_CURL )
ADD_EXECUTABLE(PlaceNameToLonLat PlaceNameToLonLat.cxx )
TARGET_LINK_LIBRARIES(PlaceNameToLonLat OTBProjections OTBCommon OTBIO ITKCommon ITKIO ${CURL_LIBRARY} tinyXML)
ENDIF( OTB_USE_CURL )
IF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING )
......
/*=========================================================================
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.
=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#include "otbPlaceNameToLonLat.h"
int main( int argc, char* argv[] )
{
if(argc!=2)
{
std::cout << argv[0] <<" <place name> "
<< std::endl;
return EXIT_FAILURE;
}
otb::PlaceNameToLonLat::Pointer pn2LL = otb::PlaceNameToLonLat::New();
pn2LL->SetPlaceName(std::string(argv[1]));
pn2LL->Evaluate();
double lon = pn2LL->GetLon();
double lat = pn2LL->GetLat();
std::cout << "Latitude: " << lat << std::endl;
std::cout << "Longitude: " << lon << std::endl;
return EXIT_SUCCESS;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment