print('velocity is %f' % velocity) #Read png image os.chdir(directory_image) initial = 0 ndvi = cv2.imread('%s.png' % initial) ndvi = cv2.rotate( ndvi, cv2.ROTATE_180 ) #I don't know why but completed images are opposite so modify here #Give rotation angle to the png image rotated_ndvi = ip.rotation(ndvi, initial_degree, scanrate, velocity, width) os.chdir(directory_image_rotated) #cv2.namedWindow('img', cv2.WINDOW_NORMAL) #cv2.imshow('img',rotated_ndvi) #cv2.waitKey(0) cv2.imwrite('0.png', rotated_ndvi) #cv2.destroyAllWindows() for i in range(flen - 1): t = i + 1 os.chdir(directory_all_HS) #Move to directory of HS files degree = ip.Yaw(HS_files[t], imu, initial_degree, initial_yaw) os.chdir(directory_image) #Move to directory of images ndvi = cv2.imread('%s.png' % t) rotated_ndvi = ip.rotation(ndvi, degree, scanrate, velocity, width) os.chdir(directory_image_rotated) #Move to directory of rotated images cv2.imwrite('%s.png' % t, rotated_ndvi) print('%d done' % t)
all_norm_image_RGB = np.append(initial_norm_image_RGB,norm_image_RGB, axis=0) print(all_norm_image_RGB.shape) else: all_norm_image_RGB = np.append(all_norm_image_RGB,norm_image_RGB, axis=0) print(norm_image_RGB.shape) ''' j = j + 1 print('j = %d' % j) #Confirm line working or turning. If turning then break os.chdir(directory_all_HS) #Move to directory of HS files initial_degree = ip.FirstDirection( HS_files[0], gps) #initial degree means initial yaw using rotation initial_yaw = ip.firstYaw(HS_files[0], imu) #This is for yaw angle from second image on degree = ip.Yaw(HS_files[j], imu, initial_degree, initial_yaw) past_degree = ip.Yaw(HS_files[j - 1], imu, initial_degree, initial_yaw) diference = abs(degree - past_degree) print('Degree deviation = %f' % diference) if diference > 10: print('Finish the first row') break ''' os.chdir(directory_image) #cv2.namedWindow('img', cv2.WINDOW_NORMAL) #cv2.imshow('img',norm_image_RGB) #cv2.waitKey(0) cv2.imwrite('big0.png' , all_norm_image_RGB) #cv2.destroyAllWindows() '''
for i in range(number - 1): os.chdir(directory_image) j = j + 1 print('j = %d' % j) image = cv2.imread('%s.png' % j) if i == 0: #The first append is initial and next image, the second one is all_images and next image all_images = np.append(initial_image, image, axis=0) print(all_images.shape) else: all_images = np.append(all_images, image, axis=0) print(all_images.shape) #Confirm line working or turning. If turning, then check the number by the end and concatenate the number of images os.chdir(directory_all_HS) degree = ip.Yaw(HS_files[j], imu, initial_degree, initial_yaw) next_degree = ip.Yaw( HS_files[j + number - 1], imu, initial_degree, initial_yaw ) #next_degree means the last image in concatenated images difference = abs(degree - next_degree) print('Degree deviation = %f' % difference) #The process of the end of the row if difference > 10: del all_images last_number = j os.chdir(directory_image) initial_image = cv2.imread('%d.png' % j) print('Last initial image is %d' % j) #Detect the number of remain images while True: os.chdir(directory_all_HS) #Move to directory of HS files
os.chdir(directory_all_HS) velocity = ip.speed(HS_files[0], HS_files[1], gps) rotated_ndvi = ip.rotation(ndvi, initial_degree, scanrate, velocity, width) os.chdir(directory_image_rotated) #cv2.namedWindow('img', cv2.WINDOW_NORMAL) #cv2.imshow('img',rotated_ndvi) #cv2.waitKey(0) cv2.imwrite('0.png', rotated_ndvi) #cv2.destroyAllWindows() print('0 done') for i in range(flen - 1): t = i + 1 os.chdir(directory_all_HS) #Move to directory of HS files degree = ip.Yaw(HS_files[t], imu, initial_degree, initial_yaw) past_degree = ip.Yaw(HS_files[t - 1], imu, initial_degree, initial_yaw) #print(degree) #print(past_degree) #Initialize yaw direction if the difference between past and current degree is larger than 20 if abs(degree - past_degree) > 10: initial_degree = ip.FirstDirection( HS_files[t], gps) #initial degree means initial yaw using rotation initial_yaw = ip.firstYaw( HS_files[t], imu) #This is for yaw angle from second image on degree = ip.Yaw(HS_files[t], imu, initial_degree, initial_yaw) print('IMU Initialized!') os.chdir(directory_image) #Move to directory of images ndvi = cv2.imread('%s.png' % t) rotated_ndvi = ip.rotation(ndvi, degree, scanrate, velocity, width) os.chdir(directory_image_rotated) #Move to directory of rotated images