首页 > 解决方案 > vtkCamera 焦点期望的值的类型和范围是什么?

问题描述

我正在使用 PCL 查看器(使用 VTK)来可视化由 SLAM 算法生成的 3D 点云。我正在尝试渲染机器人在给定姿势(位置和方向)下看到的点云视图。我可以设置相机的位置和 ViewUp 矢量,但我无法将相机的焦点设置为机器人的航向。目前,我正在使用滑块来设置焦点,但我想根据标题以编程方式设置它。

我正在尝试了解 VTKCamera Focal Point 期望的类型(以 rad 为单位的角度/以 m 为单位的距离)和值范围以及它与航向的关系。

我正在更新相机的功能

void Widget::setcamView(){

    //transfrom position
     Eigen::Vector3d position = this->transformpose(Eigen::Vector3d(image_pose.at(pose_ittr).position[0], image_pose.at(pose_ittr).position[1], image_pose.at(pose_ittr).position[2]));

    posx = position(0);
    posy = position(1);
    posz = position(2);

    //transform the pose
    Eigen::Vector3d attitude = this->transformpose(Eigen::Vector3d(image_pose.at(pose_ittr).orientation[0],image_pose.at(pose_ittr).orientation[1],image_pose.at(pose_ittr).orientation[2]));

    roll = attitude(0);
    pitch = attitude(1);
    yaw = attitude(2);

    viewx = ui->viewxhSlider->value();// * std::pow(10,-3);
    viewy = ui->viewyhSlider->value();// * std::pow(10,-3);
    viewz = ui->viewzhSlider->value();// * std::pow(10,-3);

    // debug
    std::cout<<"Positon: "<<posx<<"\t"<<posy<<"\t"<<posz<<std::endl<<
                "View: "<<viewx<<"\t"<<viewy<<"\t"<<viewz<<std::endl<<
               "Orientation: "<<roll<<"\t"<<pitch<<"\t"<<yaw<<std::endl;

    point_cutoffy = ui->ptcutoffhSlider->value();

    if(yaw <=0)
        yaw = yaw * -1;

    viewer->setCameraPosition(posx,posy,posz+1,
                              viewz,viewy,viewz,
                              0, 0, 1, 0);
    viewer->setCameraFieldOfView(1);
    viewer->setCameraClipDistances(point_cutoffx,point_cutoffy,0);

    ui->qvtkWidget->update();
    count++;
}

任何帮助是极大的赞赏。

-谢谢

附言

PCL Viewer Set Camera Implementation(使用VTK)

void pcl::visualization::PCLVisualizer::setCameraPosition (
    double pos_x, double pos_y, double pos_z,
    double view_x, double view_y, double view_z,
    double up_x, double up_y, double up_z,
    int viewport)
{
  rens_->InitTraversal ();
  vtkRenderer* renderer = NULL;
  int i = 0;
  while ((renderer = rens_->GetNextItem ()) != NULL)
  {
    // Modify all renderer's cameras
    if (viewport == 0 || viewport == i)
    {
      vtkSmartPointer<vtkCamera> cam = renderer->GetActiveCamera ();
      cam->SetPosition (pos_x, pos_y, pos_z);
      cam->SetFocalPoint (view_x, view_y, view_z);
      cam->SetViewUp (up_x, up_y, up_z);
      renderer->ResetCameraClippingRange ();
    }
    ++i;
  }
  win_->Render ();
}

标签: vtkpoint-cloud-librarypoint-cloudsqvtkwidget

解决方案


我正在通过同样使用 VTK 的 opencv Viz 处理非常类似的问题。相对于你的问题,我想你可以在这里找到答案


推荐阅读