def find_c_height(img): frame1 = copy.copy(img) frame2=copy.copy(frame1) frame2[0:359,:]=(0,0,0) frame1[360:720,:]=(0,0,0) a1,check1= findCheckerboardCoordinates(frame1) a2,check2=findCheckerboardCoordinates(frame2) # print([check1,check2]) if check1 and check2: y1 = min([a1[i][1] for i in range(len(a1)) ]) y2 = max([a2[i][1] for i in range(len(a1)) ]) # cv2.line(img,(0,y1),(1920,y1),(0,255,255),2) # cv2.line(img,(0,y2),(1920,y2),(0,255,255),2) # cv2.imshow("img",rescale(img,20)) height = y2-y1 print(height) return True,height return False,0
def find_checker_height2(img): frame1 = copy.copy(img) frame1[360:719,:]=(0,0,0) a1,check1= findCheckerboardCoordinates(frame1) a=[] if check1: for i in range(0,44,9): a.append(two_point_distance(a1[i],a1[i+9])) return True, a return False, a
return True, a return False, a def find_checker_height2(img): frame1 = copy.copy(img) frame1[360:719,:]=(0,0,0) a1,check1= findCheckerboardCoordinates(frame1) a=[] if check1: for i in range(0,44,9): a.append(two_point_distance(a1[i],a1[i+9])) return True, a return False, a a1,check1= findCheckerboardCoordinates(color_image) _,p2 = find_checker_height2(color_image) _,p = find_checker_height(color_image) print("-----------") for i in p2: print(i) # print(i*s.mean(answer)/916.364501953125) print("-----------") for i in p: print(i) # print(i*s.mean(answer)/916.364501953125)
aligned_depth_frame.get_data()) #Getting final depth image #Colorize the depth image colorized_depth = np.asanyarray( colorizer.colorize(aligned_depth_frame).get_data()) # #See the depth image # cv2.imshow("colorized depth",rescale(colorized_depth,50)) color_image = np.asanyarray( color_frame.get_data()) #Getting final RGB frame #UPPER CHECKER BOARD img1 = color_image.copy() #Create Copy img1[230:719, :] = (0, 0, 0) #Threshold remaining area a1, check1 = findCheckerboardCoordinates(img1) #FInd the cordinates if not check1: #if we don't find the checkerboard print("Check 1") cv2.imshow('Found Red', rescale(color_image, 50)) continue # #Visualise the color image with a drawn rectangle. NOTE: Turn it off when processing the RGB Image. Only for debugging. cv2.rectangle(color_image, tuple(a1[53]), tuple(a1[43]), (0, 255, 0), 5) cv2.rectangle(color_image, tuple(a1[46]), tuple(a1[36]), (0, 255, 0), 5) # Repeating the procedure for other checkerboard #BOTTOM Checkerboard img2 = color_image.copy() img2[0:450, :] = (0, 0, 0)