Skip to content

File: DepthFlow/Scene.py

DepthFlow.Scene

DEFAULT_IMAGE

DEFAULT_IMAGE: str = (
    "https://w.wallhaven.cc/full/pk/wallhaven-pkz5r9.png"
)

DEPTH_SHADER

DEPTH_SHADER: Path = (
    DEPTHFLOW.RESOURCES.SHADERS / "DepthFlow.glsl"
)

DepthScene

Bases: ShaderScene

Source code in Projects/DepthFlow/DepthFlow/Scene.py
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
@define
class DepthScene(ShaderScene):
    state: DepthState = Factory(DepthState)

    class Config(ShaderScene.Config):
        image:     Iterable[PydanticImage] = DEFAULT_IMAGE
        depth:     Iterable[PydanticImage] = None
        estimator: DepthEstimator = Field(default_factory=DepthAnythingV2)
        animation: DepthAnimation = Field(default_factory=DepthAnimation)
        upscaler:  BrokenUpscaler = Field(default_factory=NoUpscaler)

    # -------------------------------------------------------------------------------------------- #
    # Command line interface

    def commands(self):
        self.cli.description = DEPTHFLOW_ABOUT

        with self.cli.panel(self.scene_panel):
            self.cli.command(self.input)

        with self.cli.panel("🔧 Preloading"):
            self.cli.command(self.load_estimator, hidden=True)
            self.cli.command(self.load_upscaler,  hidden=True)

        with self.cli.panel("🌊 Depth estimator"):
            self.cli.command(DepthAnythingV1, post=self.set_estimator, name="any1")
            self.cli.command(DepthAnythingV2, post=self.set_estimator, name="any2")
            self.cli.command(DepthPro, post=self.set_estimator)
            self.cli.command(ZoeDepth, post=self.set_estimator)
            self.cli.command(Marigold, post=self.set_estimator)

        with self.cli.panel("⭐️ Upscaler"):
            self.cli.command(Realesr, post=self.set_upscaler)
            self.cli.command(Upscayl, post=self.set_upscaler)
            self.cli.command(Waifu2x, post=self.set_upscaler)

        with self.cli.panel("🚀 Animation components"):
            _hidden = Environment.flag("ADVANCED", 0)
            for animation in Actions.members():
                if issubclass(animation, ComponentBase):
                    self.cli.command(animation, post=self.config.animation.add, hidden=_hidden)

        with self.cli.panel("🔮 Animation presets"):
            for preset in Actions.members():
                if issubclass(preset, PresetBase):
                    self.cli.command(preset, post=self.config.animation.add)

        with self.cli.panel("🎨 Post-processing"):
            for post in Actions.members():
                if issubclass(post, FilterBase):
                    self.cli.command(post, post=self.config.animation.add)

    def input(self,
        image: Annotated[list[str], Option("--image", "-i",
            help="[bold green](🟢 Basic)[/] Background Image [green](Path, URL, NumPy, PIL)[/]"
        )],
        depth: Annotated[list[str], Option("--depth", "-d",
            help="[bold green](🟢 Basic)[/] Depthmap of the Image [medium_purple3](None to estimate)[/]"
        )]=None,
    ) -> None:
        """Input images from Path, URL, Directories and its estimated Depthmap (Lazy load)"""
        self.config.image = image
        self.config.depth = depth

    # -------------------------------------------------------------------------------------------- #
    # Module implementation

    def build(self) -> None:
        self.image = ShaderTexture(scene=self, name="image").repeat(False)
        self.depth = ShaderTexture(scene=self, name="depth").repeat(False)
        self.shader.fragment = DEPTH_SHADER
        self.base_duration = 5.0
        self.subsample = 2
        self.ssaa = 1.2

    def setup(self) -> None:
        if (not self.config.animation):
            self.config.animation.add(Actions.Orbital())
        self._load_inputs()

    def update(self) -> None:
        self.config.animation.apply(self)

    def handle(self, message: ShaderMessage) -> None:
        ShaderScene.handle(self, message)

        if isinstance(message, ShaderMessage.Window.FileDrop):
            self.input(image=message.first, depth=message.second)
            self._load_inputs()

    def pipeline(self) -> Iterable[ShaderVariable]:
        yield from ShaderScene.pipeline(self)
        yield from self.state.pipeline()

    # -------------------------------------------------------------------------------------------- #
    # Proxy methods

    # # Upscalers

    def set_upscaler(self, upscaler: Optional[BrokenUpscaler]=None) -> BrokenUpscaler:
        self.config.upscaler = (upscaler or NoUpscaler())
        return self.config.upscaler
    def clear_upscaler(self) -> None:
        self.config.upscaler = NoUpscaler()
    def load_upscaler(self) -> None:
        self.config.upscaler.download()

    def realesr(self, **options) -> Realesr:
        return self.set_upscaler(Realesr(**options))
    def upscayl(self, **options) -> Upscayl:
        return self.set_upscaler(Upscayl(**options))
    def waifu2x(self, **options) -> Waifu2x:
        return self.set_upscaler(Waifu2x(**options))

    # # Estimators

    def set_estimator(self, estimator: BaseEstimator) -> BaseEstimator:
        self.config.estimator = estimator
        return self.config.estimator
    def load_estimator(self) -> None:
        self.config.estimator.load_model()

    def depth_anything1(self, **options) -> DepthAnythingV1:
        return self.set_estimator(DepthAnythingV1(**options))
    def depth_anything2(self, **options) -> DepthAnythingV2:
        return self.set_estimator(DepthAnythingV2(**options))
    def depth_pro(self, **options) -> DepthPro:
        return self.set_estimator(DepthPro(**options))
    def zoe_depth(self, **options) -> ZoeDepth:
        return self.set_estimator(ZoeDepth(**options))
    def marigold(self, **options) -> Marigold:
        return self.set_estimator(Marigold(**options))

    # # Animations

    # Constant
    def set(self, **options) -> Actions.Set:
        return self.config.animation.add(Actions.Set(**options))
    def add(self, **options) -> Actions.Add:
        return self.config.animation.add(Actions.Add(**options))

    # Basic
    def linear(self, **options) -> Actions.Linear:
        return self.config.animation.add(Actions.Linear(**options))
    def sine(self, **options) -> Actions.Sine:
        return self.config.animation.add(Actions.Sine(**options))
    def cosine(self, **options) -> Actions.Cosine:
        return self.config.animation.add(Actions.Cosine(**options))
    def triangle(self, **options) -> Actions.Triangle:
        return self.config.animation.add(Actions.Triangle(**options))

    # Presets
    def vertical(self, **options) -> Actions.Vertical:
        return self.config.animation.add(Actions.Vertical(**options))
    def horizontal(self, **options) -> Actions.Horizontal:
        return self.config.animation.add(Actions.Horizontal(**options))
    def zoom(self, **options) -> Actions.Zoom:
        return self.config.animation.add(Actions.Zoom(**options))
    def circle(self, **options) -> Actions.Circle:
        return self.config.animation.add(Actions.Circle(**options))
    def dolly(self, **options) -> Actions.Dolly:
        return self.config.animation.add(Actions.Dolly(**options))
    def orbital(self, **options) -> Actions.Orbital:
        return self.config.animation.add(Actions.Orbital(**options))

    # Post-processing
    def vignette(self, **options) -> Actions.Vignette:
        return self.config.animation.add(Actions.Vignette(**options))
    def blur(self, **options) -> Actions.Blur:
        return self.config.animation.add(Actions.Blur(**options))
    def inpaint(self, **options) -> Actions.Inpaint:
        return self.config.animation.add(Actions.Inpaint(**options))
    def colors(self, **options) -> Actions.Colors:
        return self.config.animation.add(Actions.Colors(**options))

    # -------------------------------------------------------------------------------------------- #
    # Internal batch exporting

    def _load_inputs(self) -> None:
        """Load inputs: single or batch exporting"""

        # Batch exporting implementation
        image = self._get_batch_input(self.config.image)
        depth = self._get_batch_input(self.config.depth)

        if (image is None):
            raise ShaderBatchStop()

        self.log_info(f"Loading image: {image}")
        self.log_info(f"Loading depth: {depth or 'Estimating from image'}")

        # Load, estimate, upscale input image
        image = self.config.upscaler.upscale(LoadImage(image))
        depth = LoadImage(depth) or self.config.estimator.estimate(image)

        # Match rendering resolution to image
        self.resolution   = (image.width,image.height)
        self.aspect_ratio = (image.width/image.height)
        self.image.from_image(image)
        self.depth.from_image(depth)

        # Default to 1920x1080 on base image
        if (self.config.image is DEFAULT_IMAGE):
            self.resolution   = (1920, 1080)
            self.aspect_ratio = (16/9)

    def export_name(self, path: Path) -> Path:
        """Modifies the output path if on batch exporting mode"""
        options = list(self._iter_batch_input(self.config.image))

        # Single file mode, return as-is
        if (len(options) == 1):
            return path

        # Assume it's a local path
        image = Path(options[self.index])
        original = image.stem

        # Use the URL filename as base
        if validators.url(image):
            original = BrokenPath.url_filename(image)

        # Build the batch filename: 'file' + -'custom stem'
        return path.with_stem(original + "-" + path.stem)

    def _iter_batch_input(self, item: Optional[LoadableImage]) -> Iterable[LoadableImage]:
        if (item is None):
            return None

        # Recurse on multiple inputs
        if isinstance(item, (list, tuple, set)):
            for part in item:
                yield from self._iter_batch_input(part)

        # Return known valid inputs as is
        elif isinstance(item, (bytes, Image, numpy.ndarray)):
            yield item
        elif validators.url(item):
            yield item

        # Valid directory on disk
        elif (path := BrokenPath.get(item, exists=True)):
            if (path.is_dir()):
                files = (path.glob("*" + x) for x in FileExtensions.Image)
                yield from sorted(flatten(files))
            else:
                yield path

        # Interpret as a glob pattern
        elif ("*" in str(item)):
            yield from sorted(path.parent.glob(path.name))
        else:
            self.log_minor(f"Assuming {item} is an iterable, could go wrong..")
            yield from item

    def _get_batch_input(self, item: LoadableImage) -> Optional[LoadableImage]:
        return list_get(list(self._iter_batch_input(item)), self.index)

    def ui(self) -> None:
        if (state := imgui.slider_float("Height", self.state.height, 0, 1, "%.2f"))[0]:
            self.state.height = max(0, state[1])
        if (state := imgui.slider_float("Steady", self.state.steady, 0, 1, "%.2f"))[0]:
            self.state.steady = max(0, state[1])
        if (state := imgui.slider_float("Focus", self.state.focus, 0, 1, "%.2f"))[0]:
            self.state.focus = max(0, state[1])
        if (state := imgui.slider_float("Invert", self.state.invert, 0, 1, "%.2f"))[0]:
            self.state.invert = max(0, state[1])
        if (state := imgui.slider_float("Zoom", self.state.zoom, 0, 2, "%.2f"))[0]:
            self.state.zoom = max(0, state[1])
        if (state := imgui.slider_float("Isometric", self.state.isometric, 0, 1, "%.2f"))[0]:
            self.state.isometric = max(0, state[1])
        if (state := imgui.slider_float("Dolly", self.state.dolly, 0, 5, "%.2f"))[0]:
            self.state.dolly = max(0, state[1])

        imgui.text("- True camera position")
        if (state := imgui.slider_float("Center X", self.state.center_x, -self.aspect_ratio, self.aspect_ratio, "%.2f"))[0]:
            self.state.center_x = state[1]
        if (state := imgui.slider_float("Center Y", self.state.center_y, -1, 1, "%.2f"))[0]:
            self.state.center_y = state[1]

        imgui.text("- Fixed point at height changes")
        if (state := imgui.slider_float("Origin X", self.state.origin_x, -self.aspect_ratio, self.aspect_ratio, "%.2f"))[0]:
            self.state.origin_x = state[1]
        if (state := imgui.slider_float("Origin Y", self.state.origin_y, -1, 1, "%.2f"))[0]:
            self.state.origin_y = state[1]

        imgui.text("- Parallax offset")
        if (state := imgui.slider_float("Offset X", self.state.offset_x, -2, 2, "%.2f"))[0]:
            self.state.offset_x = state[1]
        if (state := imgui.slider_float("Offset Y", self.state.offset_y, -2, 2, "%.2f"))[0]:
            self.state.offset_y = state[1]

