OpenShot Library | libopenshot 0.5.0
Loading...
Searching...
No Matches
SphericalProjection.h
Go to the documentation of this file.
1
9// Copyright (c) 2008-2025 OpenShot Studios, LLC
10//
11// SPDX-License-Identifier: LGPL-3.0-or-later
12
13#ifndef OPENSHOT_SPHERICAL_PROJECTION_EFFECT_H
14#define OPENSHOT_SPHERICAL_PROJECTION_EFFECT_H
15
16#include "../EffectBase.h"
17#include "../Frame.h"
18#include "../Json.h"
19#include "../KeyFrame.h"
20
21#include <memory>
22#include <string>
23#include <vector>
24
25namespace openshot {
26
33private:
34 void init_effect_details();
35
36public:
37 // Enums
40 INPUT_FEQ_EQUIDISTANT = 1, // r = f * theta
41 INPUT_FEQ_EQUISOLID = 2, // r = 2f * sin(theta/2)
42 INPUT_FEQ_STEREOGRAPHIC = 3, // r = 2f * tan(theta/2)
43 INPUT_FEQ_ORTHOGRAPHIC = 4 // r = f * sin(theta)
44 };
45
47 MODE_RECT_SPHERE = 0, // Rectilinear view over full sphere
48 MODE_RECT_HEMISPHERE = 1, // Rectilinear view over hemisphere
49 MODE_FISHEYE_EQUIDISTANT = 2, // Output fisheye (equidistant)
50 MODE_FISHEYE_EQUISOLID = 3, // Output fisheye (equisolid)
51 MODE_FISHEYE_STEREOGRAPHIC = 4, // Output fisheye (stereographic)
52 MODE_FISHEYE_ORTHOGRAPHIC = 5 // Output fisheye (orthographic)
53 };
54
61
66
72
74 int invert;
77
80
82 SphericalProjection(Keyframe new_yaw, Keyframe new_pitch, Keyframe new_roll,
83 Keyframe new_fov);
84
86 std::shared_ptr<Frame> GetFrame(int64_t frame_number) override {
87 return GetFrame(std::make_shared<Frame>(), frame_number);
88 }
89
91 std::shared_ptr<Frame> GetFrame(std::shared_ptr<Frame> frame,
92 int64_t frame_number) override;
93
94 // JSON serialization
95 std::string Json() const override;
96 void SetJson(std::string value) override;
97 Json::Value JsonValue() const override;
98 void SetJsonValue(Json::Value root) override;
99 std::string PropertiesJSON(int64_t requested_frame) const override;
100
101private:
102 void project_input(double dx, double dy, double dz, double in_fov_r, int W,
103 int H, double &uf, double &vf) const;
104
105 mutable std::vector<float> uv_map;
106 mutable int cached_width = 0;
107 mutable int cached_height = 0;
108 mutable double cached_yaw = 0.0, cached_pitch = 0.0, cached_roll = 0.0;
109 mutable double cached_in_fov = 0.0, cached_out_fov = 0.0;
110 mutable int cached_input_model = -1;
111 mutable int cached_projection_mode = -1;
112 mutable int cached_invert = -1;
113};
114
115} // namespace openshot
116
117#endif // OPENSHOT_SPHERICAL_PROJECTION_EFFECT_H
This abstract class is the base class, used by all effects in libopenshot.
Definition EffectBase.h:54
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
Definition KeyFrame.h:53
Projects 360° or fisheye video through a virtual camera. Supports yaw, pitch, roll,...
int projection_mode
0=Sphere, 1=Hemisphere, 2=Fisheye
Keyframe in_fov
Source lens coverage / FOV (degrees)
void SetJson(std::string value) override
Load JSON string into this object.
void SetJsonValue(Json::Value root) override
Load Json::Value into this object.
Keyframe yaw
Yaw around up-axis (degrees)
Keyframe fov
Output field-of-view (degrees)
Json::Value JsonValue() const override
Generate Json::Value for this object.
int invert
0=Normal, 1=Invert (back lens / +180°)
std::shared_ptr< Frame > GetFrame(int64_t frame_number) override
ClipBase override: create a fresh Frame then call the main GetFrame.
Keyframe roll
Roll around forward-axis (degrees)
SphericalProjection()
Blank ctor (for JSON deserialization)
Keyframe pitch
Pitch around right-axis (degrees)
std::shared_ptr< Frame > GetFrame(std::shared_ptr< Frame > frame, int64_t frame_number) override
EffectBase override: reproject the QImage.
int input_model
0=Equirect, 1=Fisheye-Equidistant
std::string Json() const override
Generate JSON string of this object.
std::string PropertiesJSON(int64_t requested_frame) const override
int interpolation
0=Nearest, 1=Bilinear, 2=Bicubic, 3=Auto
This namespace is the default namespace for all code in the openshot library.
Definition Compressor.h:29