* @brief Projects 360° or fisheye video through a virtual camera. * Supports yaw, pitch, roll, input and output FOV, sphere/hemisphere/fisheye * modes, optional inversion, and automatic quality selection. */
| 30 | * modes, optional inversion, and automatic quality selection. |
| 31 | */ |
| 32 | class SphericalProjection : public EffectBase { |
| 33 | private: |
| 34 | void init_effect_details(); |
| 35 | |
| 36 | public: |
| 37 | // Enums |
| 38 | enum InputModel { |
| 39 | INPUT_EQUIRECT = 0, |
| 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 | |
| 46 | enum ProjectionMode { |
| 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 | |
| 55 | enum InterpMode { |
| 56 | INTERP_NEAREST = 0, |
| 57 | INTERP_BILINEAR = 1, |
| 58 | INTERP_BICUBIC = 2, |
| 59 | INTERP_AUTO = 3 |
| 60 | }; |
| 61 | |
| 62 | enum InvertFlag { |
| 63 | INVERT_NORMAL = 0, |
| 64 | INVERT_BACK = 1 |
| 65 | }; |
| 66 | |
| 67 | Keyframe yaw; ///< Yaw around up-axis (degrees) |
| 68 | Keyframe pitch; ///< Pitch around right-axis (degrees) |
| 69 | Keyframe roll; ///< Roll around forward-axis (degrees) |
| 70 | Keyframe fov; ///< Output field-of-view (degrees) |
| 71 | Keyframe in_fov; ///< Source lens coverage / FOV (degrees) |
| 72 | |
| 73 | int projection_mode; ///< 0=Sphere, 1=Hemisphere, 2=Fisheye |
| 74 | int invert; ///< 0=Normal, 1=Invert (back lens / +180°) |
| 75 | int input_model; ///< 0=Equirect, 1=Fisheye-Equidistant |
| 76 | int interpolation; ///< 0=Nearest, 1=Bilinear, 2=Bicubic, 3=Auto |
| 77 | |
| 78 | /// Blank ctor (for JSON deserialization) |
| 79 | SphericalProjection(); |
| 80 | |
| 81 | /// Ctor with custom curves |
| 82 | SphericalProjection(Keyframe new_yaw, Keyframe new_pitch, Keyframe new_roll, |
| 83 | Keyframe new_fov); |
| 84 | |
| 85 | /// ClipBase override: create a fresh Frame then call the main GetFrame |
| 86 | std::shared_ptr<Frame> GetFrame(int64_t frame_number) override { |
| 87 | return GetFrame(std::make_shared<Frame>(), frame_number); |
| 88 | } |
| 89 |