mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 06:03:15 +08:00
resetCamera, resetViewpoint in Viz3d
This commit is contained in:
parent
4aa61dee50
commit
ffbb5e9524
@ -38,6 +38,9 @@ namespace cv
|
||||
Affine3f getViewerPose();
|
||||
void setViewerPose(const Affine3f &pose);
|
||||
|
||||
void resetCameraViewpoint (const String &id);
|
||||
void resetCamera();
|
||||
|
||||
void convertToWindowCoordinates(const Point3d &pt, Point3d &window_coord);
|
||||
void converTo3DRay(const Point3d &window_coord, Point3d &origin, Vec3d &direction);
|
||||
|
||||
|
@ -67,6 +67,9 @@ cv::viz::Camera cv::viz::Viz3d::getCamera() const { return impl_->getCamera(); }
|
||||
void cv::viz::Viz3d::setViewerPose(const Affine3f &pose) { impl_->setViewerPose(pose); }
|
||||
cv::Affine3f cv::viz::Viz3d::getViewerPose() { return impl_->getViewerPose(); }
|
||||
|
||||
void cv::viz::Viz3d::resetCameraViewpoint (const String &id) { impl_->resetCameraViewpoint(id); }
|
||||
void cv::viz::Viz3d::resetCamera() { impl_->resetCamera(); }
|
||||
|
||||
void cv::viz::Viz3d::convertToWindowCoordinates(const Point3d &pt, Point3d &window_coord) { impl_->convertToWindowCoordinates(pt, window_coord); }
|
||||
void cv::viz::Viz3d::converTo3DRay(const Point3d &window_coord, Point3d &origin, Vec3d &direction) { impl_->converTo3DRay(window_coord, origin, direction); }
|
||||
|
||||
|
@ -421,21 +421,21 @@ void cv::viz::Viz3d::VizImpl::converTo3DRay(const Point3d &window_coord, Point3d
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void cv::viz::Viz3d::VizImpl::resetCameraViewpoint (const std::string &id)
|
||||
void cv::viz::Viz3d::VizImpl::resetCameraViewpoint (const String &id)
|
||||
{
|
||||
vtkSmartPointer<vtkMatrix4x4> camera_pose;
|
||||
static WidgetActorMap::iterator it = widget_actor_map_->find (id);
|
||||
if (it != widget_actor_map_->end ())
|
||||
{
|
||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(it->second);
|
||||
CV_Assert("Widget is not 3D." && actor);
|
||||
camera_pose = actor->GetUserMatrix();
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
// Prevent a segfault
|
||||
if (!camera_pose)
|
||||
return;
|
||||
if (!camera_pose) return;
|
||||
|
||||
vtkSmartPointer<vtkCamera> cam = renderer_->GetActiveCamera ();
|
||||
cam->SetPosition (camera_pose->GetElement (0, 3),
|
||||
@ -455,6 +455,12 @@ void cv::viz::Viz3d::VizImpl::resetCameraViewpoint (const std::string &id)
|
||||
renderer_->Render ();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
void cv::viz::Viz3d::VizImpl::resetCamera()
|
||||
{
|
||||
renderer_->ResetCamera();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
void cv::viz::Viz3d::VizImpl::setRepresentationToSurface()
|
||||
{
|
||||
|
@ -49,18 +49,14 @@ public:
|
||||
void setRepresentationToSurface();
|
||||
void setRepresentationToPoints();
|
||||
void setRepresentationToWireframe();
|
||||
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////////////
|
||||
// All camera methods to refactor into set/getViewwerPose, setCamera()
|
||||
// and 'Camera' class itself with various constructors/fields
|
||||
|
||||
void setCamera(const Camera &camera);
|
||||
Camera getCamera() const;
|
||||
|
||||
/** \brief Reset the camera direction from {0, 0, 0} to the center_{x, y, z} of a given dataset.
|
||||
* \param[in] id the point cloud object id (default: cloud) */
|
||||
void resetCameraViewpoint (const String& id = "cloud");
|
||||
void resetCameraViewpoint(const String& id);
|
||||
void resetCamera();
|
||||
|
||||
void setViewerPose(const Affine3f &pose);
|
||||
Affine3f getViewerPose();
|
||||
|
Loading…
Reference in New Issue
Block a user