def onChange(trackbarValue): vid.set(1, trackbarValue) ret, frame = vid.read() frame = cv2.resize(frame, (0, 0), fx=resz_val, fy=resz_val) methods.enable_point_capture(constant.CAPTURE_VERTICES) frame = methods.draw_points_mousepos(frame, methods.quadratpts, methods.posmouse) M, width, height, side, vertices_draw, IM, conversion = methods.calc_proj( methods.quadratpts) frame = cv2.warpPerspective(frame, M, (width, height)) # frame = cv2.resize(frame, dsize=(0, 0), fx=args["zoom"], fy=args["zoom"], interpolation=cv2.INTER_NEAREST) # frame = cv2.resize(frame, (960, 540)) cv2.imshow('Measure object length', frame) pass
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() if ret:
if len(methods.quadratpts) == 4: print( "Vertices were captured. Coordinates in pixels are: top-left {}, top-right {}, " "bottom-left {}, and bottom-right {}".format(*methods.quadratpts)) break key = cv2.waitKey(1) & 0xFF if key == ord("q"): # print("Q - key pressed. Window quit by user") break # vid.release() cv2.destroyAllWindows() M, side, vertices_draw, IM, conversion = methods.calc_proj(methods.quadratpts) center = (0, 0) mini = np.amin(vertices_draw, axis=0) maxi = np.amax(vertices_draw, axis=0) ok, frame = vid.read() frame = cv2.warpPerspective(frame, M, (side, side)) if not ok: print("Cannot read video file") sys.exit() counter = 0 startTime = datetime.now() cv2.destroyAllWindows()
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]))] video_name, vid, length_vid, fps, _, _, vid_duration, _ = methods.read_video(file_name) vid, target_frame = methods.set_video_star(vid, args["seconds"], args["frame"], fps) M, width, height, 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) counter = target_frame individuals = track.Crab_ID.unique() colours = methods.select_color(len(individuals)) crab_colors = dict(zip(individuals, colours)) print("\n".join("{}\t{}".format(k, v) for k, v in crab_colors.items())) dict_ind = dict(tuple(track.groupby("Crab_ID"))) f_number = dict(tuple(track.groupby("Frame_number"))) f_max = track["Frame_number"].max() while vid.isOpened():