darcyai.output.live_feed_stream

LiveFeedStream Objects

class LiveFeedStream(OutputStream)

An output stream that streams the frames.

Arguments

  • path (str): Path to host the live stream.
  • flask_app (Flask): Flask app to host the live stream. Defaults to None.
  • port (int): Port to host the live stream. Defaults to None.
  • host (str): Host to host the live stream. Defaults to None.
  • fps (int): Frames per second to stream. Defaults to 20.
  • quality (int): Quality of the JPEG encoding. Defaults to 100.

Examples

>>> from darcyai.output.live_feed_stream import LiveFeedStream
>>> live_feed_stream = LiveFeedStream(path="/live-feed",
>>>                                   port=8080,
>>>                                   host="0.0.0.0",
>>>                                   fps=20,
>>>                                   quality=100)

write

def write(data: Any) -> Any

Write a frame to the stream.

Arguments

  • data (Any): Frame to write.

Returns

Any: The annotated frame.

Examples

>>> from darcyai.output.live_feed_stream import LiveFeedStream
>>> live_feed_stream = LiveFeedStream(path="/live-feed",
>>>                                   port=8080,
>>>                                   host="0.0.0.0",
>>>                                   fps=20,
>>>                                   quality=100)
>>> live_feed_stream.write(frame)

get_fps

def get_fps() -> int

Get the frames per second.

Returns

int: Frames per second.

Examples

>>> from darcyai.output.live_feed_stream import LiveFeedStream
>>> live_feed_stream = LiveFeedStream(path="/live-feed",
>>>                                   port=8080,
>>>                                   host="0.0.0.0",
>>>                                   fps=20,
>>>                                   quality=100)
>>> live_feed_stream.get_fps()

set_fps

def set_fps(fps: int) -> None

Set the frames per second.

Arguments

  • fps (int): Frames per second.

Examples

>>> from darcyai.output.live_feed_stream import LiveFeedStream
>>> live_feed_stream = LiveFeedStream(path="/live-feed",
>>>                                   port=8080,
>>>                                   host="0.0.0.0",
>>>                                   fps=20,
>>>                                   quality=100)
>>> live_feed_stream.set_fps(30)

get_quality

def get_quality() -> int

Get the quality of the JPEG encoding.

Returns

int: Quality of the JPEG encoding.

Examples

>>> from darcyai.output.live_feed_stream import LiveFeedStream
>>> live_feed_stream = LiveFeedStream(path="/live-feed",
>>>                                   port=8080,
>>>                                   host="0.0.0.0",
>>>                                   fps=20,
>>>                                   quality=100)
>>> live_feed_stream.get_quality()

set_quality

def set_quality(quality: int) -> None

Set the quality of the JPEG encoding.

Arguments

  • quality (int): Quality of the JPEG encoding.

Examples

>>> from darcyai.output.live_feed_stream import LiveFeedStream
>>> live_feed_stream = LiveFeedStream(path="/live-feed",
>>>                                   port=8080,
>>>                                   host="0.0.0.0",
>>>                                   fps=20,
>>>                                   quality=100)
>>> live_feed_stream.set_quality(50)

close

def close() -> None

Close the stream.

Examples

>>> from darcyai.output.live_feed_stream import LiveFeedStream
>>> live_feed_stream = LiveFeedStream(path="/live-feed",
>>>                                   port=8080,
>>>                                   host="0.0.0.0",
>>>                                   fps=20,
>>>                                   quality=100)
>>> live_feed_stream.close()

get_latest_frame

def get_latest_frame() -> Any

Returns the latest frame in JPEG format.

Returns

Any: Latest frame.

Examples

>>> from darcyai.output.live_feed_stream import LiveFeedStream
>>> live_feed_stream = LiveFeedStream(path="/live-feed",
>>>                                   port=8080,
>>>                                   host="0.0.0.0",
>>>                                   fps=20,
>>>                                   quality=100)
>>> live_feed_stream.get_latest_frame()