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()
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()
Exemplo n.º 3
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()
Exemplo n.º 4
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()
Exemplo n.º 5
0
        queue_data = q.get()
        if queue_data == 'sleep':
            print('5秒待ちます...')
            time.sleep(5)
        else:
            if ('location' not in queue_data):
                print(queue_data["time"])
                print("成功!!!!")
            else:
                process_after_getting_pc.operate(queue_data)
                print('pc and location add...')
    print('sub threadを終了します.')
    sys.exit(0)


pipeline, aline = measure_conf.config()
q = Queue()
q.put('sleep')
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: