-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PCLVisualizer: save and restore camera information #703
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,8 @@ namespace pcl | |
* - g, G : display scale grid (on/off) | ||
* - u, U : display lookup table (on/off) | ||
* - r, R [+ ALT] : reset camera [to viewpoint = {0, 0, 0} -> center_{x, y, z}] | ||
* - CTRL + s, S : save camera parameters | ||
* - CTRL + r, R : restore camera parameters | ||
* - ALT + s, S : turn stereo mode on/off | ||
* - ALT + f, F : switch between maximized window mode and original size | ||
* - l, L : list all available geometric and color handlers for the current actor map | ||
|
@@ -115,7 +117,7 @@ namespace pcl | |
max_win_height_ (), max_win_width_ (), grid_enabled_ (), grid_actor_ (), lut_enabled_ (), | ||
lut_actor_ (), snapshot_writer_ (), wif_ (), mouse_signal_ (), keyboard_signal_ (), | ||
point_picking_signal_ (), area_picking_signal_ (), stereo_anaglyph_mask_default_ (), | ||
mouse_callback_ (), modifier_ () | ||
mouse_callback_ (), modifier_ (), camera_file_ (), camera_ (), camera_saved_ (), win_ () | ||
{} | ||
|
||
/** \brief Empty destructor */ | ||
|
@@ -184,6 +186,56 @@ namespace pcl | |
void | ||
saveScreenshot (const std::string &file); | ||
|
||
/** \brief Save the camera parameters to disk, as a .cam file. | ||
* \param[in] file the name of the .cam file | ||
*/ | ||
bool | ||
saveCameraParameters (const std::string &file); | ||
|
||
/** \brief Get camera parameters and save them to a \ref pcl::visualization::Camera. | ||
* \param[out] camera the name of the \ref pcl::visualization::Camera | ||
*/ | ||
void | ||
getCameraParameters (Camera &camera); | ||
|
||
/** \brief Load camera parameters from a camera parameter file. | ||
* \param[in] file the name of the camera parameter file | ||
*/ | ||
bool | ||
loadCameraParameters (const std::string &file); | ||
|
||
/** \brief Set the camera parameters via an intrinsics and and extrinsics matrix | ||
* \note This assumes that the pixels are square and that the center of the image is at the center of the sensor. | ||
* \param[in] intrinsics the intrinsics that will be used to compute the VTK camera parameters | ||
* \param[in] extrinsics the extrinsics that will be used to compute the VTK camera parameters | ||
* \param[in] viewport the viewport to modify camera of (0 modifies all cameras) | ||
*/ | ||
void | ||
setCameraParameters (const Eigen::Matrix3f &intrinsics, const Eigen::Matrix4f &extrinsics, int viewport = 0); | ||
|
||
/** \brief Set the camera parameters by given a full camera data structure. | ||
* \param[in] camera camera structure containing all the camera parameters. | ||
* \param[in] viewport the viewport to modify camera of (0 modifies all cameras) | ||
*/ | ||
void | ||
setCameraParameters (const Camera &camera, int viewport = 0); | ||
|
||
/** \brief Set camera file for camera parameter saving/restoring. | ||
* \param[in] file the name of the camera parameter file | ||
*/ | ||
void | ||
setCameraFile (const std::string file) | ||
{ | ||
camera_file_ = file; | ||
} | ||
|
||
/** \brief Get camera file for camera parameter saving/restoring. */ | ||
std::string | ||
getCameraFile () const | ||
{ | ||
return (camera_file_); | ||
} | ||
|
||
/** \brief Change the default keyboard modified from ALT to a different special key. | ||
* Allowed values are: | ||
* - INTERACTOR_KB_MOD_ALT | ||
|
@@ -284,6 +336,21 @@ namespace pcl | |
void | ||
zoomOut (); | ||
|
||
/** \brief Get camera parameters from a string vector. | ||
* \param[in] camera A string vector: | ||
* Clipping Range, Focal Point, Position, ViewUp, Distance, Field of View Y, Window Size, Window Pos. | ||
* Values in each string are seperated by a ',' | ||
*/ | ||
bool | ||
getCameraParameters (const std::vector<std::string> &camera); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this needs more explanation, it's very unclear what this function is doing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The strings in the vector are: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry, the brief should be |
||
|
||
/** \brief Set render window. */ | ||
void | ||
setRenderWindow (const vtkSmartPointer<vtkRenderWindow> &win) | ||
{ | ||
win_ = win; | ||
} | ||
|
||
/** \brief True if we're using red-blue colors for anaglyphic stereo, false if magenta-green. */ | ||
bool stereo_anaglyph_mask_default_; | ||
|
||
|
@@ -293,7 +360,19 @@ namespace pcl | |
/** \brief The keyboard modifier to use. Default: Alt. */ | ||
InteractorKeyboardModifier modifier_; | ||
|
||
/** \brief Camera file for camera parameter saving/restoring. */ | ||
std::string camera_file_; | ||
/** \brief A \ref pcl::visualization::Camera for camera parameter saving/restoring. */ | ||
Camera camera_; | ||
/** \brief A \ref pcl::visualization::Camera is saved or not. */ | ||
bool camera_saved_; | ||
/** \brief The render window. | ||
* Only used when interactor maybe not available | ||
*/ | ||
vtkSmartPointer<vtkRenderWindow> win_; | ||
|
||
friend class PointPickingCallback; | ||
friend class PCLVisualizer; | ||
}; | ||
|
||
/** \brief PCL histogram visualizer interactory style class. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to store the file name inside the interactor object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I think so. Keyboard events are handled in the interactor object and we need the file name in the interactor object. The file name is get/calculated from the command line input, so if no file name is stored, we have to store the command line input.