コード例 #1
0
            colors[numpy.logical_not(points.valid), :] = [1, 0, 0, 1]
        else:
            colors[numpy.logical_not(points.valid), :] = 0
        options = {
            "edge_width": 0,
            "face_color": colors,
            "pos": points.positions,
            "size": 2,
        }
        plot_handle.set_data(**options)


if __name__ == "__main__":
    parser = argparse.ArgumentParser(usage='%(prog)s [OPTIONS]')
    parser.add_argument("--capture_path")
    parser.add_argument("--sensor", type=int)
    args = parser.parse_args()

    options = {}
    if args.capture_path is not None:
        options["capture_path"] = args.capture_path
    cepton_sdk.initialize(**options)

    if args.sensor is None:
        sensors_dict = cepton_sdk.get_sensors()
        serial_number = next(iter(sensors_dict.keys()))
    else:
        serial_number = args.sensor

    Renderer(serial_number).run()
コード例 #2
0
Sample script for getting points from a single sensor.
"""

import pprint

import numpy

import cepton_sdk
import cepton_sdk.plot
from common import *

if __name__ == "__main__":
    # Variables
    capture_path = get_sample_capture_path()

    # Initialize
    cepton_sdk.initialize(capture_path=capture_path, enable_wait=True)

    # Get sensor
    sensor = cepton_sdk.Sensor.create_by_index(0)
    pprint.pprint(sensor.information.to_dict())

    # Get points
    listener = cepton_sdk.SensorFramesListener(sensor.serial_number)
    points_list = listener.get_points()
    del listener
    points = points_list[0]

    # Plot
    cepton_sdk.plot.plot_points(points)
コード例 #3
0
def main():
    description = """
Exports Cepton LiDAR points from live sensors or a capture file.
By default, exports frames to individual files.

- Export single frame from capture `lidar.pcap` to CSV files in directory `points`:
    python3 cepton_export --capture_path lidar.pcap --format CSV points
- Export all data from capture `lidar.pcap` to CSV files in directory `points`:
    python3 cepton_export --capture_path lidar.pcap --format CSV --duration -1 points
"""
    parser = argparse.ArgumentParser(
        usage="%(prog)s [OPTIONS] output_dir", description=description, formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument("output_dir", help="Output directory.")
    parser.add_argument("--capture_path", help="Path to PCAP capture file.")
    parser.add_argument("--capture_seek", type=float,
                        help="Capture file seek position [seconds].")
    parser.add_argument("--combine", action="store_true",
                        help="Combine points into single file per sensor.")
    parser.add_argument("--duration", default="0",
                        help="Export duration (if negative, export entire capture file).")
    all_file_types = [x.name for x in cepton_sdk.export.PointsFileType]
    parser.add_argument("--format", default="LAS", choices=all_file_types,
                        type=str.upper, help="Output file format.")
    parser.add_argument("--version", action="version",
                        version="cepton_sdk {}".format(cepton_sdk.__version__))
    args = parser.parse_args()

    file_type = cepton_sdk.export.PointsFileType[args.format]
    duration = parse_time_hms(args.duration)

    output_dir = fix_path(remove_extension(args.output_dir))
    shutil.rmtree(output_dir, ignore_errors=True)
    os.makedirs(output_dir)

    # Initialize
    options = {}
    if args.capture_path is not None:
        options["capture_path"] = fix_path(args.capture_path)
    cepton_sdk.initialize(**options)
    if args.capture_seek is not None:
        cepton_sdk.capture_replay.seek(args.capture_seek)

    listener = cepton_sdk.FramesListener()
    if args.combine:
        cepton_sdk.wait(duration)
        points_dict = listener.get_points()
        for serial_number, points_list in points_dict.items():
            points = cepton_sdk.combine_points(points_list)
            points = process_points(points)
            points = filter_points(points)

            # Save
            path = os.path.join(output_dir, str(serial_number))
            cepton_sdk.export.save_points(points, path, file_type=file_type)
    else:
        t_0 = cepton_sdk.get_time()
        i_frame = collections.defaultdict(lambda: 0)
        while True:
            if duration >= 0:
                if (cepton_sdk.get_time() - t_0) > duration:
                    break
            try:
                points_dict = listener.get_points()
            except:
                break
            for serial_number, points_list in points_dict.items():
                sensor_dir = os.path.join(output_dir, str(serial_number))
                if not os.path.isdir(sensor_dir):
                    os.makedirs(sensor_dir)
                for points in points_list:
                    points = process_points(points)
                    points = filter_points(points)

                    # Save
                    i_frame_tmp = i_frame[serial_number]
                    i_frame[serial_number] += 1
                    path = os.path.join(sensor_dir, str(i_frame_tmp))
                    cepton_sdk.export.save_points(
                        points, path, file_type=file_type)
コード例 #4
0
#!/usr/bin/env python3
"""
Sample script to list attached sensors.
"""

import argparse
import pprint

import cepton_sdk
from cepton_util.common import *

if __name__ == "__main__":
    parser = argparse.ArgumentParser(usage="%(prog)s [OPTIONS]")
    parser.add_argument("--capture_path")
    parser.add_argument("--version",
                        action="version",
                        version="cepton_sdk {}".format(cepton_sdk.__version__))
    args = parser.parse_args()

    capture_path = fix_path(args.capture_path)

    cepton_sdk.initialize(capture_path=capture_path)
    if cepton_sdk.is_live():
        cepton_sdk.wait(3)

    sensors_dict = cepton_sdk.get_sensors()
    for sensor in sensors_dict.values():
        pprint.pprint(sensor.information.to_dict())
コード例 #5
0
"""

import numpy

import cepton_sdk
from common import *


def on_frame(serial_number, points):
    print("Received {} points from sensor {}".format(len(points),
                                                     serial_number))


if __name__ == "__main__":
    # Initialize
    cepton_sdk.initialize(capture_path=get_sample_capture_path())
    sensors_dict = cepton_sdk.get_sensors()
    sensor = next(iter(sensors_dict.values()))

    callback_id = cepton_sdk.listen_frames(on_frame)
    cepton_sdk.wait(0.1)
    cepton_sdk.unlisten_frames(callback_id)

    # Get next frames for all sensors. Wait until data is available.
    listener = cepton_sdk.FramesListener()
    points_dict = listener.get_points()
    del listener

    # Get next frames for single sensor. Wait until data is available.
    listener = cepton_sdk.SensorFramesListener(sensor.serial_number)
    points_list = listener.get_points()