test_gaussian.cpp
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2010, Willow Garage, Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of Willow Garage, Inc. nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  *
00035  */
00038 #include <gtest/gtest.h>
00039 #include <pcl/common/gaussian.h>
00040 
00041 TEST(PCL, GaussianKernel)
00042 {
00043   Eigen::VectorXf kernel(31);
00044   kernel << 0.000888059f, 0.00158611f, 0.00272177f, 0.00448744f, 0.00710844f, 0.0108188f, 0.0158201f, 0.0222264f, 0.0300025f, 0.0389112f, 0.0484864f, 0.0580487f, 0.0667719f, 0.0737944f, 0.0783576f, 0.0799405f, 0.0783576f, 0.0737944f, 0.0667719f, 0.0580487f, 0.0484864f, 0.0389112f, 0.0300025f, 0.0222264f, 0.0158201f, 0.0108188f, 0.00710844f, 0.00448744f, 0.00272177f, 0.00158611f, 0.000888059f;
00045 
00046   Eigen::VectorXf derivative(35);
00047   derivative << 0.000168673f, 0.000307151f, 0.000535285f, 0.000892304f, 0.00142183f, 0.00216388f, 0.00314209f, 0.00434741f, 0.00572143f, 0.00714516f, 0.00843934f, 0.00938163f, 0.00974186f, 0.0093305f, 0.00804947f, 0.0059307f, 0.00314871f, 0.0f, -0.00314871f, -0.0059307f, -0.00804947f, -0.0093305f, -0.00974186f, -0.00938163f, -0.00843934f, -0.00714516f, -0.00572143f, -0.00434741f, -0.00314209f, -0.00216388f, -0.00142183f, -0.000892304f, -0.000535285f, -0.000307151f, -0.000168673f;
00048   pcl::GaussianKernel gk;
00049   Eigen::VectorXf computed_kernel, computed_derivative;
00050 
00051   // Test kernel only version
00052   gk.compute(5, computed_kernel);
00053   EXPECT_EQ(kernel.size (), computed_kernel.size ());
00054   for(int i = 0; i < kernel.size (); i++)
00055     EXPECT_NEAR(kernel[i], computed_kernel[i], 1e-4);
00056 
00057   // Test kernel and derivative version
00058   gk.compute(5, computed_kernel, computed_derivative);
00059   EXPECT_EQ(kernel.size (), computed_kernel.size ());
00060   for(int i = 0; i < kernel.size (); i++)
00061     EXPECT_NEAR(kernel[i], computed_kernel[i], 1e-4);
00062   EXPECT_EQ(derivative.size (), computed_derivative.size ());
00063   for(int i = 0; i < derivative.size (); i++)
00064     EXPECT_NEAR(derivative[i], computed_derivative[i], 1e-4);
00065 }
00066 
00067 int main (int argc, char** argv)
00068 {
00069   testing::InitGoogleTest (&argc, argv);
00070   return (RUN_ALL_TESTS ());
00071 }


pcl
Author(s): Open Perception
autogenerated on Mon Oct 6 2014 03:18:17