import numpy as np import math import cv2 from puffyCV._version import __version__ from services.logging_service import initialize_logging log = initialize_logging() pi = np.pi global board_resolution global projection_coefficient global projection_center_point board_resolution = 800 projection_coefficient = 2 projection_center_point = (int(board_resolution/2), int(board_resolution/2)) def draw_line(img, point1, point2, color, thickness): img = cv2.line(img, point1, point2, color, thickness) return img def draw_rectangle(img, top_left, bottom_right, color, thickness): img = cv2.rectangle(img, top_left, bottom_right, color, thickness) return img def draw_circle(img, center_coord, radius, color, thickness): img = cv2.circle(img, center_coord, radius, color, thickness) return img
import cv2 import sys import numpy as np from puffyCV.args import args from services.logging_service import initialize_logging from services.draw_service import draw_rectangle, draw_line roi_rectangle_color = (0, 255, 0) # green roi_rectanlge_thickness = 3 surface_line_color = (0, 0, 255) # red surface_line_thickness = 3 logger = initialize_logging() # Threshold for the image difference of two frames. Value between 0 and 255. 0 means that there needs to be no # difference between two successive frames (which is obviously a bad idea), 255 is the biggest possible difference. # IMAGE_DIFFERENCE_THRESHOLD = 20 def get_capture_device(device_number, image_width, image_height): capture_device = cv2.VideoCapture(device_number) capture_device.set(cv2.CAP_PROP_FRAME_WIDTH, image_width) capture_device.set(cv2.CAP_PROP_FRAME_HEIGHT, image_height) if args.PIXELFORMAT.upper() == 'MJPG': capture_device.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('M', 'J', 'P', 'G')) elif args.PIXELFORMAT.upper() == 'YUYV': capture_device.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('Y', 'U', 'Y', 'V')) else: