def main(image_first="1st.jpg", image_second="2nd.jpg"): image_first = PointExtractor(image_filename=image_first, name="test1") image_first.set_points(4) image_second = PointExtractor(image_filename=image_second, name="test2") image_second.set_points(4) image_first_hists = [] for i in range(len(image_first.points)): image_first_hists.append( get_grad_hist(image_first.image_array, image_first.points[i])) image_second_hists = [] for i in range(len(image_second.points)): image_second_hists.append( get_grad_hist(image_second.image_array, image_second.points[i])) pairs = [] for i in range(4): variances = [] for j in range(4): variances.append( variance_check(image_first_hists[i], image_second_hists[j])) pairs.append((i, variances.index(min(variances)))) image_first.save() image_second.save() result_image = ImageReader(image_array=np.concatenate( (image_first.image_array, image_second.image_array), axis=1), name="concatenated") offset = image_first.image_array.shape[1] for pair in pairs: offset_point = image_second.points[pair[1]] print(offset_point) offset_point = offset_point[0] + offset, offset_point[1] result_image.draw_line(image_first.points[pair[0]], offset_point) result_image.imshow()
print("batter knee point height in pixels: {}".format( abs(batter_keypoint_heights[0][1] - home_points[0][1]))) print("high right point for strike zone: {}".format( (strike_zone_top_height, home_points[0][0]))) print("low left point for strike zone: {}".format( (batter_keypoint_heights[0][1], home_points[1][0]))) high_right = (int(home_points[0][0]), int(strike_zone_top_height)) low_left = (home_points[1][0], batter_keypoint_heights[0][1]) new_points = [high_right, low_left] point_extraction.revert() point_extraction.destroy_window() display_image = ImageReader(image_array=point_extraction.image_array, name="result") display_image.draw_line((high_right[0], high_right[1]), (high_right[0], low_left[1])) display_image.draw_line((high_right[0], high_right[1]), (low_left[0], high_right[1])) display_image.draw_line((low_left[0], low_left[1]), (low_left[0], high_right[1])) display_image.draw_line((low_left[0], low_left[1]), (high_right[0], low_left[1])) display_image.imshow() actual_strike_bot = abs(low_left[1] - home_points[1][1]) * ( actual_distance / pixel_distance) actual_strike_height = abs(low_left[1] - high_right[1]) * ( actual_distance / pixel_distance) actual_strike_width = abs(low_left[0] - high_right[0]) * (actual_distance / pixel_distance) print("actual strike zone start bottom: {}cm".format(