state

state: DepthState = Factory(DepthState)

Config

Bases: ShaderScene.Config

Source code in Projects/DepthFlow/DepthFlow/Scene.py
56
57
58
59
60
61
class Config(ShaderScene.Config):
    image:     Iterable[PydanticImage] = DEFAULT_IMAGE
    depth:     Iterable[PydanticImage] = None
    estimator: DepthEstimator = Field(default_factory=DepthAnythingV2)
    animation: DepthAnimation = Field(default_factory=DepthAnimation)
    upscaler:  BrokenUpscaler = Field(default_factory=NoUpscaler)
image
image: Iterable[PydanticImage] = DEFAULT_IMAGE
depth
depth: Iterable[PydanticImage] = None
estimator
estimator: DepthEstimator = Field(
    default_factory=DepthAnythingV2
)
animation
animation: DepthAnimation = Field(
    default_factory=DepthAnimation
)
upscaler
upscaler: BrokenUpscaler = Field(default_factory=NoUpscaler)

commands

commands()
Source code in Projects/DepthFlow/DepthFlow/Scene.py
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
def commands(self):
    self.cli.description = DEPTHFLOW_ABOUT

    with self.cli.panel(self.scene_panel):
        self.cli.command(self.input)

    with self.cli.panel("🔧 Preloading"):
        self.cli.command(self.load_estimator, hidden=True)
        self.cli.command(self.load_upscaler,  hidden=True)

    with self.cli.panel("🌊 Depth estimator"):
        self.cli.command(DepthAnythingV1, post=self.set_estimator, name="any1")
        self.cli.command(DepthAnythingV2, post=self.set_estimator, name="any2")
        self.cli.command(DepthPro, post=self.set_estimator)
        self.cli.command(ZoeDepth, post=self.set_estimator)
        self.cli.command(Marigold, post=self.set_estimator)

    with self.cli.panel("⭐️ Upscaler"):
        self.cli.command(Realesr, post=self.set_upscaler)
        self.cli.command(Upscayl, post=self.set_upscaler)
        self.cli.command(Waifu2x, post=self.set_upscaler)

    with self.cli.panel("🚀 Animation components"):
        _hidden = Environment.flag("ADVANCED", 0)
        for animation in Actions.members():
            if issubclass(animation, ComponentBase):
                self.cli.command(animation, post=self.config.animation.add, hidden=_hidden)

    with self.cli.panel("🔮 Animation presets"):
        for preset in Actions.members():
            if issubclass(preset, PresetBase):
                self.cli.command(preset, post=self.config.animation.add)

    with self.cli.panel("🎨 Post-processing"):
        for post in Actions.members():
            if issubclass(post, FilterBase):
                self.cli.command(post, post=self.config.animation.add)

