create_dataset.py
def create_dataset(dataset_dir, count, camera):
    """
    Generates dataset from the connected camera
    :param dataset_dir: Directory to store the output.
    :param count: Number of frames to capture.
    :param camera: Camera ID for opencv lib.
    :raise Exception: If camera does not work.
    """
    if input("Are you ready to take pictures? y/n: ") == "n":
        exit(0)
    video = cv2.VideoCapture(camera)
    cnt = 0
    print(f"Turning on the camera with id {camera} to take {count} frames. Smile :)...")
    unique_seq = unique_id()
    while cnt != count:
        filename = f"{dataset_dir}{next(unique_seq)}.png"

        check, frame = video.read()
        if not check:
            raise Exception("Camera does not work!")
        print(f"{cnt}/{count}: Capturing: {filename}....")
        cv2.imwrite(filename, frame)
        time.sleep(2)
        cnt += 1
    print("Dataset created successfully!")
    video.release()

    Generates dataset from the connected camera
    :param dataset_dir: Directory to store the output.
    :param count: Number of frames to capture.
    :param camera: Camera ID for opencv lib.
    :raise Exception: If camera does not work.
    
Generates dataset from the connected camera
Generates dataset from the connected camera
def create_dataset(dataset_dir, count, camera):
    if input("Are you ready to take pictures? y/n: ") == "n":
        exit(0)
    video = cv2.VideoCapture(camera)
    cnt = 0
    print(f"Turning on the camera with id {camera} to take {count} frames. Smile :)...")
    unique_seq = unique_id()
    while cnt != count:
        filename = f"{dataset_dir}{next(unique_seq)}.png"
        check, frame = video.read()
        if not check:
            raise Exception("Camera does not work!")
        print(f"{cnt}/{count}: Capturing: {filename}....")
        cv2.imwrite(filename, frame)
        time.sleep(2)
        cnt += 1
    print("Dataset created successfully!")
    video.release()
def create_dataset ( dataset_dir , count , camera ) : if input ( "Are you ready to take pictures? y/n: " ) == "n" : exit ( 0 ) video = cv2 . VideoCapture ( camera ) cnt = 0 print ( f"Turning on the camera with id {camera} to take {count} frames. Smile :)..." ) unique_seq = unique_id ( ) while cnt != count : filename = f"{dataset_dir}{next(unique_seq)}.png" check , frame = video . read ( ) if not check : raise Exception ( "Camera does not work!" ) print ( f"{cnt}/{count}: Capturing: {filename}...." ) cv2 . imwrite ( filename , frame ) time . sleep ( 2 ) cnt += 1 print ( "Dataset created successfully!" ) video . release ( )
Generates dataset from the connected camera
Generates dataset from the connected camera
"""
    Generates dataset from the connected camera
    :param dataset_dir: Directory to store the output.
    :param count: Number of frames to capture.
    :param camera: Camera ID for opencv lib.
    :raise Exception: If camera does not work.
    """
If camera does not work.
If camera does not work .
Exception
dataset_dir
Directory to store the output.
Directory to store the output .
count
Number of frames to capture.
Number of frames to capture .
camera
Camera ID for opencv lib.
Camera ID for opencv lib .