35 #include <gtest/gtest.h> 41 static const float eps = 1e-6;
44 float&
pixel(IplImage* image,
int row,
int col,
int chan)
46 return *(((
float*)(image->imageData + row*image->widthStep))+image->nChannels*col + chan);
54 source_image_ = cvCreateImage( cvSize(3,3), IPL_DEPTH_32F, 2);
55 pixel(source_image_, 0, 0, 0) = 10;
56 pixel(source_image_, 0, 1, 0) = 20;
57 pixel(source_image_, 0, 2, 0) = 30;
58 pixel(source_image_, 1, 0, 0) = 40;
59 pixel(source_image_, 1, 1, 0) = 50;
60 pixel(source_image_, 1, 2, 0) = 60;
61 pixel(source_image_, 2, 0, 0) = 70;
62 pixel(source_image_, 2, 1, 0) = 80;
63 pixel(source_image_, 2, 2, 0) = 90;
65 pixel(source_image_, 0, 0, 1) = 1;
66 pixel(source_image_, 0, 1, 1) = 2;
67 pixel(source_image_, 0, 2, 1) = 3;
68 pixel(source_image_, 1, 0, 1) = 4;
69 pixel(source_image_, 1, 1, 1) = 5;
70 pixel(source_image_, 1, 2, 1) = 6;
71 pixel(source_image_, 2, 0, 1) = 7;
72 pixel(source_image_, 2, 1, 1) = 8;
73 pixel(source_image_, 2, 2, 1) = 9;
80 image_points_.resize(3);
81 image_points_[0].x = 0.0;
82 image_points_[0].y = 0.0;
84 image_points_[1].x = 0.5;
85 image_points_[1].y = 0.5;
87 image_points_[2].x = 1;
88 image_points_[2].y = 0.75;
91 success = interp_.interp(image_points_, source_image_, positions_, velocities_);
97 cvReleaseImage(&source_image_);
109 ASSERT_EQ(positions_.size(), (
unsigned int) 3);
110 EXPECT_NEAR(positions_[0], 10.0,
eps);
111 EXPECT_NEAR(positions_[1], 30.0,
eps);
112 EXPECT_NEAR(positions_[2], 42.5,
eps);
117 ASSERT_EQ(velocities_.size(), (
unsigned int) 3);
118 EXPECT_NEAR(velocities_[0], 1.0,
eps);
119 EXPECT_NEAR(velocities_[1], 3.0,
eps);
120 EXPECT_NEAR(velocities_[2], 4.25,
eps);
124 int main(
int argc,
char **argv){
125 testing::InitGoogleTest(&argc, argv);
126 return RUN_ALL_TESTS();
float & pixel(IplImage *image, int row, int col, int chan)
vector< geometry_msgs::Point > image_points_
JointImageInterpolator interp_
int main(int argc, char **argv)
vector< float > velocities_
vector< float > positions_
TEST_F(JointImageInterpolator_EasyTests, positionTests)