11 #include <IJsonConvertibleIO.h>
20 namespace visualization {
32 utility::LogInfo(
" Ctrl + P : Enter animation mode and play animation from beginning.");
33 utility::LogInfo(
" Ctrl + R : Enter animation mode, play animation, and record screen.");
34 utility::LogInfo(
" Ctrl + G : Enter animation mode, play animation, and record depth.");
41 utility::LogInfo(
" Ctrl + +/- : Increase/decrease interval between keyframes.");
43 utility::LogInfo(
" Ctrl + A : Add a keyframe right after the current keyframe.");
46 utility::LogInfo(
" Ctrl + N : Add 360 spin right after the current keyframe.");
61 std::string new_window_title =
63 glfwSetWindowTitle(
window_, new_window_title.c_str());
69 bool recording_depth ,
70 bool close_window_when_animation_ends ) {
72 if (view_control.NumOfFrames() == 0) {
76 view_control.SetAnimationMode(
77 ViewControlWithCustomAnimation::AnimationMode::PlayMode);
83 auto trajectory_ptr = std::make_shared<camera::PinholeCameraTrajectory>();
84 bool recording_trajectory = view_control.IsValidPinholeCameraTrajectory();
86 if (recording_depth) {
95 close_window_when_animation_ends,
96 recording_trajectory, trajectory_ptr,
102 std::this_thread::sleep_for(std::chrono::milliseconds(10));
105 if (recording_trajectory) {
107 view_control.ConvertToPinholeCameraParameters(parameter);
108 trajectory_ptr->parameters_.push_back(parameter);
111 if (recording_depth) {
123 view_control.Step(1.0);
126 view_control.SetAnimationMode(
127 ViewControlWithCustomAnimation::AnimationMode::FreeMode);
129 if (recording && recording_trajectory) {
130 if (recording_depth) {
142 if (close_window_when_animation_ends) {
159 GLFWwindow *window,
int key,
int scancode,
int action,
int mods) {
161 if (action == GLFW_RELEASE || view_control.IsPlaying()) {
165 if (mods & GLFW_MOD_CONTROL) {
169 AnimationMode::FreeMode);
171 "[Visualizer] Enter freeview (editing) mode.");
174 view_control.SetAnimationMode(
189 view_control.CaptureTrajectory();
192 view_control.Step(-1.0);
195 view_control.Step(1.0);
197 case GLFW_KEY_LEFT_BRACKET:
198 view_control.GoToFirst();
200 case GLFW_KEY_RIGHT_BRACKET:
201 view_control.GoToLast();
204 view_control.ChangeTrajectoryInterval(1);
206 view_control.GetTrajectoryInterval());
209 view_control.ChangeTrajectoryInterval(-1);
211 view_control.GetTrajectoryInterval());
214 view_control.ToggleTrajectoryLoop();
217 view_control.AddKeyFrame();
219 "[Visualizer] Insert key frame; {} remaining.",
220 view_control.NumOfKeyFrames());
223 view_control.UpdateKeyFrame();
225 "[Visualizer] Update key frame; {} remaining.",
226 view_control.NumOfKeyFrames());
229 view_control.DeleteKeyFrame();
231 "[Visualizer] Delete last key frame; {} remaining.",
232 view_control.NumOfKeyFrames());
235 view_control.AddSpinKeyFrames();
237 "[Visualizer] Insert spin key frames; {} remaining.",
238 view_control.NumOfKeyFrames());
241 view_control.ClearAllKeyFrames();
243 "[Visualizer] Clear key frames; {} remaining.",
244 view_control.NumOfKeyFrames());
262 if (view_control.IsPreviewing()) {
263 }
else if (view_control.IsPlaying()) {
273 if (view_control.IsPreviewing()) {
274 if (glfwGetKey(window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS ||
275 glfwGetKey(window, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS) {
276 view_control.Step(y);
280 }
else if (view_control.IsPlaying()) {
291 if (view_control.IsPreviewing()) {
292 }
else if (view_control.IsPlaying()) {
filament::Texture::InternalFormat format
utility::CountingProgressReporter * progress_bar
Contains both intrinsic and extrinsic pinhole camera parameters.
std::string recording_depth_trajectory_filename_
std::string recording_image_trajectory_filename_
void MouseButtonCallback(GLFWwindow *window, int button, int action, int mods) override
void UpdateWindowTitle() override
std::string recording_depth_filename_format_
std::string recording_depth_basedir_
void KeyPressCallback(GLFWwindow *window, int key, int scancode, int action, int mods) override
size_t recording_file_index_
void MouseMoveCallback(GLFWwindow *window, double x, double y) override
~VisualizerWithCustomAnimation() override
std::string recording_image_filename_format_
VisualizerWithCustomAnimation()
void PrintVisualizerHelp() override
bool InitViewControl() override
Function to initialize ViewControl.
std::string recording_image_basedir_
void Play(bool recording=false, bool recording_depth=false, bool close_window_when_animation_ends=false)
void MouseScrollCallback(GLFWwindow *window, double x, double y) override
The main Visualizer class.
virtual void KeyPressCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
void CaptureScreenImage(const std::string &filename="", bool do_render=true)
Function to capture and save a screen image.
virtual void MouseScrollCallback(GLFWwindow *window, double x, double y)
virtual void MouseButtonCallback(GLFWwindow *window, int button, int action, int mods)
virtual void MouseMoveCallback(GLFWwindow *window, double x, double y)
void ResetViewPoint(bool reset_bounding_box=false)
Function to reset view point.
void Close()
Function to to notify the window to be closed.
void RegisterAnimationCallback(std::function< bool(Visualizer *)> callback_func)
Function to register a callback function for animation.
std::unique_ptr< ViewControl > view_control_ptr_
virtual void PrintVisualizerHelp()
void CaptureDepthImage(const std::string &filename="", bool do_render=true, double depth_scale=1000.0)
bool WriteIJsonConvertible(const std::string &filename, const cloudViewer::utility::IJsonConvertible &object)
bool MakeDirectoryHierarchy(const std::string &directory)
Generic file read and write utility for python interface.