Skip to content

开启跟踪后,下一次再重新注册,姿态出现BUG #25

@liuchangji

Description

@liuchangji

@zz990099 您好, 谢谢您解决了#23 ,在我的测试中,遇到一个BUG

问题描述:

  1. 对一个物体进行第一帧注册,然后跟踪,姿态输出正确。此时再重新执行注册,姿态输出错误。(图3,图4)
  2. 对一个物体连续进行第一帧注册,不执行跟踪相关代码,无论执行多少次注册,输出姿态都是正确的。(如图1,图2)
  3. 也就是说,执行跟踪函数后,如果下一次再重新进行注册,会出现错误。

图1:第0次注册,姿态正确
Image

图2:第1次注册,姿态正确
Image

图3:跟踪打开下,第0次注册,姿态正确

Image

图4:跟踪打开下,第1次注册,姿态错误

Image

可能是使用跟踪track函数后某些姿态缓存没有清除?

测试代码

您可以用如下的代码进行测试,放在test_foundationpose.cpp当中即可
你可以修改 bool if_track = true;来开启关闭是否启动跟踪
每一轮检测后,会弹出图片,按下任意键会进行下一次检测
测试数据在t1.zip文件夹中
t1.zip

void test_track()
{
  std::string refiner_engine_path = "/home/lcjpc/lcj/foundation-pose_tensor-rt/models/refiner_hwc_dynamic_fp16.engine";
  std::string scorer_engine_path  = "/home/lcjpc/lcj/foundation-pose_tensor-rt/models/scorer_hwc_dynamic_fp16.engine";
  std::string demo_data_path      = "/home/lcjpc/lcj/fdpose_tensorRT/test_data/t1";
  std::string demo_textured_obj_path = demo_data_path + "/box_mesh/untitled1.obj";
  std::string demo_textured_map_path = demo_data_path + "/box_mesh/TexturedMeshSimplified_0000_map_Kd.jpg";
  std::string demo_name             = "box";

  auto [foundation_pose, mesh_loader] = CreateModel();
  Eigen::Matrix3f intrinsic_in_mat    = ReadCamK(demo_data_path + "/cam_K.txt");
  const std::string first_rgb_path   = demo_data_path + "/bgr.png";
  const std::string first_depth_path = demo_data_path + "/depth.png";
  const std::string first_mask_path  = demo_data_path + "/mask.png";
  auto [rgb, depth, mask] = ReadRgbDepthMask(first_rgb_path, first_depth_path, first_mask_path);
  bool if_track = true;

  for(int i = 0; i < 5; ++i)
  {
      Eigen::Matrix4f first_pose;
      foundation_pose->Register(rgb.clone(), depth, mask, demo_name_, first_pose,5);
      const Eigen::Vector3f object_dimension = mesh_loader->GetObjectDimension();
      cv::Size image_size = rgb.size();
      cv::Mat imshow = rgb.clone();

      Eigen::Matrix4f draw_pose = detection_6d::ConvertPoseMesh2BBox(first_pose, mesh_loader);
      draw3DBoundingBox(intrinsic_in_mat, draw_pose, image_size.height, image_size.width, object_dimension, imshow);   
        // Eigen::Matrix4f tf_to_center   = Eigen::Matrix4f::Identity();
        // tf_to_center.block<3, 1>(0, 3) = -mesh_loader->GetMeshModelCenter();    
        // out_pose = out_pose * tf_to_center * mesh->GetOrientBounds().inverse(); // !!!!!!!!!!!! 
        // out_pose = out_pose * tf_to_center; // move the frame to the orgin of the mesh
      std::string content;
      if(if_track)
      {
        content = "round " + std::to_string(i) + " track is On";
      } 
      else
      {
        content = "round " + std::to_string(i) + " track is Off";
      } 

      cv::putText(imshow,content,cv::Point(40,40),cv::FONT_HERSHEY_SIMPLEX,1.0,cv::Scalar(0,255,0),2);
      cv::imshow("register", imshow);
      if(if_track)
      {
        FPSCounter counter;
        counter.Start();
        for (int i = 0; i < 5; ++i)
        {
          Eigen::Matrix4f track_pose;
          foundation_pose->Track(rgb.clone(), depth, first_pose, demo_name_, track_pose);
          std::cout << "first_pose: \n" << first_pose << std::endl;
          std::cout << "track_pose: \n" << track_pose << std::endl;
          counter.Count(1);
          cv::cvtColor(rgb, imshow, cv::COLOR_RGB2BGR);
          Eigen::Matrix4f draw_pose = detection_6d::ConvertPoseMesh2BBox(track_pose, mesh_loader);
          // out_pose = out_pose * tf.inverse();
          draw3DBoundingBox(intrinsic_in_mat, draw_pose, image_size.height, image_size.width, object_dimension, imshow);   
          // Eigen::Matrix4f tf_to_center   = Eigen::Matrix4f::Identity();
          // tf_to_center.block<3, 1>(0, 3) = -mesh_loader->GetMeshModelCenter();    
          // out_pose = out_pose * tf_to_center * mesh->GetOrientBounds().inverse(); // !!!!!!!!!!!! 
          // out_pose = out_pose * tf_to_center; // move the frame to the orgin of the mesh
          cv::imshow("track", imshow);
          cv::waitKey(1);
        }         
      }      
      cv::waitKey(0);
  }  
  // LOG(WARNING) << "average fps: " << counter.GetFPS();
}

希望您的回复,谢谢!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions