|
|
|
@ -38,7 +38,6 @@ class LoadStreams: |
|
|
|
|
|
|
|
|
|
Attributes: |
|
|
|
|
sources (str): The source input paths or URLs for the video streams. |
|
|
|
|
imgsz (int): The image size for processing, defaults to 640. |
|
|
|
|
vid_stride (int): Video frame-rate stride, defaults to 1. |
|
|
|
|
buffer (bool): Whether to buffer input streams, defaults to False. |
|
|
|
|
running (bool): Flag to indicate if the streaming thread is running. |
|
|
|
@ -60,13 +59,12 @@ class LoadStreams: |
|
|
|
|
__len__: Return the length of the sources object. |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
def __init__(self, sources="file.streams", imgsz=640, vid_stride=1, buffer=False): |
|
|
|
|
def __init__(self, sources="file.streams", vid_stride=1, buffer=False): |
|
|
|
|
"""Initialize instance variables and check for consistent input stream shapes.""" |
|
|
|
|
torch.backends.cudnn.benchmark = True # faster for fixed-size inference |
|
|
|
|
self.buffer = buffer # buffer input streams |
|
|
|
|
self.running = True # running flag for Thread |
|
|
|
|
self.mode = "stream" |
|
|
|
|
self.imgsz = imgsz |
|
|
|
|
self.vid_stride = vid_stride # video frame-rate stride |
|
|
|
|
|
|
|
|
|
sources = Path(sources).read_text().rsplit() if os.path.isfile(sources) else [sources] |
|
|
|
@ -193,7 +191,6 @@ class LoadScreenshots: |
|
|
|
|
|
|
|
|
|
Attributes: |
|
|
|
|
source (str): The source input indicating which screen to capture. |
|
|
|
|
imgsz (int): The image size for processing, defaults to 640. |
|
|
|
|
screen (int): The screen number to capture. |
|
|
|
|
left (int): The left coordinate for screen capture area. |
|
|
|
|
top (int): The top coordinate for screen capture area. |
|
|
|
@ -210,7 +207,7 @@ class LoadScreenshots: |
|
|
|
|
__next__: Captures the next screenshot and returns it. |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
def __init__(self, source, imgsz=640): |
|
|
|
|
def __init__(self, source): |
|
|
|
|
"""Source = [screen_number left top width height] (pixels).""" |
|
|
|
|
check_requirements("mss") |
|
|
|
|
import mss # noqa |
|
|
|
@ -223,7 +220,6 @@ class LoadScreenshots: |
|
|
|
|
left, top, width, height = (int(x) for x in params) |
|
|
|
|
elif len(params) == 5: |
|
|
|
|
self.screen, left, top, width, height = (int(x) for x in params) |
|
|
|
|
self.imgsz = imgsz |
|
|
|
|
self.mode = "stream" |
|
|
|
|
self.frame = 0 |
|
|
|
|
self.sct = mss.mss() |
|
|
|
@ -258,7 +254,6 @@ class LoadImages: |
|
|
|
|
various formats, including single image files, video files, and lists of image and video paths. |
|
|
|
|
|
|
|
|
|
Attributes: |
|
|
|
|
imgsz (int): Image size, defaults to 640. |
|
|
|
|
files (list): List of image and video file paths. |
|
|
|
|
nf (int): Total number of files (images and videos). |
|
|
|
|
video_flag (list): Flags indicating whether a file is a video (True) or an image (False). |
|
|
|
@ -274,7 +269,7 @@ class LoadImages: |
|
|
|
|
_new_video(path): Create a new cv2.VideoCapture object for a given video path. |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
def __init__(self, path, imgsz=640, vid_stride=1): |
|
|
|
|
def __init__(self, path, vid_stride=1): |
|
|
|
|
"""Initialize the Dataloader and raise FileNotFoundError if file not found.""" |
|
|
|
|
parent = None |
|
|
|
|
if isinstance(path, str) and Path(path).suffix == ".txt": # *.txt file with img/vid/dir on each line |
|
|
|
@ -298,7 +293,6 @@ class LoadImages: |
|
|
|
|
videos = [x for x in files if x.split(".")[-1].lower() in VID_FORMATS] |
|
|
|
|
ni, nv = len(images), len(videos) |
|
|
|
|
|
|
|
|
|
self.imgsz = imgsz |
|
|
|
|
self.files = images + videos |
|
|
|
|
self.nf = ni + nv # number of files |
|
|
|
|
self.video_flag = [False] * ni + [True] * nv |
|
|
|
@ -377,7 +371,6 @@ class LoadPilAndNumpy: |
|
|
|
|
Attributes: |
|
|
|
|
paths (list): List of image paths or autogenerated filenames. |
|
|
|
|
im0 (list): List of images stored as Numpy arrays. |
|
|
|
|
imgsz (int): Image size, defaults to 640. |
|
|
|
|
mode (str): Type of data being processed, defaults to 'image'. |
|
|
|
|
bs (int): Batch size, equivalent to the length of `im0`. |
|
|
|
|
count (int): Counter for iteration, initialized at 0 during `__iter__()`. |
|
|
|
@ -386,13 +379,12 @@ class LoadPilAndNumpy: |
|
|
|
|
_single_check(im): Validate and format a single image to a Numpy array. |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
def __init__(self, im0, imgsz=640): |
|
|
|
|
def __init__(self, im0): |
|
|
|
|
"""Initialize PIL and Numpy Dataloader.""" |
|
|
|
|
if not isinstance(im0, list): |
|
|
|
|
im0 = [im0] |
|
|
|
|
self.paths = [getattr(im, "filename", f"image{i}.jpg") for i, im in enumerate(im0)] |
|
|
|
|
self.im0 = [self._single_check(im) for im in im0] |
|
|
|
|
self.imgsz = imgsz |
|
|
|
|
self.mode = "image" |
|
|
|
|
# Generate fake paths |
|
|
|
|
self.bs = len(self.im0) |
|
|
|
|