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 #ifndef ASRL_GPU_AREA_TESTS_HPP
00032 #define ASRL_GPU_AREA_TESTS_HPP
00033
00034 #include "GpuIntegralImageProcessor.hpp"
00035 #include "gpu_area.h"
00036 #include <opencv/highgui.h>
00037 #include <opencv/highgui.hpp>
00038
00040 BOOST_AUTO_TEST_SUITE(asrl_area)
00041
00042 BOOST_AUTO_TEST_CASE(test_area_lookup)
00043 {
00044
00045 cv::Mat image = cv::Mat::zeros(64,64,CV_8UC1);
00046
00047
00048 int cx = 30;
00049 int cy = 30;
00050
00051 for(int r = -1; r < 2; r++)
00052 {
00053 for(int c = -2; c < 3; c++)
00054 {
00055
00056 image.ptr(cy + r)[cx + c] = 255;
00057 }
00058 }
00059
00060
00061 asrl::GpuIntegralImageProcessor iiProc(image.cols, image.rows);
00062 asrl::GpuIntegralImage iimageI(image.cols, image.rows);
00063
00064 iiProc.process(image, iimageI);
00065 cudaArray * iimage = iimageI.d_get();
00066
00067 float area = asrl::iiAreaLookupC(iimage, (float)cx, (float)cy, 5.f, 3.f);
00068 BOOST_CHECK_CLOSE(area, 15.f,0.001f);
00069
00070 area = asrl::iiAreaLookupC(iimage, (float)cx-0.5f, (float)cy, 5.f, 3.f);
00071 BOOST_CHECK_CLOSE(area, 13.5f,0.001f);
00072
00073 area = asrl::iiAreaLookupC(iimage, (float)cx-1, (float)cy, 5.f, 3.f);
00074 BOOST_CHECK_CLOSE(area, 12.f,0.001f);
00075
00076 area = asrl::iiAreaLookupC(iimage, (float)cx-0.5f, (float)cy, 5.f, 3.f);
00077 BOOST_CHECK_CLOSE(area, 13.5f,0.001f);
00078
00079 area = asrl::iiAreaLookupC(iimage, (float)cx+1, (float)cy, 5.f, 3.f);
00080 BOOST_CHECK_CLOSE(area, 12.f,0.001f);
00081
00082 area = asrl::iiAreaLookupC(iimage, (float)cx, (float)cy-1, 5.f, 3.f);
00083 BOOST_CHECK_CLOSE(area, 10.f,0.001f);
00084
00085 area = asrl::iiAreaLookupC(iimage, (float)cx, (float)cy-0.5f, 5.f, 3.f);
00086 BOOST_CHECK_CLOSE(area, 12.5f,0.001f);
00087
00088 area = asrl::iiAreaLookupC(iimage, (float)cx, (float)cy+1, 5.f, 3.f);
00089 BOOST_CHECK_CLOSE(area, 10.f,0.001f);
00090
00091 area = asrl::iiAreaLookupC(iimage, (float)cx, (float)cy+0.5f, 5.f, 3.f);
00092 BOOST_CHECK_CLOSE(area, 12.5f,0.001f);
00093
00094 area = asrl::iiAreaLookupC(iimage, (float)cx-1, (float)cy-1, 5.f, 3.f);
00095 BOOST_CHECK_CLOSE(area, 8.f,0.001f);
00096
00097 area = asrl::iiAreaLookupC(iimage, (float)cx-0.5f, (float)cy-0.5f, 5.f, 3.f);
00098 BOOST_CHECK_CLOSE(area, 11.25f,0.001f);
00099
00100 area = asrl::iiAreaLookupC(iimage, (float)cx+1, (float)cy+1, 5.f, 3.f);
00101 BOOST_CHECK_CLOSE(area, 8.f,0.001f);
00102
00103 area = asrl::iiAreaLookupC(iimage, (float)cx+0.5f, (float)cy+0.5f, 5.f, 3.f);
00104 BOOST_CHECK_CLOSE(area, 11.25f,0.001f);
00105
00106 area = asrl::iiAreaLookupC(iimage, (float)cx-1, (float)cy+1, 5.f, 3.f);
00107 BOOST_CHECK_CLOSE(area, 8.f,0.001f);
00108
00109 area = asrl::iiAreaLookupC(iimage, (float)cx+1, (float)cy-1, 5.f, 3.f);
00110 BOOST_CHECK_CLOSE(area, 8.f,0.001f);
00111
00112 area = asrl::iiAreaLookupC(iimage, (float)cx-0.5f, (float)cy+0.5f, 5.f, 3.f);
00113 BOOST_CHECK_CLOSE(area, 11.25f,0.001f);
00114
00115 area = asrl::iiAreaLookupC(iimage, (float)cx+0.5f, (float)cy-0.5f, 5.f, 3.f);
00116 BOOST_CHECK_CLOSE(area, 11.25f,0.001f);
00117
00118 area = asrl::iiAreaLookupC(iimage, (float)cx-1, (float)cy+1, 5.f, 3.f);
00119 BOOST_CHECK_CLOSE(area, 8.f,0.001f);
00120
00121 area = asrl::iiAreaLookupC(iimage, (float)cx, (float)cy, 3.f, 3.f);
00122 BOOST_CHECK_CLOSE(area, 9.f,0.001f);
00123
00124 area = asrl::iiAreaLookupC(iimage, (float)cx, (float)cy, 3.f, 4.5f);
00125 BOOST_CHECK_CLOSE(area, 9.f,0.001f);
00126
00127 area = asrl::iiAreaLookupC(iimage, (float)cx, (float)cy, 4.5f, 3.f);
00128 BOOST_CHECK_CLOSE(area, 13.5f,0.001f);
00129 }
00130
00131
00132 BOOST_AUTO_TEST_SUITE_END()
00133
00134 #endif // ASRL_GPU_AREA_TESTS_HPP