OpenShot Library | libopenshot  0.7.0
Public Member Functions | Public Attributes | List of all members
openshot::Displace Class Reference

This class uses a grayscale image or video to displace frame pixels. More...

#include <effects/Displace.h>

Inheritance diagram for openshot::Displace:
[legend]
Collaboration diagram for openshot::Displace:
[legend]

Public Member Functions

 Displace ()
 Blank constructor, useful when using Json to load the effect properties. More...
 
 Displace (ReaderBase *map_reader, Keyframe map_strength, Keyframe map_horizontal, Keyframe map_vertical, Keyframe map_brightness, Keyframe map_contrast)
 
std::shared_ptr< openshot::FrameGetFrame (int64_t frame_number) override
 This method is required for all derived classes of ClipBase, and returns a new openshot::Frame object. All Clip keyframes and effects are resolved into pixels. More...
 
std::shared_ptr< openshot::FrameGetFrame (std::shared_ptr< openshot::Frame > frame, int64_t frame_number) override
 This method is required for all derived classes of ClipBase, and returns a modified openshot::Frame object. More...
 
std::string Json () const override
 Generate JSON string of this object. More...
 
Json::Value JsonValue () const override
 Generate Json::Value for this object. More...
 
std::string PropertiesJSON (int64_t requested_frame) const override
 
ReaderBaseReader ()
 Get the reader object of the displacement map. More...
 
void Reader (ReaderBase *new_reader)
 Set a new reader to be used by the displacement effect. More...
 
void SetJson (const std::string value) override
 Load JSON string into this object. More...
 
void SetJsonValue (const Json::Value root) override
 Load Json::Value into this object. More...
 
 ~Displace () override
 
- Public Member Functions inherited from openshot::EffectBase
Json::Value BasePropertiesJSON (int64_t requested_frame) const
 Generate JSON object of base properties (recommended to be used by all effects) More...
 
int constrain (int color_value)
 Constrain a color value from 0 to 255. More...
 
void DisplayInfo (std::ostream *out=&std::cout)
 Display effect information in the standard output stream (stdout) More...
 
virtual std::string GetVisibleObjects (int64_t frame_number) const
 Get the indexes and IDs of all visible objects in the given frame. More...
 
void InitEffectInfo ()
 
virtual std::string Json (int64_t requested_frame) const
 
Json::Value JsonInfo () const
 Generate JSON object of meta data / info. More...
 
ReaderBaseMaskReader ()
 Get the common mask reader. More...
 
const ReaderBaseMaskReader () const
 
void MaskReader (ReaderBase *new_reader)
 Set or replace the common mask reader. More...
 
int Order () const
 Get the order that this effect should be executed. More...
 
void Order (int new_order)
 Set the order that this effect should be executed. More...
 
openshot::ClipBaseParentClip ()
 Parent clip object of this effect (which can be unparented and NULL) More...
 
void ParentClip (openshot::ClipBase *new_clip)
 Set parent clip object of this effect. More...
 
std::string ParentClipId () const
 Return the ID of this effect's parent clip. More...
 
std::shared_ptr< openshot::FrameProcessFrame (std::shared_ptr< openshot::Frame > frame, int64_t frame_number)
 Apply effect processing with common mask support (if enabled). More...
 
virtual void SetJson (int64_t requested_frame, const std::string value)
 
void SetParentEffect (std::string parentEffect_id)
 Set the parent effect from which this properties will be set to. More...
 
virtual ~EffectBase ()
 
- Public Member Functions inherited from openshot::ClipBase
 ClipBase ()
 Constructor for the base clip. More...
 
virtual void End (float value)
 Set end position (in seconds) of clip (trim end of video) More...
 
void Id (std::string value)
 
void Layer (int value)
 Set layer of clip on timeline (lower number is covered by higher numbers) More...
 
bool operator< (ClipBase &a)
 
bool operator<= (ClipBase &a)
 
bool operator> (ClipBase &a)
 
bool operator>= (ClipBase &a)
 
void Position (float value)
 

Set the Id of this clip object

More...
 
void Start (float value)
 Set start position (in seconds) of clip (trim start of video) More...
 
virtual ~ClipBase ()=default
 

Public Attributes

Keyframe brightness
 Brightness adjustment for the displacement map. More...
 
Keyframe contrast
 Contrast adjustment for the displacement map. More...
 
Keyframe horizontal
 Horizontal displacement amount as a percentage of image width. More...
 
bool invert
 Invert the displacement map before converting it to offsets. More...
 
bool replace_image
 Replace the frame image with the processed displacement map for debugging. More...
 
Keyframe strength
 Overall strength multiplier for the displacement effect. More...
 
Keyframe vertical
 Vertical displacement amount as a percentage of image height. More...
 
