00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "fasthessian.h"
00032 #ifndef ASRL_FASTHESSIAN_TEST_HPP
00033 #define ASRL_FASTHESSIAN_TEST_HPP
00034
00035 #include "GpuSurfOctave.hpp"
00036 #include "fasthessian.h"
00037 #include "GpuSurfDetectorInternal.hpp"
00038 #include <opencv/highgui.h>
00039 #include <opencv/highgui.hpp>
00040 #include "gpu_area.h"
00041
00043 BOOST_AUTO_TEST_SUITE(asrl_fasthessian)
00044
00045 BOOST_AUTO_TEST_CASE(test_fasthessian)
00046 {
00047
00048
00049
00050 cv::Mat img = cv::imread("../testdata/seq-lt-g-000001.pgm",CV_LOAD_IMAGE_GRAYSCALE);
00051 asrl::GpuSurfConfiguration config;
00052
00053 asrl::GpuSurfDetectorInternal detector1(config);
00054
00055 detector1.buildIntegralImage(img);
00056 detector1.detectKeypoints();
00057
00058 asrl::GpuSurfDetectorInternal detector2(config);
00059
00060 detector2.buildIntegralImage(img);
00061 detector2.detectKeypoints();
00062
00063 for(unsigned i = 0 ; i < detector1.m_config.nOctaves; i++)
00064 {
00065 asrl::GpuSurfOctave & o1 = detector1.m_octaves[i];
00066 asrl::GpuSurfOctave & o2 = detector2.m_octaves[i];
00067
00068 o1.pullHessianFromDevice();
00069 o2.pullHessianFromDevice();
00070 size_t hSize = o1.width() * o1.height() * o1.intervals();
00071 std::cout << "Checking the " << hSize << " elements of octave " << i << std::endl;
00072 BOOST_CHECK_EQUAL_COLLECTIONS( o1.h_hessian(), o1.h_hessian() + hSize, o2.h_hessian(), o2.h_hessian() + hSize );
00073 }
00074
00075 }
00076
00077
00078 BOOST_AUTO_TEST_CASE(test_area_calculation)
00079 {
00080
00081 cv::Mat img = cv::Mat::ones(64,64,CV_8UC1) * 126;
00082 asrl::GpuSurfConfiguration config;
00083
00084 asrl::GpuSurfDetectorInternal detector1(config);
00085
00086 detector1.buildIntegralImage(img);
00087 detector1.detectKeypoints();
00088
00089 asrl::texturize_integral_image(detector1.m_intImg->d_get());
00090 try {
00091
00092 for(int component = 0; component < 7; component++)
00093 {
00094 asrl::eval_component( detector1.m_octaves, detector1.m_config.nOctaves, (asrl::fh_component)component);
00095
00096 std::string cname = "not set";
00097 if(component == 0)
00098 cname = "Dxx";
00099 else if(component == 1)
00100 cname = "Dyy";
00101 else if(component == 2)
00102 cname = "Dxx * Dyy";
00103 else if(component == 3)
00104 cname = "Dxy";
00105 else if(component == 4)
00106 cname = "censure";
00107 else if(component == 5)
00108 cname = "result";
00109 else if(component == 6)
00110 cname = "result---last bit set";
00111 else
00112 ASRL_THROW("Unknown component: " << component);
00113
00114
00115 unsigned o = 0;
00116 {
00117 asrl::GpuSurfOctave & o1 = detector1.m_octaves[o];
00118
00119 o1.pullHessianFromDevice();
00120 size_t hSize = o1.width() * o1.height() * o1.intervals();
00121
00122 for(int r = 1; r < o1.height() - 1; r++)
00123 {
00124 for(int c = 1; c < o1.width() -1 ; c++)
00125 {
00126 for(int i = 0; i < o1.intervals(); i++)
00127 {
00128 try
00129 {
00130 ASRL_ASSERT_LT(fabs(o1(r,c,i)),0.01,"FH entry " << cname << "[" << component << "]" << " at (" << o << "," << i << "," << r << "," << c << ") is too big");
00131 }
00132 catch(std::exception const & e)
00133 {
00134 BOOST_ERROR(e.what());
00135 }
00136 }
00137 }
00138 }
00139 }
00140 }
00141 }
00142 catch(std::exception const & e)
00143 {
00144 BOOST_ERROR(e.what());
00145 }
00146 asrl::fh_untexturizeIntegral();
00147
00148 }
00149
00150 BOOST_AUTO_TEST_SUITE_END()
00151
00152 #endif // ASRL_FASTHESSIAN_TEST_HPP