Ejemplo n.º 1
0
 /** \brief Resets the FeatureWarping.
  *
  */
 void reset(){
   affineTransform_.setIdentity();
   valid_pixelCorners_ = false;
   valid_bearingCorners_ = false;
   valid_affineTransform_ = true;
   isIdentity_ = true;
 }
Ejemplo n.º 2
0
// Test isPatchInFrame
TEST_F(PatchTesting, isPatchInFrameWithWarping) {
  Eigen::Matrix2f aff;
  aff.setIdentity();
  warp_.set_affineTransfrom(aff);
  c_.set_c(cv::Point2f(0,0));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_)),false);
  c_.set_c(cv::Point2f(patchSize_/2-0.1,patchSize_/2-0.1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_)),false);
  c_.set_c(cv::Point2f(patchSize_/2,patchSize_/2));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_)),true);
  c_.set_c(cv::Point2f(patchSize_/2+0.1,patchSize_/2+0.1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_)),true);
  c_.set_c(cv::Point2f(imgSize_-patchSize_/2-0.1,imgSize_-patchSize_/2-0.1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_)),true);
  c_.set_c(cv::Point2f(imgSize_-patchSize_/2,imgSize_-patchSize_/2));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_)),true);
  c_.set_c(cv::Point2f(imgSize_-patchSize_/2+0.1,imgSize_-patchSize_/2+0.1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_)),false);
  c_.set_c(cv::Point2f(imgSize_,imgSize_));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_)),false);
  c_.set_c(cv::Point2f(0,0));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_),true),false);
  c_.set_c(cv::Point2f(patchSize_/2+1-0.1,patchSize_/2+1-0.1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_),true),false);
  c_.set_c(cv::Point2f(patchSize_/2+1,patchSize_/2+1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_),true),true);
  c_.set_c(cv::Point2f(patchSize_/2+1+0.1,patchSize_/2+1+0.1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_),true),true);
  c_.set_c(cv::Point2f(imgSize_-patchSize_/2-1-0.1,imgSize_-patchSize_/2-1-0.1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_),true),true);
  c_.set_c(cv::Point2f(imgSize_-patchSize_/2-1,imgSize_-patchSize_/2-1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_),true),true);
  c_.set_c(cv::Point2f(imgSize_-patchSize_/2-1+0.1,imgSize_-patchSize_/2-1+0.1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_),true),false);
  c_.set_c(cv::Point2f(imgSize_,imgSize_));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_),true),false);
  aff << 0, -1, 1, 0;
  warp_.set_affineTransfrom(aff);
  c_.set_c(cv::Point2f(0,0));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_)),false);
  c_.set_c(cv::Point2f(patchSize_/2-0.1,patchSize_/2-0.1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_)),false);
  c_.set_c(cv::Point2f(patchSize_/2,patchSize_/2));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_)),true);
  c_.set_c(cv::Point2f(patchSize_/2+0.1,patchSize_/2+0.1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_)),true);
  c_.set_c(cv::Point2f(imgSize_-patchSize_/2-0.1,imgSize_-patchSize_/2-0.1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_)),true);
  c_.set_c(cv::Point2f(imgSize_-patchSize_/2,imgSize_-patchSize_/2));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_)),true);
  c_.set_c(cv::Point2f(imgSize_-patchSize_/2+0.1,imgSize_-patchSize_/2+0.1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_)),false);
  c_.set_c(cv::Point2f(imgSize_,imgSize_));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_)),false);
  c_.set_c(cv::Point2f(0,0));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_),true),false);
  c_.set_c(cv::Point2f(patchSize_/2+1-0.1,patchSize_/2+1-0.1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_),true),false);
  c_.set_c(cv::Point2f(patchSize_/2+1,patchSize_/2+1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_),true),true);
  c_.set_c(cv::Point2f(patchSize_/2+1+0.1,patchSize_/2+1+0.1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_),true),true);
  c_.set_c(cv::Point2f(imgSize_-patchSize_/2-1-0.1,imgSize_-patchSize_/2-1-0.1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_),true),true);
  c_.set_c(cv::Point2f(imgSize_-patchSize_/2-1,imgSize_-patchSize_/2-1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_),true),true);
  c_.set_c(cv::Point2f(imgSize_-patchSize_/2-1+0.1,imgSize_-patchSize_/2-1+0.1));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_),true),false);
  c_.set_c(cv::Point2f(imgSize_,imgSize_));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_),true),false);
  aff << cos(M_PI/6.0), -sin(M_PI/6.0), sin(M_PI/6.0), cos(M_PI/6.0);
  warp_.set_affineTransfrom(aff);
  c_.set_c(cv::Point2f((sin(M_PI/6.0)+cos(M_PI/6.0))*patchSize_/2+1e-6,(sin(M_PI/6.0)+cos(M_PI/6.0))*patchSize_/2+1e-6));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_)),true);
  c_.set_c(cv::Point2f((sin(M_PI/6.0)+cos(M_PI/6.0))*patchSize_/2+1e-6,(sin(M_PI/6.0)+cos(M_PI/6.0))*patchSize_/2-1e-6));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_)),false);
  c_.set_c(cv::Point2f((sin(M_PI/6.0)+cos(M_PI/6.0))*patchSize_/2-1e-6,(sin(M_PI/6.0)+cos(M_PI/6.0))*patchSize_/2+1e-6));
  ASSERT_EQ(p_.isPatchInFrame(img1_,c_.get_c(),warp_.get_affineTransform(&c_)),false);
}