def line_map(size, pre_data_array, lineMap_array): lf = LidarFunctions() data_id = pre_data_array[0] data_size = int(pre_data_array[1]) data = np.frombuffer(pre_data_array.get_obj(), c.c_uint16)[2:(data_size + 2)].reshape(-1, 2) lineMap = lf.draw_line_map(np.zeros(size, dtype=c.c_uint8), data) lineMap_array[0] = data_id lineMap_array[1:] = lineMap.reshape(-1) print("LineMap:", data_id)
def main_map(size, pre_data_array, rotation, position, mainMap_array): lf = LidarFunctions() data_id = pre_data_array[0] data_size = pre_data_array[1] position_data = (position[0], position[1]) grad = rotation mainMap = np.frombuffer(mainMap_array.get_obj(), c.c_uint8).reshape(size) mainMap = lf.draw_main_map( np.frombuffer(pre_data_array.get_obj(), c.c_uint16)[2:].reshape(-1, 2), position_data, size, mainMap, grad) mainMap_array[:] = mainMap.reshape(-1)
def process_lidar_data(lidar_data_queue, pre_data_array, lineMap_array, mainMap_array, rotation, size): position = (size[0] // 2, size[1] // 2) while True: if not lidar_data_queue.empty(): st = time.time() data_id, data = lidar_data_queue.get() lf = LidarFunctions() pre_data = lf.prepare_data(data, position) pre_data_array[0] = data_id pre_data_array[1] = pre_data.size pre_data_array[2:pre_data.size + 2] = pre_data.reshape(-1) mp.Process(target=process_data, args=(size, pre_data_array, lineMap_array, mainMap_array, rotation, position)).start()
def movement(last_pre_data, pre_data, rotation, size): last_cp = draw_map(last_pre_data, size) cp = draw_map(pre_data, size) cp = rotate(cp, rotation) # Queue lidar_data = Queue() mainMap_img_q = ImageQueue(5, 2) pci_img_q = ImageQueue(3, 2) lidar = Lidar(lidar_data) lf = LidarFunctions() print(lidar.start_lidar()) size = (5000, 5000) position = (size[0] // 2, size[1] // 2) mainMap = np.zeros(size, np.uint8) # mainMapArray = Array() new_scan_event = Event() get_lidar_data = Process(target=lidar.get_scan_v3, args=(new_scan_event, 3)) start_time = time.time() last_line_map = None rotation_counter = 0 last_rotation = 0 new_scan_event.set() try:
import numpy as np import pandas as pd import cv2 import sklearn import matplotlib from modules import LidarFunctions lf = LidarFunctions() data_frame = pd.read_csv("data_set.csv") data_set1 = np.array([data_frame["0"], data_frame["1"]], dtype=np.uint8) data_set2 = np.array([data_frame["2"], data_frame["3"]], dtype=np.uint8) print(data_set1) image1 = lf.draw_point_cloud(data_set1.T, (500, 500)) image2 = lf.draw_point_cloud(data_set2.T, (500, 500)) images = np.hstack((image1, image2)) print(images.shape) cv2.imshow("Image", cv2.resize(images, (1000, 500))) cv2.waitKey(0) cv2.destroyAllWindows() exit()
import cv2 import numpy as np from modules import Lidar, LidarFunctions, Rotation, Motion, ImageQueue from multiprocessing import Process, Queue, Event import time from imutils import rotate lidar_data = Queue() ImgQueue = ImageQueue(10, 1) lidar = Lidar(lidar_data) lf = LidarFunctions() print(lidar.start_lidar()) size = (5000, 5000) position = (size[0] // 2, size[1] // 2) mainMap = np.zeros(size, np.uint8) new_scan_event = Event() get_lidar_data = Process(target=lidar.get_scan_v3, args=(new_scan_event, 6)) start_time = time.time() last_line_map = None last_image = None last_rotation = None rotation_counter = 0 new_scan_event.set() Motion = Motion(size) try: get_lidar_data.start()
import cv2 import numpy as np from modules import Lidar, LidarFunctions, Rotation, Motion, ImageQueue, Filter from multiprocessing import Process, Queue, Event import time import pandas as pd import sys lidar_data = Queue() ImgQueue = ImageQueue(10, 2) lidar = Lidar(lidar_data) lf = LidarFunctions() print(lidar.start_lidar()) size = (5000, 5000) position = (size[0] // 2, size[1] // 2) new_scan_event = Event() get_lidar_data = Process(target=lidar.get_scan_v3, args=(new_scan_event, 6)) start_time = time.time() last_line_map = None last_data_set = None last_rotation = None rotation_counter = 0 new_scan_event.set() last_point_cloud = np.zeros(size, np.uint8) try: get_lidar_data.start()
import cv2 import numpy as np from modules import Lidar, LidarFunctions from multiprocessing import Process, Queue, Event import time from Process import cal_rot_move # Queue lidar_data = Queue() lidar = Lidar(lidar_data) lf = LidarFunctions() print(lidar.start_lidar()) size = (5000, 5000) position = (size[0] // 2, size[1] // 2) mainMap = np.zeros(size, np.uint8) new_scan_event = Event() get_lidar_data = Process(target=lidar.get_scan_v3, args=(new_scan_event, 3)) start_time = time.time() last_line_map = None grad_counter = 0 new_scan_event.set() try: get_lidar_data.start() while True: if not lidar_data.empty(): st = time.time()