input

input(
    image: Annotated[
        list[str],
        Option(
            --image,
            -i,
            help="[bold green](🟢 Basic)[/] Background Image [green](Path, URL, NumPy, PIL)[/]",
        ),
    ],
    depth: Annotated[
        list[str],
        Option(
            --depth,
            -d,
            help="[bold green](🟢 Basic)[/] Depthmap of the Image [medium_purple3](None to estimate)[/]",
        ),
    ] = None,
) -> None

Input images from Path, URL, Directories and its estimated Depthmap (Lazy load)

Source code in Projects/DepthFlow/DepthFlow/Scene.py
104
105
106
107
108
109
110
111
112
113
114
def input(self,
    image: Annotated[list[str], Option("--image", "-i",
        help="[bold green](🟢 Basic)[/] Background Image [green](Path, URL, NumPy, PIL)[/]"
    )],
    depth: Annotated[list[str], Option("--depth", "-d",
        help="[bold green](🟢 Basic)[/] Depthmap of the Image [medium_purple3](None to estimate)[/]"
    )]=None,
) -> None:
    """Input images from Path, URL, Directories and its estimated Depthmap (Lazy load)"""
    self.config.image = image
    self.config.depth = depth

build

build() -> None
Source code in Projects/DepthFlow/DepthFlow/Scene.py
119
120
121
122
123
124
125
def build(self) -> None:
    self.image = ShaderTexture(scene=self, name="image").repeat(False)
    self.depth = ShaderTexture(scene=self, name="depth").repeat(False)
    self.shader.fragment = DEPTH_SHADER
    self.base_duration = 5.0
    self.subsample = 2
    self.ssaa = 1.2

