OpenShot Library | libopenshot
1.1.1
Toggle main menu visibility
Loading...
Searching...
No Matches
ObjectMask.h
Go to the documentation of this file.
1
8
9
// Copyright (c) 2026 OpenShot Studios, LLC
10
//
11
// SPDX-License-Identifier: LGPL-3.0-or-later
12
13
#ifndef OPENSHOT_OBJECT_MASK_EFFECT_H
14
#define OPENSHOT_OBJECT_MASK_EFFECT_H
15
16
#include "
Color.h
"
17
#include "
EffectBase.h
"
18
#include "
KeyFrame.h
"
19
#include "
TrackedObjectBBox.h
"
20
21
#include <map>
22
23
namespace
openshot
24
{
25
class
Frame
;
26
27
struct
ObjectMaskFrameData
{
28
int
width
= 0;
29
int
height
= 0;
30
std::vector<uint32_t>
rle
;
31
BBox
box
;
32
float
score
= 0.0f;
33
34
bool
HasData
()
const
{
return
width
> 0 &&
height
> 0 && !
rle
.empty(); }
35
};
36
40
class
ObjectMask
:
public
EffectBase
41
{
42
private
:
43
std::string protobuf_data_path;
44
std::map<size_t, ObjectMaskFrameData> masksData;
45
46
void
init_effect_details();
47
48
public
:
49
Keyframe
draw_mask
;
50
Color
mask_color
;
51
Keyframe
mask_alpha
;
52
Color
stroke_color
;
53
Keyframe
stroke_alpha
;
54
Keyframe
stroke_width
;
55
56
ObjectMask
();
57
58
std::shared_ptr<Frame>
GetFrame
(std::shared_ptr<Frame> frame, int64_t frame_number)
override
;
59
std::shared_ptr<openshot::Frame>
GetFrame
(int64_t frame_number)
override
{
return
GetFrame
(std::make_shared<Frame>(), frame_number); }
60
61
bool
LoadObjMaskData
(std::string inputFilePath);
62
std::shared_ptr<QImage>
TrackedObjectMask
(std::shared_ptr<QImage> target_image, int64_t frame_number)
const override
;
63
64
std::string
Json
()
const override
;
65
void
SetJson
(
const
std::string value)
override
;
66
Json::Value
JsonValue
()
const override
;
67
void
SetJsonValue
(
const
Json::Value root)
override
;
68
69
std::string
PropertiesJSON
(int64_t requested_frame)
const override
;
70
};
71
}
72
73
#endif
Color.h
Header file for Color class.
EffectBase.h
Header file for EffectBase class.
KeyFrame.h
Header file for the Keyframe class.
TrackedObjectBBox.h
Header file for the TrackedObjectBBox class.
openshot::Color
This class represents a color (used on the timeline and clips).
Definition
Color.h:27
openshot::EffectBase
This abstract class is the base class, used by all effects in libopenshot.
Definition
EffectBase.h:57
openshot::Frame
This class represents a single frame of video (i.e. image & audio data).
Definition
Frame.h:90
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::ObjectMask::stroke_width
Keyframe stroke_width
Definition
ObjectMask.h:54
openshot::ObjectMask::SetJsonValue
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Definition
ObjectMask.cpp:275
openshot::ObjectMask::stroke_alpha
Keyframe stroke_alpha
Definition
ObjectMask.h:53
openshot::ObjectMask::TrackedObjectMask
std::shared_ptr< QImage > TrackedObjectMask(std::shared_ptr< QImage > target_image, int64_t frame_number) const override
Generate a black/white mask from tracked object data.
Definition
ObjectMask.cpp:226
openshot::ObjectMask::draw_mask
Keyframe draw_mask
Definition
ObjectMask.h:49
openshot::ObjectMask::ObjectMask
ObjectMask()
Definition
ObjectMask.cpp:100
openshot::ObjectMask::GetFrame
std::shared_ptr< openshot::Frame > GetFrame(int64_t frame_number) override
This method is required for all derived classes of ClipBase, and returns a new openshot::Frame object...
Definition
ObjectMask.h:59
openshot::ObjectMask::GetFrame
std::shared_ptr< Frame > GetFrame(std::shared_ptr< Frame > frame, int64_t frame_number) override
Definition
ObjectMask.cpp:122
openshot::ObjectMask::JsonValue
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition
ObjectMask.cpp:252
openshot::ObjectMask::SetJson
void SetJson(const std::string value) override
Load JSON string into this object.
Definition
ObjectMask.cpp:266
openshot::ObjectMask::PropertiesJSON
std::string PropertiesJSON(int64_t requested_frame) const override
Definition
ObjectMask.cpp:304
openshot::ObjectMask::stroke_color
Color stroke_color
Definition
ObjectMask.h:52
openshot::ObjectMask::Json
std::string Json() const override
Generate JSON string of this object.
Definition
ObjectMask.cpp:247
openshot::ObjectMask::mask_color
Color mask_color
Definition
ObjectMask.h:50
openshot::ObjectMask::mask_alpha
Keyframe mask_alpha
Definition
ObjectMask.h:51
openshot::ObjectMask::LoadObjMaskData
bool LoadObjMaskData(std::string inputFilePath)
Definition
ObjectMask.cpp:170
openshot
This namespace is the default namespace for all code in the openshot library.
Definition
AnimatedCurve.h:24
openshot::BBox
This struct holds the information of a bounding-box.
Definition
TrackedObjectBBox.h:47
openshot::ObjectMaskFrameData
Definition
ObjectMask.h:27
openshot::ObjectMaskFrameData::box
BBox box
Definition
ObjectMask.h:31
openshot::ObjectMaskFrameData::height
int height
Definition
ObjectMask.h:29
openshot::ObjectMaskFrameData::score
float score
Definition
ObjectMask.h:32
openshot::ObjectMaskFrameData::width
int width
Definition
ObjectMask.h:28
openshot::ObjectMaskFrameData::rle
std::vector< uint32_t > rle
Definition
ObjectMask.h:30
openshot::ObjectMaskFrameData::HasData
bool HasData() const
Definition
ObjectMask.h:34
effects
ObjectMask.h
Generated by
1.17.0