def test_full_color_compare(): print('Process lab adjustment') # Loading instances instance_pose = ClassOpenPose() # Loading images image1, image2, pose1, pose2 = ClassDescriptors.load_images_comparision( instance_pose, min_score) # Performing color comparision upper1, lower1 = ClassDescriptors.process_colors_person(pose1, min_score, image1, decode_img=False) upper2, lower2 = ClassDescriptors.process_colors_person(pose2, min_score, image2, decode_img=False) # Performing custom comparison first diff_upper, diff_lower, delta = ClassUtils.compare_colors( upper1, upper2, lower1, lower2) print('Diff upper: {0}'.format(diff_upper)) print('Diff lower: {0}'.format(diff_lower)) print('Delta: {0}'.format(delta)) # Showing images cv2.namedWindow('main_window', cv2.WND_PROP_AUTOSIZE) cv2.imshow('main_window', np.hstack((image1, image2))) cv2.waitKey(0) print('Done!')
def process_btf(): print('Processing BTF transformation') # Loading instances instance_pose = ClassOpenPose() image1, image2, pose1, pose2 = ClassDescriptors.load_images_comparision( instance_pose, min_score) hists1 = ClassDescriptors.get_color_histograms(pose1, min_score, image1, decode_img=False) hists2 = ClassDescriptors.get_color_histograms(pose2, min_score, image2, decode_img=False) # Plotting # plot_histograms(hists1) # Showing first images without transformation cv2.namedWindow('main_window', cv2.WINDOW_AUTOSIZE) upper1, lower1 = ClassDescriptors.process_colors_person(pose1, min_score, image1, decode_img=False) upper2, lower2 = ClassDescriptors.process_colors_person(pose2, min_score, image2, decode_img=False) print('Diff1: {0}'.format(ClassUtils.get_color_diff_rgb(upper1, upper2))) print('Diff2: {0}'.format(ClassUtils.get_color_diff_rgb(lower1, lower2))) cv2.imshow('main_window', np.hstack((image1, image2))) print('Press any key to continue') cv2.waitKey(0) # Perform image transformation image_tr = ClassDescriptors.transform_image(image2, hists2, hists1) upper1, lower1 = ClassDescriptors.process_colors_person(pose1, min_score, image1, decode_img=False) upper2, lower2 = ClassDescriptors.process_colors_person(pose2, min_score, image_tr, decode_img=False) print('Diff1: {0}'.format(ClassUtils.get_color_diff_rgb(upper1, upper2))) print('Diff2: {0}'.format(ClassUtils.get_color_diff_rgb(lower1, lower2))) cv2.imshow('main_window', np.hstack((image1, image_tr))) print('Press any key to continue') cv2.waitKey(0) cv2.destroyAllWindows() print('Done!')
def process_lab_adj(): print('Process lab adjustment') # Loading instances instance_pose = ClassOpenPose() # Loading images image1, image2, pose1, pose2 = ClassDescriptors.load_images_comparision( instance_pose, min_score) # Performing color comparision upper1, lower1 = ClassDescriptors.process_colors_person(pose1, min_score, image1, decode_img=False) upper2, lower2 = ClassDescriptors.process_colors_person(pose2, min_score, image2, decode_img=False) # Performing custom comparison first diff_upper = ClassUtils.get_color_diff_rgb(upper1, upper2) diff_lower = ClassUtils.get_color_diff_rgb(lower1, lower2) print('Diff upper: {0}'.format(diff_upper)) print('Diff lower: {0}'.format(diff_lower)) # Performing lab conversion and equal L values diff_upper_lum = ClassUtils.get_color_diff_rgb_lum(upper1, upper2) diff_lower_lum = ClassUtils.get_color_diff_rgb_lum(lower1, lower2) print('Diff upper lum: {0}'.format(diff_upper_lum)) print('Diff lower lum: {0}'.format(diff_lower_lum)) # Showing images cv2.namedWindow('main_window', cv2.WND_PROP_AUTOSIZE) cv2.imshow('main_window', np.hstack((image1, image2))) cv2.waitKey(0) print('Done!')
def test_view_histogram(): print('Test view histogram') # Loading instances instance_pose = ClassOpenPose() # Loading images image1, _, pose1, _ = ClassDescriptors.load_images_comparision( instance_pose, min_score, load_one_img=True) # Drawing poses ClassDescriptors.draw_pose(image1, pose1, min_score) # Showing image cv2.namedWindow('main_window', cv2.WND_PROP_AUTOSIZE) cv2.imshow('main_window', image1) print('Press a key to continue') cv2.waitKey(0) cv2.destroyAllWindows() print('Done!')
def process_test_color_eq(): print('Processing color eq') # Loading instances instance_pose = ClassOpenPose() im1, im2, pose1, pose2 = ClassDescriptors.load_images_comparision( instance_pose, min_score) upper1, lower1 = ClassDescriptors.process_colors_person(pose1, min_score, im1, decode_img=False) upper2, lower2 = ClassDescriptors.process_colors_person(pose2, min_score, im2, decode_img=False) img_size = 100 image1 = np.zeros((img_size, img_size, 3), np.uint8) image2 = np.zeros((img_size, img_size, 3), np.uint8) image3 = np.zeros((img_size, img_size, 3), np.uint8) image4 = np.zeros((img_size, img_size, 3), np.uint8) # Generating elements in list cv2.namedWindow('aux_window', cv2.WND_PROP_AUTOSIZE) cv2.imshow('aux_window', np.hstack((im1, im2))) # BGR format -> Generating image1[:, :] = (upper1[2], upper1[1], upper1[0]) image2[:, :] = (lower1[2], lower1[1], lower1[0]) image3[:, :] = (upper2[2], upper2[1], upper2[0]) image4[:, :] = (lower2[2], lower2[1], lower2[0]) # Performing custom comparison first diff_upper = ClassUtils.get_color_diff_rgb(upper1, upper2) diff_lower = ClassUtils.get_color_diff_rgb(lower1, lower2) print('Diff upper: {0}'.format(diff_upper)) print('Diff lower: {0}'.format(diff_lower)) cv2.namedWindow('main_window', cv2.WND_PROP_AUTOSIZE) cv2.imshow( 'main_window', np.hstack((np.vstack((image1, image2)), np.vstack((image3, image4))))) cv2.waitKey(0) # Performing lab conversion and equal L values diff_upper_lum = ClassUtils.get_color_diff_rgb_lum(upper1, upper2) diff_lower_lum = ClassUtils.get_color_diff_rgb_lum(lower1, lower2) # Transform point upper2_eq = ClassUtils.eq_lum_rgb_colors(upper1, upper2) lower2_eq = ClassUtils.eq_lum_rgb_colors(lower1, lower2) print('Diff upper lum: {0}'.format(diff_upper_lum)) print('Diff lower lum: {0}'.format(diff_lower_lum)) image3[:, :] = (upper2_eq[2], upper2_eq[1], upper2_eq[0]) image4[:, :] = (lower2_eq[2], lower2_eq[1], lower2_eq[0]) # Showing again image cv2.imshow( 'main_window', np.hstack((np.vstack((image1, image2)), np.vstack((image3, image4))))) cv2.waitKey(0) # Destroying all windows cv2.destroyAllWindows() print('Done!')