def visualize(eigens): l1 = eigens[:,:,0] l2 = eigens[:,:,1] m1 = np.min(l1) m2 = np.min(l2) r1 = np.max(l1) - m1 r2 = np.max(l2) - m2 if r1 == 0: r1 = 1 if r2 == 0: r2 = 1 l1cv = ut.np2cv(np.array( (1 - ((l1-m1) / r1)) * 255, dtype='uint8')) l2cv = ut.np2cv(np.array( (1 - ((l2-m2) / r2)) * 255, dtype='uint8')) hg.cvNamedWindow('eigen value 1', 1) hg.cvNamedWindow('eigen value 2', 1) hg.cvShowImage('eigen value 1', l1cv) hg.cvShowImage('eigen value 2', l2cv) while True: k = hg.cvWaitKey(33) if k == ' ': return if k == 'x': exit()
def convert_ROS_image_to_cvimage(ROS_image, width, height): ROS_image = np.array(ROS_image, dtype='uint8') imNP = np.reshape(ROS_image,(height,width, 3)) cvimage = ut.np2cv(imNP) return cvimage