Module ivit_i.io.source

Functions

def get_source_object(input: str, camera_resolution: Tuple[int, int] = (1280, 720), fps: int = 30) ‑> ivit_i.io.source.Wrapper

Trying to instance the source object

Args

input : str
input data
camera_resolution : Tuple[int, int], optional
setup camera resolution ( width, height ) if need. Defaults to (1280, 720).
fps : int, optional
setup fps if need. Defaults to 30.

Raises

errors
the latest exception

Returns

Wrapper
return a iVIT Source Wrapper

Classes

class Source (input: str, resolution: Tuple[int, int] = None, fps: int = None)

iVIT Source Object

Args

input : str
the input data, supported image path, image folder,
video path, rtsp uri and usb camera
resolution : Tuple[int, int], optional
A tuple value with width and height,
you will get target size of the frame after setting up. Defaults to None.
fps : int, optional
This option is only for camera. Defaults to None.

Methods

def get_fps(self) ‑> int

Get source fps value

Returns

int
frame per second
def get_shape(self) ‑> Tuple[int, int]

Get source shape (height, width)

Returns

tuple
(height, width)
def get_type(self) ‑> Literal['IMAGE', 'VIDEO', 'DIR', 'CAM', 'RTSP']

Get source type

Returns

str
source type
def read(self) ‑> numpy.ndarray

Return the OpenCV::Mat

def release(self) ‑> None

Release source object

def set_cam(self, width: int = 1280, height: int = 720, fps: int = 30) ‑> None

Setup camera resolution and reload source object which only support usb camera mode.

Args

width : int, optional
camera width. Defaults to 1280.
height : int, optional
camera height. Defaults to 720.
fps : int, optional
camera fps. Defaults to 30.
class SourceV2 (input: str, resolution: Tuple[int, int] = None, fps: int = None, start: bool = False)

iVIT Source Object ( Async )

Args

input : str
the input data, supported image path, image folder, video path, rtsp uri and usb camera.
resolution : Tuple[int, int], optional
A tuple value with width and height, you will get target size of the frame after setting up. Defaults to None.
fps : int, optional
This option is only for camera. Defaults to None.
start : bool, optional
Start the source piepline after instance. Defaults to False.

Notes

  1. Keep update the newest frame
  2. Keep loop in background
  3. Auto reload source

Methods

def get_fps(self) ‑> int

Get source fps value

Returns

int
frame per second
def get_shape(self) ‑> Tuple[int, int]

Get source shape (height, width)

Returns

tuple
(height, width)
def get_thread_id(self) ‑> int

Get threading.Thrad.ident

Returns

int
threading pid
def get_type(self) ‑> Literal['IMAGE', 'VIDEO', 'DIR', 'CAM', 'RTSP']

Get source type

Returns

str
source type
def read(self) ‑> Tuple[bool, numpy.ndarray]

Get source status and current frame

def release(self) ‑> None

Close Thread and release Capture Object

def set_cam(self, width: int = 1280, height: int = 720, fps: int = 30) ‑> None

Setup camera resolution and reload source object which only support usb camera mode.

Args

width : int, optional
camera width. Defaults to 1280.
height : int, optional
camera height. Defaults to 720.
fps : int, optional
camera fps. Defaults to 30.
def start(self) ‑> threading.Thread

Start the source thread.

Returns

threading.Thread
inference thread object

Workflow

  1. Wait Thread launch.
  2. Wait Camera warnup if need.
  3. Set is_ready = True