setup

setup() -> None
Source code in Projects/DepthFlow/DepthFlow/Scene.py
127
128
129
130
def setup(self) -> None:
    if (not self.config.animation):
        self.config.animation.add(Actions.Orbital())
    self._load_inputs()

update

update() -> None
Source code in Projects/DepthFlow/DepthFlow/Scene.py
132
133
def update(self) -> None:
    self.config.animation.apply(self)

handle

handle(message: ShaderMessage) -> None
Source code in Projects/DepthFlow/DepthFlow/Scene.py
135
136
137
138
139
140
def handle(self, message: ShaderMessage) -> None:
    ShaderScene.handle(self, message)

    if isinstance(message, ShaderMessage.Window.FileDrop):
        self.input(image=message.first, depth=message.second)
        self._load_inputs()

pipeline

pipeline() -> Iterable[ShaderVariable]
Source code in Projects/DepthFlow/DepthFlow/Scene.py
142
143
144
def pipeline(self) -> Iterable[ShaderVariable]:
    yield from ShaderScene.pipeline(self)
    yield from self.state.pipeline()

set_upscaler

set_upscaler(
    upscaler: Optional[BrokenUpscaler] = None,
) -> BrokenUpscaler
Source code in Projects/DepthFlow/DepthFlow/Scene.py
151
152
153
def set_upscaler(self, upscaler: Optional[BrokenUpscaler]=None) -> BrokenUpscaler:
    self.config.upscaler = (upscaler or NoUpscaler())
    return self.config.upscaler

clear_upscaler

clear_upscaler() -> None
Source code in Projects/DepthFlow/DepthFlow/Scene.py
154
155
def clear_upscaler(self) -> None:
    self.config.upscaler = NoUpscaler()

load_upscaler

load_upscaler() -> None
Source code in Projects/DepthFlow/DepthFlow/Scene.py
156
157
def load_upscaler(self) -> None:
    self.config.upscaler.download()

realesr

realesr(**options) -> Realesr
Source code in Projects/DepthFlow/DepthFlow/Scene.py
159
160
def realesr(self, **options) -> Realesr:
    return self.set_upscaler(Realesr(**options))

upscayl

upscayl(**options) -> Upscayl
Source code in Projects/DepthFlow/DepthFlow/Scene.py
161
162
def upscayl(self, **options) -> Upscayl:
    return self.set_upscaler(Upscayl(**options))

waifu2x

waifu2x(**options) -> Waifu2x
Source code in Projects/DepthFlow/DepthFlow/Scene.py
163
164
def waifu2x(self, **options) -> Waifu2x:
    return self.set_upscaler(Waifu2x(**options))

set_estimator

set_estimator(estimator: BaseEstimator) -> BaseEstimator
Source code in Projects/DepthFlow/DepthFlow/Scene.py
168
169
170
def set_estimator(self, estimator: BaseEstimator) -> BaseEstimator:
    self.config.estimator = estimator
    return self.config.estimator

load_estimator

load_estimator() -> None
Source code in Projects/DepthFlow/DepthFlow/Scene.py
171
172
def load_estimator(self) -> None:
    self.config.estimator.load_model()

depth_anything1

