TuttleOFX
1
|
00001 #ifndef _TUTTLE_PLUGIN_LENSDISTORTPLUGIN_HPP_ 00002 #define _TUTTLE_PLUGIN_LENSDISTORTPLUGIN_HPP_ 00003 00004 #include "lensDistortDefinitions.hpp" 00005 #include "lensDistortProcessParams.hpp" 00006 00007 #include <tuttle/plugin/ImageEffectGilPlugin.hpp> 00008 #include <tuttle/plugin/context/SamplerPlugin.hpp> 00009 00010 #include <boost/gil/utilities.hpp> 00011 #include <string> 00012 00013 namespace tuttle { 00014 namespace plugin { 00015 namespace lens { 00016 00017 struct LensDistortParams 00018 { 00019 EParamLensType _lensType; 00020 EParamCenterType _centerType; 00021 00022 SamplerProcessParams _samplerProcessParams; 00023 }; 00024 00025 /** 00026 * @brief Main class of the lens distortion 00027 */ 00028 class LensDistortPlugin : public SamplerPlugin 00029 { 00030 public: 00031 typedef double Scalar; 00032 typedef boost::gil::point2<double> Point2; 00033 00034 public: 00035 ///@{ 00036 OFX::Clip* _srcRefClip; ///< source ref image clip 00037 ///@} 00038 00039 ///@{ 00040 OFX::BooleanParam* _reverse; ///< reverse the effect 00041 OFX::BooleanParam* _displaySource; ///< do nothing (so host displays input) 00042 OFX::ChoiceParam* _lensType; ///< choice to select lens type 00043 OFX::DoubleParam* _coef1; ///< distortion coeffiscient 00044 OFX::DoubleParam* _coef2; ///< distortion coeffiscient for fish-eye lens 00045 OFX::DoubleParam* _squeeze; ///< squeeze coefficient horizontally/vertically (not implemented yet) 00046 OFX::Double2DParam* _asymmetric; ///< lens distortion is asymmetric horizontally/vertically (not implemented yet) 00047 OFX::Double2DParam* _center; ///< center coordonnates 00048 OFX::BooleanParam* _centerOverlay; ///< lens center overlay 00049 OFX::ChoiceParam* _centerType; ///< centered the lens distortion on source RoD or image size (not implemented yet) 00050 OFX::DoubleParam* _postScale; ///< scale after applying the lens distortion 00051 OFX::DoubleParam* _preScale; ///< scale before applying the lens distortion 00052 OFX::ChoiceParam* _resizeRod; ///< Choice how to resize the RoD (default 'no' resize) 00053 OFX::DoubleParam* _resizeRodManualScale; ///< scale the output RoD 00054 00055 OFX::GroupParam* _groupDisplayParams; ///< group of all overlay options (don't modify the output image) 00056 OFX::BooleanParam* _gridOverlay; ///< grid overlay 00057 OFX::Double2DParam* _gridCenter; ///< grid center 00058 OFX::BooleanParam* _gridCenterOverlay; ///< grid center overlay 00059 OFX::Double2DParam* _gridScale; ///< grid scale 00060 00061 OFX::BooleanParam* _debugDisplayRoi; ///< debug display options 00062 00063 ///@} 00064 00065 ///@{ 00066 /// can't use static because it's common to all plugin instances... 00067 /// so it's not perfect but it's just here for debug purpose (used in overlay) 00068 static OfxRectD _dstRoi; 00069 static OfxRectD _srcRoi; 00070 static OfxRectD _srcRealRoi; 00071 ///@} 00072 00073 public: 00074 LensDistortPlugin( OfxImageEffectHandle handle ); 00075 00076 void render ( const OFX::RenderArguments& args ); 00077 void changedParam ( const OFX::InstanceChangedArgs& args, const std::string& paramName ); 00078 bool isIdentity ( const OFX::RenderArguments& args, OFX::Clip*& identityClip, double& identityTime ); 00079 bool getRegionOfDefinition ( const OFX::RegionOfDefinitionArguments& args, OfxRectD& rod ); 00080 void getRegionsOfInterest ( const OFX::RegionsOfInterestArguments& args, OFX::RegionOfInterestSetter& rois ); 00081 00082 public: 00083 /** 00084 * @todo pixelRatio ! 00085 */ 00086 LensDistortProcessParams<Scalar> getProcessParams( const OfxRectD& inputRod, const OfxRectD& outputRod, const OfxRectD& optionalInputRod, const double pixelAspectRatio, const bool reverse = false ) const; 00087 LensDistortProcessParams<Scalar> getProcessParams( const OfxRectD& inputRod, const OfxRectD& outputRod, const double pixelAspectRatio, const bool reverse = false ) const 00088 { 00089 static const OfxRectD noOptionalInputRod = { 0, 0, 0, 0 }; 00090 00091 return getProcessParams( inputRod, outputRod, noOptionalInputRod, pixelAspectRatio, reverse ); 00092 } 00093 00094 LensDistortParams getProcessParams( ) const ; 00095 00096 const EParamLensType getLensType () const { return static_cast<EParamLensType >( _lensType->getValue() ); } 00097 const EParamCenterType getCenterType() const { return static_cast<EParamCenterType >( _centerType->getValue() ); } 00098 const EParamResizeRod getResizeRod () const { return static_cast<EParamResizeRod >( _resizeRod->getValue() ); } 00099 00100 private: 00101 void initParamsProps(); 00102 }; 00103 00104 } 00105 } 00106 } 00107 00108 #endif