def main():
    pipeline, aline = measure_conf.config()
    only_get_pc_thread = threading.Thread(target=only_get_pc,
                                          args=(
                                              pipeline,
                                              aline,
                                          ))
    only_get_pc_thread.start()
    try:
        while True:
            print('main process. main thread.')
            start = time.time()
            #location = module_gps.get_location()
            location = {"lat": 1.0, "lon": 3.0}
            time.sleep(1)
            depth_image = measure_pc_to_csv_temp.measure_pc(pipeline, aline)

            # メタデータ生成
            meta = {
                'time': time.time(),
                'depth_image': depth_image,
                'location': {
                    'lat': location["lat"],
                    'lon': location["lon"]
                },
                'result': None
            }
            q.put(meta)
            elapsed_time = time.time() - start
            print(f'1周の所要時間:{elapsed_time}\n')
    except KeyboardInterrupt:
        print('点群/位置情報取得プログラムを終了します.')
        pipeline.stop()
예제 #2
0
def operate(pipeline, align):
    i=0
    while(i<2):
        # 起伏計測
        #result = [{'id': j, 'sum': sum(range(i*j))} for j in range(10000)]
        depth_image = measure_pc_to_csv_temp.measure_pc(pipeline, align)
        print(f'{i}番目の起伏計測終了')
        i+=1
예제 #3
0
def only_get_pc(pipeline, aline):
    try:
        while True:
            print('start only get pc')
            depth_image = measure_pc_to_csv_temp.measure_pc(pipeline, aline)
            q.put({"time": time.time(), "depth_image": depth_image})
    except KeyboardInterrupt:
        print('only get pcを終了します.')
def only_get_pc(pipeline, aline):
    try:
        while True:
            print('main process. sub thread.')
            depth_image = measure_pc_to_csv_temp.measure_pc(pipeline, aline)
            q.put({"time": time.time(), "depth_image": depth_image})
            #time.sleep(1)
    except KeyboardInterrupt:
        print('only get pcを終了します.')
def main(q):
    pipeline, aline = measure_conf.config()
    try:
        while True:
            print('main process...')
            start = time.time()
            depth_image = measure_pc_to_csv_temp.measure_pc(pipeline, aline)

            # json生成
            depth = {
                'time': time.time(),
                'depth_image': depth_image,
                'result': None
            }
            q.put(depth)
            print(f'main process queue size: {q.qsize()}')
            elapsed_time = time.time() - start
            print(f'1周の所要時間:{elapsed_time}\n')
            #time.sleep(2)
    except KeyboardInterrupt:
        print('点群/位置情報取得プログラムを終了します.')
        pipeline.stop()
예제 #6
0
def main():
    global buf, data_store_flag, buf_index, store_index
    print("realsense setup...")
    pipeline, aline = measure_conf.config()

    try:
        while True:
            start = time.time()
            depth_image = measure_pc_to_csv_temp.measure_pc(pipeline, aline)

            # dict生成
            depth = {
                'time': time.time(),
                'depth_image': depth_image,
                'result': None
            }
            # 保存処理
            buf[buf_index].append(depth)
            print(f'現在のbuf_index: {buf_index}')
            print(
                f'0: {len(buf[0])}, 1: {len(buf[1])}, 2: {len(buf[2])}, 3: {len(buf[3])}, 4: {len(buf[4])}'
            )

            if len(buf[buf_index]) >= 5:
                data_store_flag[buf_index] = True
                print(data_store_flag)
                #sub_thread = threading.Thread(target=sub_thread, args=(buf_index, store_index))
                #sub_thread.start()
                if buf_index != 4:
                    buf_index += 1
                else:
                    buf_index = 0

            elapsed_time = time.time() - start
            print(f'1周の所要時間:{elapsed_time}\n')
            time.sleep(1)
    except KeyboardInterrupt:
        print('深度情報取得プログラムを終了します.')
        pipeline.stop()
예제 #7
0
def main():
    print("realsense setup...")
    pipeline, aline = measure_conf.config()

    try:
        while True:
            start = time.time()
            depth_image_ndarray = measure_pc_to_csv_temp.measure_pc(
                pipeline, aline)

            # dict生成
            depth = {
                'time': time.time(),
                'depth_image': depth_image_ndarray,
                'result': None
            }
            # 保存処理
            d = ''.join(map(str, depth_image_ndarray))
            file_ssd.write(d)
            elapsed_time = time.time() - start
            print(f'1周の所要時間:{elapsed_time}\n')
    except KeyboardInterrupt:
        print('深度情報取得プログラムを終了します.')
        pipeline.stop()
예제 #8
0
sub_process = threading.Thread(target=sub_thread, args=(q, ))
sub_thread.start()


def ndarray_to_csv(file_name, ndarray):
    with open(file_name, 'w') as f:
        writer = csv.writer(f)
        for value in ndarray:
            writer.writerow(value)
    print('change depth array to csv')


try:
    while True:
        start = time.time()
        depth_image_ndarray = measure_pc_to_csv_temp.measure_pc(
            pipeline, aline)

        # メタデータ生成
        depth = {
            'time': time.time(),
            'depth_image': depth_image_ndarray,
            'result': None
        }
        q.put(depth)
        print(type(depth_image_ndarray))
        #d = ''.join(map(str,depth_image_ndarray))
        #with open('test.txt', 'w') as f:
        #    f.write(d)
        #ndarray_to_csv('test.csv', depth_image_ndarray)
        elapsed_time = time.time() - start
        print(f'深度情報取得1周の所要時間:{elapsed_time}\n')