depth_anything1(**options) -> DepthAnythingV1
Source code in Projects/DepthFlow/DepthFlow/Scene.py
174
175
def depth_anything1(self, **options) -> DepthAnythingV1:
    return self.set_estimator(DepthAnythingV1(**options))

depth_anything2

depth_anything2(**options) -> DepthAnythingV2
Source code in Projects/DepthFlow/DepthFlow/Scene.py
176
177
def depth_anything2(self, **options) -> DepthAnythingV2:
    return self.set_estimator(DepthAnythingV2(**options))

depth_pro

depth_pro(**options) -> DepthPro
Source code in Projects/DepthFlow/DepthFlow/Scene.py
178
179
def depth_pro(self, **options) -> DepthPro:
    return self.set_estimator(DepthPro(**options))

zoe_depth

zoe_depth(**options) -> ZoeDepth
Source code in Projects/DepthFlow/DepthFlow/Scene.py
180
181
def zoe_depth(self, **options) -> ZoeDepth:
    return self.set_estimator(ZoeDepth(**options))

marigold

marigold(**options) -> Marigold
Source code in Projects/DepthFlow/DepthFlow/Scene.py
182
183
def marigold(self, **options) -> Marigold:
    return self.set_estimator(Marigold(**options))

set

set(**options) -> Actions.Set
Source code in Projects/DepthFlow/DepthFlow/Scene.py
188
189
def set(self, **options) -> Actions.Set:
    return self.config.animation.add(Actions.Set(**options))

add

add(**options) -> Actions.Add
Source code in Projects/DepthFlow/DepthFlow/Scene.py
190
191
def add(self, **options) -> Actions.Add:
    return self.config.animation.add(Actions.Add(**options))

linear

linear(**options) -> Actions.Linear
Source code in Projects/DepthFlow/DepthFlow/Scene.py
194
195
def linear(self, **options) -> Actions.Linear:
    return self.config.animation.add(Actions.Linear(**options))

sine

sine(**options) -> Actions.Sine
Source code in Projects/DepthFlow/DepthFlow/Scene.py
196
197
def sine(self, **options) -> Actions.Sine:
    return self.config.animation.add(Actions.Sine(**options))

cosine

cosine(**options) -> Actions.Cosine
Source code in Projects/DepthFlow/DepthFlow/Scene.py
198
199
def cosine(self, **options) -> Actions.Cosine:
    return self.config.animation.add(Actions.Cosine(**options))

triangle

triangle(**options) -> Actions.Triangle
Source code in Projects/DepthFlow/DepthFlow/Scene.py
200
201
def triangle(self, **options) -> Actions.Triangle:
    return self.config.animation.add(Actions.Triangle(**options))

vertical

vertical(**options) -> Actions.Vertical
Source code in Projects/DepthFlow/DepthFlow/Scene.py
204
205
def vertical(self, **options) -> Actions.Vertical:
    return self.config.animation.add(Actions.Vertical(**options))

horizontal

horizontal(**options) -> Actions.Horizontal
Source code in Projects/DepthFlow/DepthFlow/Scene.py
206
207
def horizontal(self, **options) -> Actions.Horizontal:
    return self.config.animation.add(Actions.Horizontal(**options))

zoom

zoom(**options) -> Actions.Zoom
Source code in Projects/DepthFlow/DepthFlow/Scene.py
208
209
def zoom(self, **options) -> Actions.Zoom:
    return self.config.animation.add(Actions.Zoom(**options))

circle

circle(**options) -> Actions.Circle
Source code in Projects/DepthFlow/DepthFlow/Scene.py
210
211
def circle(self, **options) -> Actions.Circle:
    return self.config.animation.add(Actions.Circle(**options))

dolly

dolly(**options) -> Actions.Dolly
Source code in Projects/DepthFlow/DepthFlow/Scene.py
212
213
def dolly(self, **options) -> Actions.Dolly:
    return self.config.animation.add(Actions.Dolly(**options))

orbital

orbital(**options) -> Actions.Orbital
Source code in Projects/DepthFlow/DepthFlow/Scene.py
214
215
def orbital(self, **options) -> Actions.Orbital:
    return self.config.animation.add(Actions.Orbital(**options))

