print("Cannot read video file") sys.exit() counter = 0 startTime = datetime.now() cv2.destroyAllWindows() # From warp.py # fgbg1 = cv2.createBackgroundSubtractorMOG2(history=5000, varThreshold=20, detectShadows=False) # fgbg2 = cv2.createBackgroundSubtractorMOG2(history=5000, varThreshold=100) fgbg3 = cv2.createBackgroundSubtractorKNN(history=5000, dist2Threshold=250) for_er = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3)) for_di = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (7, 7)) info = [ methods.CompileInformation("name_video", video_name), methods.CompileInformation("local_creation", local_creation), methods.CompileInformation("creation", creation), methods.CompileInformation("length_vid", length_vid), methods.CompileInformation("fps", fps), methods.CompileInformation("vid_duration", vid_duration), methods.CompileInformation("target_frame", target_frame), methods.CompileInformation("side", side), methods.CompileInformation("conversion", conversion) ] info_video = {} for i in info: info_video[i.name] = i.value start, end, step, _, _ = methods.frame_to_time(info_video)
if key == ord("q"): # print("Q - key pressed. Window quit by user") break cv2.destroyAllWindows() M, side, vertices_draw, IM, conversion = methods.calc_proj(vertices) center = (0, 0) mini = np.amin(vertices_draw, axis=0) maxi = np.amax(vertices_draw, axis=0) img = cv2.imread(args["image"]) img = cv2.resize(img, dsize=(0, 0), fx=0.5, fy=0.5) img = cv2.warpPerspective(img, M, (side, side)) info = [methods.CompileInformation("name_image", image_name), methods.CompileInformation("image_dimx", height), methods.CompileInformation("image_dimy", width), methods.CompileInformation("image_dimz", channels), methods.CompileInformation("conversion", conversion), methods.CompileInformation("side", side)] info_image = {} for i in info: info_image[i.name] = i.value if create_new_file: print("There is not burrows map file for this video, creating one.") head_true = True name_result_file = image_path + "/" + "_burrows_map_" + sampling_time + ".csv"
# species = str(input("* Please enter species name for this individual: ")) # sex = str(input("* Please enter sex for this individual: ")) # handedness = str(input(" *Please enter handedness for this individual: ")) except ValueError: print("Error in input. Using pre-defined information") name = video_name + "_" + methods.random_name() # species = "unknown" # sex = "unknown" # handedness = "unknown" else: name = video_name + "_" + methods.random_name() # species = "unknown" # sex = "unknown" # handedness = "unknown" info = [methods.CompileInformation("name_video", video_name), methods.CompileInformation("local_creation", local_creation), methods.CompileInformation("creation", creation), methods.CompileInformation("length_vid", length_vid), methods.CompileInformation("fps", fps), methods.CompileInformation("vid_duration", vid_duration), methods.CompileInformation("target_frame", target_frame), methods.CompileInformation("side", (width, height, side)), methods.CompileInformation("conversion", conversion), methods.CompileInformation("tracker", "Manual_tracking"), methods.CompileInformation("Crab_ID", name)] info_video = {} for i in info: info_video[i.name] = i.value
# area = width_m * height_m size = dist * new_conversion print('\n' 'Measure capture:', '\n' 'Starting point', coord[0], '\n' 'Ending point', coord[1]) print('Lenght in pixels = ', round(dist, 2)) print('Pixel to centimeter conversion factor = ', round(new_conversion, 2)) # print('Width of field of view in meters = ', width_m) # print('Height of field of view in meters = ', height_m) # print('Area of field of view in square meters = ', area) print('Size in cm = ', round(size, 2)) info = [ methods.CompileInformation("frame_number", selected_f), methods.CompileInformation("coordinate_0", coord[0]), methods.CompileInformation("coordinate_1", coord[1]), methods.CompileInformation("length_pixels", dist), methods.CompileInformation("conversion_factor", new_conversion), methods.CompileInformation("length_cm", size) ] info_video = {} for i in info: info_video[i.name] = i.value save_measures(args["video"], info_video, False) # break
print("Radius {}".format(radius)) # cv2.circle(img, (int((xi + x) / 2), int((yi + y) / 2)), radius, (0, 0, 255), 1) draw = False fgbg1 = cv2.createBackgroundSubtractorMOG2(history=5000, varThreshold=20) fgbg2 = cv2.createBackgroundSubtractorMOG2(history=5000, varThreshold=100) fgbg3 = cv2.createBackgroundSubtractorKNN(history=5000, dist2Threshold=250) for_er = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, constant.ERODE) for_di = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, constant.DILATE) info = [ methods.CompileInformation("name_video", video_name), methods.CompileInformation("local_creation", local_creation), methods.CompileInformation("creation", creation), methods.CompileInformation("length_vid", length_vid), methods.CompileInformation("fps", fps), methods.CompileInformation("vid_duration", vid_duration), methods.CompileInformation("target_frame", target_frame), methods.CompileInformation("side", (width, height, side)), methods.CompileInformation("conversion", conversion), methods.CompileInformation("tracker", "Manual_tracking"), methods.CompileInformation("Crab_ID", None) ] info_video = {} for i in info: info_video[i.name] = i.value
video_name = "GP010016" name = "testing" # try: # name = video_name + "_" + str(input("* Please enter name for this individual: ")) # # species = str(input("* Please enter species name for this individual: ")) # # sex = str(input("* Please enter sex for this individual: ")) # # handedness = str(input(" *Please enter handedness for this individual: ")) # except ValueError: # print("Error in input. Using pre-defined information") # name = video_name + "_" + methods.random_name() print("I have given you a name. Your name is ", name) info = [ methods.CompileInformation("name_video", video_name), methods.CompileInformation("local_creation", "local_creation"), methods.CompileInformation("creation", "creation"), methods.CompileInformation("length_vid", "length_vid"), methods.CompileInformation("fps", "fps"), methods.CompileInformation("vid_duration", "vid_duration"), methods.CompileInformation("target_frame", "target_frame"), methods.CompileInformation("side", "side"), methods.CompileInformation("conversion", "conversion"), methods.CompileInformation("tracker", "str(tracker)"), methods.CompileInformation("Crab_ID", name) ] info_video = {} for i in info: info_video[i.name] = i.value