Loading...
Searching...
No Matches
SphericalProjection.h
Go to the documentation of this file.
// Copyright (c) 2008-2025 OpenShot Studios, LLC
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#ifndef OPENSHOT_SPHERICAL_PROJECTION_EFFECT_H
#define OPENSHOT_SPHERICAL_PROJECTION_EFFECT_H
#include "../EffectBase.h"
#include "../Frame.h"
#include "../Json.h"
#include "../KeyFrame.h"
#include <memory>
#include <string>
#include <vector>
namespace openshot {
class SphericalProjection : public EffectBase {
private:
void init_effect_details();
public:
// Enums
enum InputModel {
INPUT_EQUIRECT = 0,
INPUT_FEQ_EQUIDISTANT = 1, // r = f * theta
INPUT_FEQ_EQUISOLID = 2, // r = 2f * sin(theta/2)
INPUT_FEQ_STEREOGRAPHIC = 3, // r = 2f * tan(theta/2)
INPUT_FEQ_ORTHOGRAPHIC = 4 // r = f * sin(theta)
};
enum ProjectionMode {
MODE_RECT_SPHERE = 0, // Rectilinear view over full sphere
MODE_RECT_HEMISPHERE = 1, // Rectilinear view over hemisphere
MODE_FISHEYE_EQUIDISTANT = 2, // Output fisheye (equidistant)
MODE_FISHEYE_EQUISOLID = 3, // Output fisheye (equisolid)
MODE_FISHEYE_STEREOGRAPHIC = 4, // Output fisheye (stereographic)
MODE_FISHEYE_ORTHOGRAPHIC = 5 // Output fisheye (orthographic)
};
enum InterpMode {
INTERP_NEAREST = 0,
INTERP_BILINEAR = 1,
INTERP_BICUBIC = 2,
INTERP_AUTO = 3
};
enum InvertFlag {
INVERT_NORMAL = 0,
INVERT_BACK = 1
};
Keyframe yaw;
Keyframe pitch;
Keyframe roll;
Keyframe fov;
Keyframe in_fov;
int projection_mode;
int invert;
int input_model;
int interpolation;
SphericalProjection();
SphericalProjection(Keyframe new_yaw, Keyframe new_pitch, Keyframe new_roll,
Keyframe new_fov);
std::shared_ptr<Frame> GetFrame(int64_t frame_number) override {
return GetFrame(std::make_shared<Frame>(), frame_number);
}
std::shared_ptr<Frame> GetFrame(std::shared_ptr<Frame> frame,
int64_t frame_number) override;
// JSON serialization
std::string Json() const override;
void SetJson(std::string value) override;
Json::Value JsonValue() const override;
void SetJsonValue(Json::Value root) override;
std::string PropertiesJSON(int64_t requested_frame) const override;
private:
void project_input(double dx, double dy, double dz, double in_fov_r, int W,
int H, double &uf, double &vf) const;
mutable std::vector<float> uv_map;
mutable int cached_width = 0;
mutable int cached_height = 0;
mutable double cached_yaw = 0.0, cached_pitch = 0.0, cached_roll = 0.0;
mutable double cached_in_fov = 0.0, cached_out_fov = 0.0;
mutable int cached_input_model = -1;
mutable int cached_projection_mode = -1;
mutable int cached_invert = -1;
};
} // namespace openshot
#endif // OPENSHOT_SPHERICAL_PROJECTION_EFFECT_H
EffectBase.h
Header file for EffectBase class.
Frame.h
Header file for Frame class.
Json.h
Header file for JSON class.
KeyFrame.h
Header file for the Keyframe class.
openshot::EffectBase
This abstract class is the base class, used by all effects in libopenshot.
Definition EffectBase.h:54
openshot::Keyframe
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
Definition KeyFrame.h:53
openshot::SphericalProjection::projection_mode
int projection_mode
0=Sphere, 1=Hemisphere, 2=Fisheye
Definition SphericalProjection.h:73
openshot::SphericalProjection::in_fov
Keyframe in_fov
Source lens coverage / FOV (degrees).
Definition SphericalProjection.h:71
openshot::SphericalProjection::SetJson
void SetJson(std::string value) override
Load JSON string into this object.
Definition SphericalProjection.cpp:443
openshot::SphericalProjection::SetJsonValue
void SetJsonValue(Json::Value root) override
Load Json::Value into this object.
Definition SphericalProjection.cpp:456
openshot::SphericalProjection::yaw
Keyframe yaw
Yaw around up-axis (degrees).
Definition SphericalProjection.h:67
openshot::SphericalProjection::fov
Keyframe fov
Output field-of-view (degrees).
Definition SphericalProjection.h:70
openshot::SphericalProjection::JsonValue
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition SphericalProjection.cpp:427
openshot::SphericalProjection::InvertFlag
InvertFlag
Definition SphericalProjection.h:62
openshot::SphericalProjection::INVERT_NORMAL
@ INVERT_NORMAL
Definition SphericalProjection.h:63
openshot::SphericalProjection::INVERT_BACK
@ INVERT_BACK
Definition SphericalProjection.h:64
openshot::SphericalProjection::invert
int invert
0=Normal, 1=Invert (back lens / +180°)
Definition SphericalProjection.h:74
openshot::SphericalProjection::ProjectionMode
ProjectionMode
Definition SphericalProjection.h:46
openshot::SphericalProjection::MODE_FISHEYE_ORTHOGRAPHIC
@ MODE_FISHEYE_ORTHOGRAPHIC
Definition SphericalProjection.h:52
openshot::SphericalProjection::MODE_RECT_HEMISPHERE
@ MODE_RECT_HEMISPHERE
Definition SphericalProjection.h:48
openshot::SphericalProjection::MODE_RECT_SPHERE
@ MODE_RECT_SPHERE
Definition SphericalProjection.h:47
openshot::SphericalProjection::MODE_FISHEYE_STEREOGRAPHIC
@ MODE_FISHEYE_STEREOGRAPHIC
Definition SphericalProjection.h:51
openshot::SphericalProjection::MODE_FISHEYE_EQUISOLID
@ MODE_FISHEYE_EQUISOLID
Definition SphericalProjection.h:50
openshot::SphericalProjection::MODE_FISHEYE_EQUIDISTANT
@ MODE_FISHEYE_EQUIDISTANT
Definition SphericalProjection.h:49
openshot::SphericalProjection::InputModel
InputModel
Definition SphericalProjection.h:38
openshot::SphericalProjection::INPUT_FEQ_ORTHOGRAPHIC
@ INPUT_FEQ_ORTHOGRAPHIC
Definition SphericalProjection.h:43
openshot::SphericalProjection::INPUT_EQUIRECT
@ INPUT_EQUIRECT
Definition SphericalProjection.h:39
openshot::SphericalProjection::INPUT_FEQ_EQUIDISTANT
@ INPUT_FEQ_EQUIDISTANT
Definition SphericalProjection.h:40
openshot::SphericalProjection::INPUT_FEQ_STEREOGRAPHIC
@ INPUT_FEQ_STEREOGRAPHIC
Definition SphericalProjection.h:42
openshot::SphericalProjection::INPUT_FEQ_EQUISOLID
@ INPUT_FEQ_EQUISOLID
Definition SphericalProjection.h:41
openshot::SphericalProjection::InterpMode
InterpMode
Definition SphericalProjection.h:55
openshot::SphericalProjection::INTERP_BICUBIC
@ INTERP_BICUBIC
Definition SphericalProjection.h:58
openshot::SphericalProjection::INTERP_AUTO
@ INTERP_AUTO
Definition SphericalProjection.h:59
openshot::SphericalProjection::INTERP_NEAREST
@ INTERP_NEAREST
Definition SphericalProjection.h:56
openshot::SphericalProjection::INTERP_BILINEAR
@ INTERP_BILINEAR
Definition SphericalProjection.h:57
openshot::SphericalProjection::GetFrame
std::shared_ptr< Frame > GetFrame(int64_t frame_number) override
ClipBase override: create a fresh Frame then call the main GetFrame.
Definition SphericalProjection.h:86
openshot::SphericalProjection::roll
Keyframe roll
Roll around forward-axis (degrees).
Definition SphericalProjection.h:69
openshot::SphericalProjection::SphericalProjection
SphericalProjection()
Blank ctor (for JSON deserialization).
Definition SphericalProjection.cpp:23
openshot::SphericalProjection::pitch
Keyframe pitch
Pitch around right-axis (degrees).
Definition SphericalProjection.h:68
openshot::SphericalProjection::GetFrame
std::shared_ptr< Frame > GetFrame(std::shared_ptr< Frame > frame, int64_t frame_number) override
EffectBase override: reproject the QImage.
openshot::SphericalProjection::input_model
int input_model
0=Equirect, 1=Fisheye-Equidistant
Definition SphericalProjection.h:75
openshot::SphericalProjection::Json
std::string Json() const override
Generate JSON string of this object.
Definition SphericalProjection.cpp:422
openshot::SphericalProjection::PropertiesJSON
std::string PropertiesJSON(int64_t requested_frame) const override
Definition SphericalProjection.cpp:493
openshot::SphericalProjection::interpolation
int interpolation
0=Nearest, 1=Bilinear, 2=Bicubic, 3=Auto
Definition SphericalProjection.h:76
openshot
This namespace is the default namespace for all code in the openshot library.
Definition Compressor.h:29