vignette

vignette(**options) -> Actions.Vignette
Source code in Projects/DepthFlow/DepthFlow/Scene.py
218
219
def vignette(self, **options) -> Actions.Vignette:
    return self.config.animation.add(Actions.Vignette(**options))

blur

blur(**options) -> Actions.Blur
Source code in Projects/DepthFlow/DepthFlow/Scene.py
220
221
def blur(self, **options) -> Actions.Blur:
    return self.config.animation.add(Actions.Blur(**options))

inpaint

inpaint(**options) -> Actions.Inpaint
Source code in Projects/DepthFlow/DepthFlow/Scene.py
222
223
def inpaint(self, **options) -> Actions.Inpaint:
    return self.config.animation.add(Actions.Inpaint(**options))

colors

colors(**options) -> Actions.Colors
Source code in Projects/DepthFlow/DepthFlow/Scene.py
224
225
def colors(self, **options) -> Actions.Colors:
    return self.config.animation.add(Actions.Colors(**options))

export_name

export_name(path: Path) -> Path

Modifies the output path if on batch exporting mode

Source code in Projects/DepthFlow/DepthFlow/Scene.py
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
def export_name(self, path: Path) -> Path:
    """Modifies the output path if on batch exporting mode"""
    options = list(self._iter_batch_input(self.config.image))

    # Single file mode, return as-is
    if (len(options) == 1):
        return path

    # Assume it's a local path
    image = Path(options[self.index])
    original = image.stem

    # Use the URL filename as base
    if validators.url(image):
        original = BrokenPath.url_filename(image)

    # Build the batch filename: 'file' + -'custom stem'
    return path.with_stem(original + "-" + path.stem)

ui

ui() -> None
Source code in Projects/DepthFlow/DepthFlow/Scene.py
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
def ui(self) -> None:
    if (state := imgui.slider_float("Height", self.state.height, 0, 1, "%.2f"))[0]:
        self.state.height = max(0, state[1])
    if (state := imgui.slider_float("Steady", self.state.steady, 0, 1, "%.2f"))[0]:
        self.state.steady = max(0, state[1])
    if (state := imgui.slider_float("Focus", self.state.focus, 0, 1, "%.2f"))[0]:
        self.state.focus = max(0, state[1])
    if (state := imgui.slider_float("Invert", self.state.invert, 0, 1, "%.2f"))[0]:
        self.state.invert = max(0, state[1])
    if (state := imgui.slider_float("Zoom", self.state.zoom, 0, 2, "%.2f"))[0]:
        self.state.zoom = max(0, state[1])
    if (state := imgui.slider_float("Isometric", self.state.isometric, 0, 1, "%.2f"))[0]:
        self.state.isometric = max(0, state[1])
    if (state := imgui.slider_float("Dolly", self.state.dolly, 0, 5, "%.2f"))[0]:
        self.state.dolly = max(0, state[1])

    imgui.text("- True camera position")
    if (state := imgui.slider_float("Center X", self.state.center_x, -self.aspect_ratio, self.aspect_ratio, "%.2f"))[0]:
        self.state.center_x = state[1]
    if (state := imgui.slider_float("Center Y", self.state.center_y, -1, 1, "%.2f"))[0]:
        self.state.center_y = state[1]

    imgui.text("- Fixed point at height changes")
    if (state := imgui.slider_float("Origin X", self.state.origin_x, -self.aspect_ratio, self.aspect_ratio, "%.2f"))[0]:
        self.state.origin_x = state[1]
    if (state := imgui.slider_float("Origin Y", self.state.origin_y, -1, 1, "%.2f"))[0]:
        self.state.origin_y = state[1]

    imgui.text("- Parallax offset")
    if (state := imgui.slider_float("Offset X", self.state.offset_x, -2, 2, "%.2f"))[0]:
        self.state.offset_x = state[1]
    if (state := imgui.slider_float("Offset Y", self.state.offset_y, -2, 2, "%.2f"))[0]:
        self.state.offset_y = state[1]