コード例 #1
0
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
コード例 #2
0
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,
                                         methods.posmouse)
    cv2.imshow("Vertices selection", frame)

    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
コード例 #3
0
                # print(quadrat_pts_used)
                # print(burrows_coord)

                for i, rows in burrows_coord.iterrows():
                    row_values = [int(rows.ID), (int(rows.Burrow_coord_x), int(rows.Burrow_coord_y)), int(rows.Radius)]
                    # print(row_values)
                    existing_burrows.append(row_values)

            except (TypeError, RuntimeError):
                print("Exiting because of TypeError or RuntimeError")
                pass

        else:
            while True:
                img_preview = img.copy()
                methods.enable_point_capture(True)
                img_preview = methods.draw_points_mousepos(img_preview, methods.quadratpts, methods.posmouse)
                cv2.imshow("Vertices selection", img_preview)

                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))
                    vertices = methods.quadratpts
                    break

                key = cv2.waitKey(1) & 0xFF
                if key == ord("q"):
                    # print("Q - key pressed. Window quit by user")
                    break

            cv2.destroyAllWindows()