- Public Attributes inherited from openshot::EffectBase
EffectInfoStruct info
 Information about the current effect. More...
 
bool mask_invert = false
 Invert grayscale mask values before blending. More...
 
int mask_loop_mode = MASK_LOOP_PLAY_ONCE
 Behavior when mask range reaches the end. More...
 
int mask_time_mode = MASK_TIME_SOURCE_FPS
 How effect frames map to mask source frames. More...
 
EffectBaseparentEffect
 Parent effect (which properties will set this effect properties) More...
 
std::map< int, std::shared_ptr< openshot::TrackedObjectBase > > trackedObjects
 Map of Tracked Object's by their indices (used by Effects that track objects on clips) More...
 

Additional Inherited Members

- Public Types inherited from openshot::EffectBase
enum  MaskLoopMode { MASK_LOOP_PLAY_ONCE = 0, MASK_LOOP_REPEAT = 1, MASK_LOOP_PING_PONG = 2 }
 
enum  MaskTimeMode { MASK_TIME_TIMELINE = 0, MASK_TIME_SOURCE_FPS = 1 }
 
- Protected Member Functions inherited from openshot::EffectBase
virtual void ApplyCustomMaskBlend (std::shared_ptr< QImage > original_image, std::shared_ptr< QImage > effected_image, std::shared_ptr< QImage > mask_image, int64_t frame_number) const
 Optional override for effects with custom mask implementation. More...
 
ReaderBaseCreateReaderFromJson (const Json::Value &reader_json) const
 Create a reader instance from reader JSON. More...
 
virtual bool HandlesMaskInternally () const
 Optional override for effects that apply mask processing inside GetFrame(). More...
 
int64_t MapMaskFrameNumber (int64_t frame_number)
 Convert an effect frame number to a mask source frame number. More...
 
double ResolveMaskHostFps ()
 Determine host FPS used to convert timeline frames to mask source FPS. More...
 
std::shared_ptr< QImage > ResolveMaskImage (std::shared_ptr< QImage > target_image, int64_t frame_number)
 Resolve a cached/scaled mask image for the target frame dimensions. More...
 
double ResolveMaskSourceDuration () const
 Determine mask source duration in seconds. More...
 
virtual bool UseCustomMaskBlend (int64_t frame_number) const
 Optional override for effects that need custom mask behavior. More...
 
- Protected Member Functions inherited from openshot::ClipBase
Json::Value add_property_choice_json (std::string name, int value, int selected_value) const
 Generate JSON choice for a property (dropdown properties) More...
 
Json::Value add_property_json (std::string name, float value, std::string type, std::string memo, const Keyframe *keyframe, float min_value, float max_value, bool readonly, int64_t requested_frame) const
 Generate JSON for a property. More...
 
- Protected Attributes inherited from openshot::EffectBase
openshot::ClipBaseclip
 Pointer to the parent clip instance (if any) More...
 
- Protected Attributes inherited from openshot::ClipBase
float end
 The position in seconds to end playing (used to trim the ending of a clip) More...
 
std::string id
 ID Property for all derived Clip and Effect classes. More...
 
int layer
 The layer this clip is on. Lower clips are covered up by higher clips. More...
 
float position
 The position on the timeline where this clip should start playing. More...
 
std::string previous_properties
 This string contains the previous JSON properties. More...
 
float start
 The position in seconds to start playing (used to trim the beginning of a clip) More...
 
openshot::TimelineBasetimeline
 Pointer to the parent timeline instance (if any) More...
 

Detailed Description

This class uses a grayscale image or video to displace frame pixels.

A displacement map is sampled per pixel, then used to offset the source pixel lookup in the X and Y directions. Mid-gray represents no movement, while darker and lighter values move pixels in opposite directions.

Definition at line 37 of file Displace.h.

Constructor & Destructor Documentation

◆ Displace() [1/2]

Displace::Displace ( )

Blank constructor, useful when using Json to load the effect properties.

Definition at line 66 of file Displace.cpp.

◆ Displace() [2/2]

Displace::Displace ( ReaderBase map_reader,
Keyframe  map_strength,
Keyframe  map_horizontal,
Keyframe  map_vertical,
Keyframe  map_brightness,
Keyframe  map_contrast 
)

Default constructor, which takes displacement curves and a map image path.

Parameters
map_readerThe reader of a grayscale image or video used to drive displacement
map_strengthThe curve to adjust the overall displacement strength
map_horizontalThe curve to adjust horizontal displacement percentage
map_verticalThe curve to adjust vertical displacement percentage
map_brightnessThe curve to adjust the displacement map brightness
map_contrastThe curve to adjust the displacement map contrast

Definition at line 72 of file Displace.cpp.

◆ ~Displace()

Displace::~Displace ( )
override

Definition at line 347 of file Displace.cpp.

Member Function Documentation

◆ GetFrame() [1/2]

std::shared_ptr<openshot::Frame> openshot::Displace::GetFrame ( int64_t  frame_number)
inlineoverridevirtual

This method is required for all derived classes of ClipBase, and returns a new openshot::Frame object. All Clip keyframes and effects are resolved into pixels.

Returns
A new openshot::Frame object
Parameters
frame_numberThe frame number (starting at 1) of the clip or effect on the timeline.

Implements openshot::ClipBase.

Definition at line 80 of file Displace.h.

Referenced by GetFrame().

◆ GetFrame() [2/2]

std::shared_ptr< openshot::Frame > Displace::GetFrame ( std::shared_ptr< openshot::Frame frame,
int64_t  frame_number 
)
overridevirtual

This method is required for all derived classes of ClipBase, and returns a modified openshot::Frame object.

The frame object is passed into this method and used as a starting point (pixels and audio). All Clip keyframes and effects are resolved into pixels.

Returns
The modified frame object
Parameters
frameThe frame object that needs the effect applied to it
frame_numberThe frame number (starting at 1) of the clip or effect on the timeline.

Implements openshot::ClipBase.

Definition at line 164 of file Displace.cpp.

◆ Json()

std::string Displace::Json ( ) const
overridevirtual

Generate JSON string of this object.

Reimplemented from openshot::EffectBase.

Definition at line 236 of file Displace.cpp.

◆ JsonValue()

Json::Value Displace::JsonValue ( ) const
overridevirtual

Generate Json::Value for this object.

Reimplemented from openshot::EffectBase.

Definition at line 241 of file Displace.cpp.

Referenced by Json().

◆ PropertiesJSON()

std::string Displace::PropertiesJSON ( int64_t  requested_frame) const
overridevirtual

Get all properties for a specific frame (perfect for a UI to display the current state of all properties at any time)

Implements openshot::ClipBase.

Definition at line 307 of file Displace.cpp.

◆ Reader() [1/2]

ReaderBase* openshot::Displace::Reader ( )
inline

Get the reader object of the displacement map.

Definition at line 104 of file Displace.h.

Referenced by Displace(), SetJsonValue(), and ~Displace().

◆ Reader() [2/2]

void Displace::Reader ( ReaderBase new_reader)

Set a new reader to be used by the displacement effect.

Definition at line 330 of file Displace.cpp.

◆ SetJson()

void Displace::SetJson ( const std::string  value)
overridevirtual

Load JSON string into this object.

Reimplemented from openshot::EffectBase.

Definition at line 259 of file Displace.cpp.

◆ SetJsonValue()

void Displace::SetJsonValue ( const Json::Value  root)
overridevirtual

Load Json::Value into this object.

Reimplemented from openshot::EffectBase.

Definition at line 272 of file Displace.cpp.

Referenced by SetJson().

Member Data Documentation

◆ brightness

Keyframe openshot::Displace::brightness

Brightness adjustment for the displacement map.

Definition at line 57 of file Displace.h.

Referenced by GetFrame(), JsonValue(), PropertiesJSON(), and SetJsonValue().

◆ contrast

Keyframe openshot::Displace::contrast

Contrast adjustment for the displacement map.

Definition at line 58 of file Displace.h.

Referenced by GetFrame(), JsonValue(), PropertiesJSON(), and SetJsonValue().

◆ horizontal

Keyframe openshot::Displace::horizontal

Horizontal displacement amount as a percentage of image width.

Definition at line 55 of file Displace.h.

Referenced by GetFrame(), JsonValue(), PropertiesJSON(), and SetJsonValue().

◆ invert

bool openshot::Displace::invert

Invert the displacement map before converting it to offsets.

Definition at line 53 of file Displace.h.

Referenced by GetFrame(), JsonValue(), PropertiesJSON(), and SetJsonValue().

◆ replace_image

bool openshot::Displace::replace_image

Replace the frame image with the processed displacement map for debugging.

Definition at line 52 of file Displace.h.

Referenced by GetFrame(), JsonValue(), PropertiesJSON(), and SetJsonValue().

◆ strength

Keyframe openshot::Displace::strength

Overall strength multiplier for the displacement effect.

Definition at line 54 of file Displace.h.

Referenced by GetFrame(), JsonValue(), PropertiesJSON(), and SetJsonValue().

◆ vertical

Keyframe openshot::Displace::vertical

Vertical displacement amount as a percentage of image height.

Definition at line 56 of file Displace.h.

Referenced by GetFrame(), JsonValue(), PropertiesJSON(), and SetJsonValue().


The documentation for this class was generated from the following files: