from load_streams import LoadStreams
from person_jump_check import PersonJump
import cv2
import datetime



stream_loader = LoadStreams(r"rtsp://admin:lww123456@172.16.22.16:554/Streaming/Channels/0501")
region_points = [(820, 200), (1600, 200), (1600, 530), (820, 530)]



counter = PersonJump(
    show=True,
    region=region_points,
    model="no_train_person_jump.pt",
    classes=[0],
    conf=0.4,
)


if __name__ == "__main__":
    model_name = "no_train_person_jump.pt"
    for sources, imgs, _ in stream_loader:
        im0 = counter.count(imgs[0])
        if counter.in_count > 0:
            data_time = str(datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S"))
            file_name = "high_speed_fall" + data_time + ".jpg"
            print(file_name)
            cv2.imwrite(file_name, im0)
            print("person jump!")
            counter.in_count = 0

