コード例 #1
0
ファイル: frame.py プロジェクト: alpc32/lidar
def process_frame(ar):
    """
    处理雷达每帧数据
    """
    # file_handle = FileHandle()
    frame_cnt = 0
    while True:
        global error_frame
        for temp_i in range(0, 6):
            print 'queuesize', queue.qsize(
            ), 'frame_cnt', frame_cnt, 'error frame', error_frame
        # 处理queue队列中留存的所有扫描数据
        while not queue.empty():
            buf = queue.get()
            # print buf
            buf_split = buf.split()
            buf_split_len = len(buf_split)
            if buf[0] != '\x02' or buf_split_len < 26:
                error_frame += 1
                print "Erro frame"
                continue

            frame_cnt += 1
            point_num = min(hexstr2int(buf_split[25]), buf_split_len - 26)
            # print 'point_num', point_num

            # print buf_split[9], buf_split[10], process_frame(buf_split[26:26+point_num])
            result_data = buf_split[9] + ' ' + \
                get_frame_info(buf_split[26:26 + point_num])
            # result_data = process_frame(buf_split[26:26+proint_num])
            # file_handle.write(result_data + '\n')
            # return
        if ar[0] == 0:
            return
        time.sleep(0.1)
コード例 #2
0
 def print_queue(ar):
     while True:
         while not queue.empty():
             print queue.get()
             print ""
         if ar[0] == 0:
             return
         time.sleep(0.2)
コード例 #3
0
def get_one_frame():
    AllConfig.read_config_file()
    lidar = LidarHandle(AllConfig.host, AllConfig.port)
    lidar.connect()
    for i in range(0, 3):
        lidar.scandata()
    # f = open('one_frame.txt', 'w+')
    scan_flag = Array('i', 1)
    scan_flag[0] = 1
    process_frame(scan_flag)
    while not queue.empty():
        print queue.get()
        print ""
コード例 #4
0
 def print_queue(ar):
     while True:
         f_name = datetime.now().strftime("%Y%m%d%H%M%S")
         fp = gzip.open('out/' + f_name + '.txt.gz', 'wb')
         fp_cnt = 0
         while fp_cnt < frame_num:
             while (not queue.empty()) and (fp_cnt < frame_num):
                 if fp_cnt % 100 == 0:
                     print "get_frame ", fp_cnt
                 fp.write(queue.get())
                 fp.write('\n')
                 fp_cnt += 1
                 if ar[0] == 0:
                     fp.close()
                     return
             if fp_cnt >= frame_num:
                 print f_name, 'close'
                 fp.close()
                 break
         time.sleep(1)
コード例 #5
0
ファイル: frame.py プロジェクト: alpc32/lidar
def read_frame(ar, queue, web_frame_queue, car_queue):
    car_info = [None]*6
    for index in range(0, 6):
        car_info[index] = CarInfo(index)
    '''
    car_info[0].horizon_line = 594
    car_info[1].horizon_line = 573
    car_info[2].horizon_line = 574
    car_info[3].horizon_line = 604
    car_info[4].horizon_line = 481
    car_info[5].horizon_line = 630
    '''
    car_info[0].horizon_line = 559
    car_info[1].horizon_line = 371
    car_info[2].horizon_line = 563
    car_info[3].horizon_line = 605
    car_info[4].horizon_line = 502
    car_info[5].horizon_line = 650
    """
    处理雷达每帧数据
    """
    # file_handle = FileHandle()
    frame_cnt = 0
    begin_flag = 'sSN'
    end_flag = '0'
    while True:
        if ar[0] == 0:
            print 'read_frame close'
            return
        # print 'read_frame process'
        while not queue.empty():
            # print 'read_frame process'
            if ar[0] == 0:
                print 'read_frame close'
                return
            if queue.qsize < 2:
                time.sleep(0.1)
                continue
            buf = queue.get()
            # print buf
            buf_split = buf.split()
            if len(buf_split) == 0:
                continue
            if buf_split[0] == begin_flag:
                if buf_split[-1] != end_flag:
                    next_buf_split = queue.get().split()
                    if next_buf_split[-1] == end_flag:
                        buf_split += next_buf_split
            else:
                continue
            # print buf_split
            xdata, ydata, height, analysis_data = get_frame_info(buf_split, car_info)
            for temp in analysis_data:
                if temp != 'null':
                    car_queue.put(temp)

            # if web_frame_queue.empty():
            web_frame_queue.put([xdata, ydata, height, analysis_data])
            '''
            for i in range(0, len(xdata)):
                print xdata[i], ydata[i]
            print ''
            '''
            # print height

        time.sleep(0.1)