Exemple #1
0
    "-s",
    "--seconds",
    default=None,
    help=
    "Provide time in seconds of target video section showing the key points")
ap.add_argument(
    "-f",
    "--frame",
    default=None,
    type=int,
    help="Provide the targeted frame of video section you want to jump to")
# ap.add_argument("-c", "--crab_id", default="crab_", help="Provide a name for the crab to be tracked")
args = vars(ap.parse_args())

# Return video information
video_name, vid, length_vid, fps, _, _, vid_duration, _ = methods.read_video(
    args["video"])
local_creation, creation = methods.get_file_creation(args["video"])
# Set frame where video should start to be read
vid, target_frame = methods.set_video_star(vid, args["seconds"], args["frame"],
                                           fps)

if target_frame > length_vid:
    print("You have provided a time beyond the video duration.\n"
          "Video duration is {} seconds".format(round(vid_duration, 2)))
    sys.exit("Crabspy halted")

while vid.isOpened():
    ret, frame = vid.read()

    methods.enable_point_capture(constant.CAPTURE_VERTICES)
    frame = methods.draw_points_mousepos(frame, methods.quadratpts,
Exemple #2
0
quadrat_vertices = [track_meta["vertice_1"].values[0],
                    track_meta["vertice_2"].values[0],
                    track_meta["vertice_3"].values[0],
                    track_meta["vertice_4"].values[0]]

df = pd.DataFrame(quadrat_vertices, columns=["vertices_x"])
df["vertices_x"] = df["vertices_x"].map(lambda x: x.lstrip("(").rstrip(")"))
df[["vertices_x", "vertices_y"]] = df["vertices_x"].str.split(",", expand=True)

quadrat_vertices = [(int(df.iloc[0, 0]), int(df.iloc[0, 1])),
                    (int(df.iloc[1, 0]), int(df.iloc[1, 1])),
                    (int(df.iloc[2, 0]), int(df.iloc[2, 1])),
                    (int(df.iloc[3, 0]), int(df.iloc[3, 1]))]
# print(df)
# print(quadrat_vertices)
video_name, vid, length_vid, fps, _, _, vid_duration, _ = methods.read_video(file_name)
M, side, vertices_draw, IM, conversion = methods.calc_proj(quadrat_vertices)

pts = deque(maxlen=int(track_meta["length_video"].values[0])+250)
(dX, dY) = (0, 0)
target = 1
vid.set(1, target)
counter = target
# color1 = [random.randint(0,255), random.randint(0,255), random.randint(0,255)]
color1 = methods.select_color(1)
# print(name_color)


while vid.isOpened():
    ret, img = vid.read()
Exemple #3
0
    elif event == cv2.EVENT_LBUTTONUP:
        coord.append((x, y))
        draw = False
        cv2.circle(frame, coord[1], 1, (0, 0, 255), 3)

        cv2.line(frame, coord[0], coord[1], (0, 0, 255), 1)
        cv2.imshow('Measure object length', frame)


def mouse_do_nothing(*args, **kwargs):
    pass


# Load video frames
print('Loading video, please wait')
_, vid, length_vid, fps, vid_width, vid_height, vid_duration, _ = methods.read_video(
    args["video"])
# Set frame where video should start to be read
vid, target_frame = methods.set_video_star(vid, args["seconds"], None, fps)
print('Total number of frames in video = ' + str(length_vid))

resz_val = constant.RESIZE
while vid.isOpened():
    ret, frame = vid.read()
    frame = cv2.resize(frame, (0, 0), fx=resz_val, fy=resz_val)
    time.sleep(1)
    methods.enable_point_capture(constant.CAPTURE_VERTICES)
    frame = methods.draw_points_mousepos(frame, methods.quadratpts,
                                         methods.posmouse)
    cv2.imshow("Vertices selection", frame)

    if len(methods.quadratpts) == 4: