27 #include "../Config.h" 32 #define BOOST_TEST_NO_MAIN 33 #include <boost/test/unit_test.hpp> 34 #include <boost/shared_ptr.hpp> 38 void saveImagesAndTiePoints(
40 const
te::
rst::Raster& raster1,
41 const
unsigned int band1,
42 const
te::
rst::Raster& raster2,
43 const
unsigned int band2,
44 const
std::vector<
te::gm::GTParameters::TiePoint >& tiePoints,
45 const
std::
string& tifFileNameBeginning )
47 std::map<std::string, std::string> rInfo1;
48 rInfo1[
"URI"] = tifFileNameBeginning +
"_raster1.tif";
50 std::vector<te::rst::BandProperty*> bandsProperties1;
53 bandsProperties1[0]->m_noDataValue = 0;
61 std::unique_ptr< te::rst::Raster > outputRaster1Ptr(
63 BOOST_CHECK( outputRaster1Ptr.get() );
65 unsigned int line = 0;
69 for( line = 0 ; line < raster1.getNumberOfRows() ; ++
line )
70 for( col = 0 ; col < raster1.getNumberOfColumns() ; ++
col )
72 raster1.getValue( col, line, value, band1 );
73 outputRaster1Ptr->setValue( col, line, value, 0 );
74 outputRaster1Ptr->setValue( col, line, value, 1 );
75 outputRaster1Ptr->setValue( col, line, value, 2 );
78 std::map<std::string, std::string> rInfo2;
79 rInfo2[
"URI"] = tifFileNameBeginning +
"_raster2.tif";
81 std::vector<te::rst::BandProperty*> bandsProperties2;
84 bandsProperties2[0]->m_noDataValue = 0;
92 std::unique_ptr< te::rst::Raster > outputRaster2Ptr(
94 BOOST_CHECK( outputRaster2Ptr.get() );
96 for( line = 0 ; line < raster2.getNumberOfRows() ; ++
line )
97 for( col = 0 ; col < raster2.getNumberOfColumns() ; ++
col )
99 raster2.getValue( col, line, value, band2 );
100 outputRaster2Ptr->setValue( col, line, value, 0 );
101 outputRaster2Ptr->setValue( col, line, value, 1 );
102 outputRaster2Ptr->setValue( col, line, value, 2 );
105 std::vector< te::gm::GTParameters::TiePoint >::const_iterator itB = tiePoints.begin();
106 const std::vector< te::gm::GTParameters::TiePoint >::const_iterator itE =
111 BOOST_CHECK( ((
unsigned int)(itB->first.x)) < outputRaster1Ptr->getNumberOfColumns() );
112 BOOST_CHECK( ((
unsigned int)(itB->first.y)) < outputRaster1Ptr->getNumberOfRows() );
113 outputRaster1Ptr->setValue( (
unsigned int)(itB->first.x), (
unsigned int)(itB->first.y), 255, 1 );
115 BOOST_CHECK( ((
unsigned int)(itB->second.x)) < outputRaster2Ptr->getNumberOfColumns() );
116 BOOST_CHECK( ((
unsigned int)(itB->second.y)) < outputRaster2Ptr->getNumberOfRows() );
117 outputRaster2Ptr->setValue( (
unsigned int)(itB->second.x), (
unsigned int)(itB->second.y), 255, 1 );
127 std::map<std::string, std::string> inputRasterInfo;
128 inputRasterInfo[
"URI"] = TERRALIB_DATA_DIR
129 "/geotiff/cbers_b2_crop.tif";
133 BOOST_CHECK( inputRasterPointer.get() );
156 BOOST_CHECK( algorithmInstance.
initialize( algoInputParams ) );
157 BOOST_CHECK( algorithmInstance.
execute( algoOutputParams ) );
161 saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRasterPointer, 0,
162 algoOutputParams.
m_tiePoints,
"terralib_rp_tiepointslocator_test_MoravecStrategySameImage" );
164 BOOST_CHECK( algoOutputParams.
m_tiePoints.size() >= (size_t)866 );
171 std::map<std::string, std::string> inputRasterInfo;
172 inputRasterInfo[
"URI"] = TERRALIB_DATA_DIR
173 "/geotiff/cbers_b2_crop.tif";
177 BOOST_CHECK( inputRasterPointer.get() );
179 std::map<std::string, std::string> inputRaster2Info;
180 inputRaster2Info[
"URI"] = TERRALIB_DATA_DIR
181 "/geotiff/cbers_b2_crop_upsampled.tif";
184 inputRaster2Info ) );
185 BOOST_CHECK( inputRaster2Pointer.get() );
200 inputRaster2Pointer->getResolutionX();
202 inputRaster2Pointer->getResolutionY();
212 BOOST_CHECK( algorithmInstance.
initialize( algoInputParams ) );
213 BOOST_CHECK( algorithmInstance.
execute( algoOutputParams ) );
217 saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRaster2Pointer, 0,
218 algoOutputParams.
m_tiePoints,
"terralib_rp_tiepointslocator_test_MoravecStrategyUpsampledImage" );
220 BOOST_CHECK( algoOutputParams.
m_tiePoints.size() >= (size_t)866 );
227 std::map<std::string, std::string> inputRasterInfo;
228 inputRasterInfo[
"URI"] = TERRALIB_DATA_DIR
229 "/geotiff/cbers_b2_crop.tif";
233 BOOST_CHECK( inputRasterPointer.get() );
235 std::map<std::string, std::string> inputRaster2Info;
236 inputRaster2Info[
"URI"] = TERRALIB_DATA_DIR
237 "/geotiff/cbers_b2_crop_90clockw_rotation.tif";
240 inputRaster2Info ) );
241 BOOST_CHECK( inputRaster2Pointer.get() );
264 BOOST_CHECK( algorithmInstance.
initialize( algoInputParams ) );
265 BOOST_CHECK( algorithmInstance.
execute( algoOutputParams ) );
269 saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRaster2Pointer, 0,
270 algoOutputParams.
m_tiePoints,
"terralib_rp_tiepointslocator_test_MoravecStrategy90ClkWRotationImage" );
272 BOOST_CHECK( algoOutputParams.
m_tiePoints.size() >= (size_t)854 );
279 std::map<std::string, std::string> inputRaster1Info;
280 inputRaster1Info[
"URI"] = TERRALIB_DATA_DIR
281 "/geotiff/cbers_b2_crop.tif";
284 inputRaster1Info ) );
285 BOOST_CHECK( inputRaster1Pointer.get() );
287 std::map<std::string, std::string> inputRaster2Info;
288 inputRaster2Info[
"URI"] = TERRALIB_DATA_DIR
289 "/geotiff/cbers_b2_crop_contrast_halfsampled_90rotation.tif";
292 inputRaster2Info ) );
293 BOOST_CHECK( inputRaster2Pointer.get() );
318 BOOST_CHECK( algorithmInstance.
initialize( algoInputParams ) );
319 BOOST_CHECK( algorithmInstance.
execute( algoOutputParams ) );
323 saveImagesAndTiePoints( *inputRaster1Pointer, 0, *inputRaster2Pointer, 0,
324 algoOutputParams.
m_tiePoints,
"terralib_rp_tiepointslocator_test_MoravecStrategyHalfRotated90Image" );
326 BOOST_CHECK( algoOutputParams.
m_tiePoints.size() >= (size_t)200 );
333 std::map<std::string, std::string> inputRasterInfo;
334 inputRasterInfo[
"URI"] = TERRALIB_DATA_DIR
335 "/geotiff/cbers_b2_crop.tif";
339 BOOST_CHECK( inputRasterPointer.get() );
370 BOOST_CHECK( algorithmInstance.
initialize( algoInputParams ) );
371 BOOST_CHECK( algorithmInstance.
execute( algoOutputParams ) );
375 saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRasterPointer, 0,
376 algoOutputParams.
m_tiePoints,
"terralib_rp_tiepointslocator_test_MoravecStrategySameImageDifBoxes" );
378 BOOST_CHECK( algoOutputParams.
m_tiePoints.size() >= (size_t)189 );
385 std::map<std::string, std::string> inputRasterInfo;
386 inputRasterInfo[
"URI"] = TERRALIB_DATA_DIR
387 "/geotiff/cbers_b2_crop.tif";
391 BOOST_CHECK( inputRasterPointer.get() );
414 BOOST_CHECK( algorithmInstance.
initialize( algoInputParams ) );
415 BOOST_CHECK( algorithmInstance.
execute( algoOutputParams ) );
419 saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRasterPointer, 0,
420 algoOutputParams.
m_tiePoints,
"terralib_rp_tiepointslocator_test_MoravecStrategyMultipleThreads" );
422 BOOST_CHECK( algoOutputParams.
m_tiePoints.size() >= (size_t)700 );
429 std::map<std::string, std::string> inputRasterInfo;
430 inputRasterInfo[
"URI"] = TERRALIB_DATA_DIR
431 "/geotiff/cbers2b_hrc_crop.tif";
435 BOOST_CHECK( inputRasterPointer.get() );
459 BOOST_CHECK( algorithmInstance.
initialize( algoInputParams ) );
460 BOOST_CHECK( algorithmInstance.
execute( algoOutputParams ) );
464 saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRasterPointer, 0,
465 algoOutputParams.
m_tiePoints,
"terralib_rp_tiepointslocator_test_MoravecStrategyRescaleFactor" );
467 BOOST_CHECK( algoOutputParams.
m_tiePoints.size() >= (size_t)992 );
474 std::map<std::string, std::string> inputRasterInfo;
475 inputRasterInfo[
"URI"] = TERRALIB_DATA_DIR
476 "/geotiff/cbers_b2_crop.tif";
480 BOOST_CHECK( inputRasterPointer.get() );
503 BOOST_CHECK( algorithmInstance.
initialize( algoInputParams ) );
504 BOOST_CHECK( algorithmInstance.
execute( algoOutputParams ) );
508 saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRasterPointer, 0,
509 algoOutputParams.
m_tiePoints,
"terralib_rp_tiepointslocator_test_SurfStrategySameImage" );
511 BOOST_CHECK( algoOutputParams.
m_tiePoints.size() >= (size_t)1500 );
518 std::map<std::string, std::string> inputRasterInfo;
519 inputRasterInfo[
"URI"] = TERRALIB_DATA_DIR
520 "/geotiff/cbers_b2_crop.tif";
524 BOOST_CHECK( inputRasterPointer.get() );
526 std::map<std::string, std::string> inputRaster2Info;
527 inputRaster2Info[
"URI"] = TERRALIB_DATA_DIR
528 "/geotiff/cbers_b2_crop_upsampled.tif";
531 inputRaster2Info ) );
532 BOOST_CHECK( inputRaster2Pointer.get() );
548 inputRaster2Pointer->getResolutionX();
550 inputRaster2Pointer->getResolutionY();
559 BOOST_CHECK( algorithmInstance.
initialize( algoInputParams ) );
560 BOOST_CHECK( algorithmInstance.
execute( algoOutputParams ) );
564 saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRaster2Pointer, 0,
565 algoOutputParams.
m_tiePoints,
"terralib_rp_tiepointslocator_test_SurfStrategyUpsampledImage" );
567 BOOST_CHECK( algoOutputParams.
m_tiePoints.size() >= (size_t)1700 );
574 std::map<std::string, std::string> inputRasterInfo;
575 inputRasterInfo[
"URI"] = TERRALIB_DATA_DIR
576 "/geotiff/cbers_b2_crop.tif";
580 BOOST_CHECK( inputRasterPointer.get() );
582 std::map<std::string, std::string> inputRaster2Info;
583 inputRaster2Info[
"URI"] = TERRALIB_DATA_DIR
584 "/geotiff/cbers_b2_crop_90clockw_rotation.tif";
587 inputRaster2Info ) );
588 BOOST_CHECK( inputRaster2Pointer.get() );
611 BOOST_CHECK( algorithmInstance.
initialize( algoInputParams ) );
612 BOOST_CHECK( algorithmInstance.
execute( algoOutputParams ) );
616 saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRaster2Pointer, 0,
617 algoOutputParams.
m_tiePoints,
"terralib_rp_tiepointslocator_test_SurfStrategy90ClkWRotationImage" );
619 BOOST_CHECK( algoOutputParams.
m_tiePoints.size() >= (size_t)1268 );
626 std::map<std::string, std::string> inputRasterInfo;
627 inputRasterInfo[
"URI"] = TERRALIB_DATA_DIR
628 "/geotiff/cbers_b2_crop.tif";
632 BOOST_CHECK( inputRasterPointer.get() );
663 BOOST_CHECK( algorithmInstance.
initialize( algoInputParams ) );
664 BOOST_CHECK( algorithmInstance.
execute( algoOutputParams ) );
668 saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRasterPointer, 0,
669 algoOutputParams.
m_tiePoints,
"terralib_rp_tiepointslocator_test_SurfStrategySameImageDifBoxes" );
671 BOOST_CHECK( algoOutputParams.
m_tiePoints.size() >= (size_t)1081 );
678 std::map<std::string, std::string> inputRaster1Info;
679 inputRaster1Info[
"URI"] = TERRALIB_DATA_DIR
680 "/geotiff/cbers_b2_crop.tif";
683 inputRaster1Info ) );
684 BOOST_CHECK( inputRaster1Pointer.get() );
686 std::map<std::string, std::string> inputRaster2Info;
687 inputRaster2Info[
"URI"] = TERRALIB_DATA_DIR
688 "/geotiff/cbers_b2_crop_contrast_halfsampled_90rotation.tif";
691 inputRaster2Info ) );
692 BOOST_CHECK( inputRaster2Pointer.get() );
717 BOOST_CHECK( algorithmInstance.
initialize( algoInputParams ) );
718 BOOST_CHECK( algorithmInstance.
execute( algoOutputParams ) );
722 saveImagesAndTiePoints( *inputRaster1Pointer, 0, *inputRaster2Pointer, 0,
723 algoOutputParams.
m_tiePoints,
"terralib_rp_tiepointslocator_test_SurfStrategyHalfRotated90Image" );
725 BOOST_CHECK( algoOutputParams.
m_tiePoints.size() >= (size_t)882 );
732 std::map<std::string, std::string> inputRasterInfo;
733 inputRasterInfo[
"URI"] = TERRALIB_DATA_DIR
734 "/geotiff/cbers_b2_crop.tif";
738 BOOST_CHECK( inputRasterPointer.get() );
761 BOOST_CHECK( algorithmInstance.
initialize( algoInputParams ) );
762 BOOST_CHECK( algorithmInstance.
execute( algoOutputParams ) );
766 saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRasterPointer, 0,
767 algoOutputParams.
m_tiePoints,
"terralib_rp_tiepointslocator_test_SurfStrategyMultipleThreads" );
769 BOOST_CHECK( algoOutputParams.
m_tiePoints.size() >= (size_t)400 );
776 std::map<std::string, std::string> inputRasterInfo;
777 inputRasterInfo[
"URI"] = TERRALIB_DATA_DIR
778 "/geotiff/cbers2b_hrc_crop.tif";
782 BOOST_CHECK( inputRasterPointer.get() );
806 BOOST_CHECK( algorithmInstance.
initialize( algoInputParams ) );
807 BOOST_CHECK( algorithmInstance.
execute( algoOutputParams ) );
811 saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRasterPointer, 0,
812 algoOutputParams.
m_tiePoints,
"terralib_rp_tiepointslocator_test_SurfStrategyRescaleFactor" );
814 BOOST_CHECK( algoOutputParams.
m_tiePoints.size() >= (size_t)1540 );
816 BOOST_AUTO_TEST_SUITE_END()
std::vector< te::gm::GTParameters::TiePoint > m_tiePoints
The generated tie-points (te::gm::GTParameters::TiePoint::first are raster 1 line/column indexes...
A raster band description.
Red channel color interpretation.
TiePointsLocator SURF strategy parameters.
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
TiePointsLocator Moravec strategy parameters.
This file contains include headers for the TerraLib Raster Processing module.
BOOST_AUTO_TEST_CASE(moravecStrategySameImage_test)
TiePointsLocator output parameters.
BOOST_AUTO_TEST_SUITE(tiePointsLocator_tests) void saveImagesAndTiePoints(const te
static Raster * make()
It creates and returns an empty raster with default raster driver.
Blue channel color interpretation.
A rectified grid is the spatial support for raster data.
Green channel color interpretation.
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
static Raster * open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)
It opens a raster with the given parameters and default raster driver.