11 #include <IJsonConvertibleIO.h>
15 namespace visualization {
70 if (mode != AnimationMode::FreeMode &&
76 case AnimationMode::PreviewMode:
77 case AnimationMode::PlayMode:
81 case AnimationMode::FreeMode:
128 double radian_per_step =
M_PI * 2.0 / double(num_of_key_frames);
129 for (
int i = 0; i < num_of_key_frames; i++) {
139 case AnimationMode::FreeMode:
142 case AnimationMode::PreviewMode:
143 prefix =
"Previewing ";
145 case AnimationMode::PlayMode:
152 buffer =
"empty trajectory";
155 "#{} keyframe ({} in total{})",
162 buffer =
"empty trajectory";
164 buffer =
fmt::format(buffer,
"#{} frame ({} in total{})",
170 return prefix + std::string(buffer);
220 std::string json_filename =
filename;
221 if (json_filename.empty()) {
226 json_filename.c_str());
253 for (
size_t i = 0; i < camera_trajectory.
parameters_.size(); i++) {
278 if (status.field_of_view_ !=
287 double current_frame,
size_t num_of_frames,
bool is_loop) {
288 if (num_of_frames == 0) {
291 double frame_index = current_frame;
293 while (
int(round(frame_index)) < 0) {
294 frame_index += double(num_of_frames);
296 while (
int(round(frame_index)) >=
int(num_of_frames)) {
297 frame_index -= double(num_of_frames);
300 if (frame_index < 0.0) {
303 if (frame_index > num_of_frames - 1.0) {
304 frame_index = num_of_frames - 1.0;
320 std::tie(success, status) =
filament::Texture::InternalFormat format
std::vector< PinholeCameraParameters > parameters_
List of PinholeCameraParameters objects.
bool LoadTrajectoryFromCameraTrajectory(const camera::PinholeCameraTrajectory &camera_trajectory)
void ChangeFieldOfView(double step) override
bool LoadTrajectoryFromJsonFile(const std::string &filename)
size_t CurrentFrame() const
void AddSpinKeyFrames(int num_of_key_frames=20)
ViewTrajectory view_trajectory_
void Rotate(double x, double y, double xo, double yo) override
Function to process rotation.
size_t CurrentKeyframe() const
void SetAnimationMode(AnimationMode mode)
AnimationMode animation_mode_
void SetViewControlFromTrajectory()
void Scale(double scale) override
std::string GetStatusString() const
bool IsValidPinholeCameraTrajectory() const
double RegularizeFrameIndex(double current_frame, size_t num_of_frames, bool is_loop)
void Translate(double x, double y, double xo, double yo) override
Function to process translation.
bool CaptureTrajectory(const std::string &filename="")
bool ConvertFromViewParameters(const ViewParameters &status)
ProjectionType GetProjectionType() const
virtual void Translate(double x, double y, double xo=0.0, double yo=0.0)
Function to process translation.
virtual void Rotate(double x, double y, double xo=0.0, double yo=0.0)
Function to process rotation.
static const double FIELD_OF_VIEW_MIN
virtual void ChangeFieldOfView(double step)
bool ConvertFromPinholeCameraParameters(const camera::PinholeCameraParameters ¶meters, bool allow_arbitrary=false)
virtual void Scale(double scale)
void SetProjectionParameters()
static const double ROTATION_RADIAN_PER_PIXEL
bool ConvertToViewParameters(ViewParameters &status) const
Function to get equivalent view parameters (support orthogonal)
size_t NumOfFrames() const
std::tuple< bool, ViewParameters > GetInterpolatedFrame(size_t k)
std::vector< ViewParameters > view_status_
static const int INTERVAL_MIN
void ComputeInterpolationCoefficients()
Helper functions for the ml ops.
bool WriteIJsonConvertible(const std::string &filename, const cloudViewer::utility::IJsonConvertible &object)
bool ReadIJsonConvertible(const std::string &filename, cloudViewer::utility::IJsonConvertible &object)
std::string GetCurrentTimeStamp()
Returns current time stamp.
GLMatrix4f Perspective(double field_of_view_, double aspect, double z_near, double z_far)
Generic file read and write utility for python interface.