ouster-lidar / ouster-sdk

Ouster, Inc. sample code
Other
469 stars 438 forks source link

PCap to Visualization #452

Closed sanehk closed 2 years ago

sanehk commented 2 years ago

Hi~

I'm trying to Visualization from PCAP, Json data. (Env : Windows, Visualstudio 2022, Qt 5.12.2, c++)

Now I have some problem with visualization. MyTest visualization displays wierd view.

  1. View on OusterStudio (same Pcap file) ouster_studio_1

  2. View on MyTest App (same Pcap file) test1

  3. MyTest code

    auto handle = sensor_utils::replay_initialize(strPCap); auto info = sensor::metadata_from_json(strJson);

    size_t w = info.format.columns_per_frame; size_t h = info.format.pixels_per_column;

    auto scan = LidarScan(w, h, info.format.udp_profile_lidar);

    get_complete_scan(handle, scan, info);

    XYZLut lut = make_xyz_lut(info); auto range = scan.field(sensor::RANGE); auto cloud = cartesian(range, lut);

    viz::PointViz viz("Viz test"); viz::add_default_controls(viz);

    size_t cloud_size = cloud.rows();

    std::vector points; std::vector colors;

    auto clouds = std::make_shared (cloud_size); viz.add(clouds);

    // auto reflect = scan.field(sensor::REFLECTIVITY);

    for (int i = 0; i < cloud.rows(); i++) { auto xyz = cloud.row(i); if (!xyz.isApproxToConstant(0, 0)) { points.push_back(xyz(0)); points.push_back(xyz(1)); points.push_back(xyz(2));

    }

    }

    clouds->set_xyz(points.data()); // clouds->set_key(colors.data()); reflect??

    viz.update(); viz.run();

If I export cartesian coordinates from MyTest App to 'CSV' file, and open it another PointsCloud viewer (CloudCompare) It displays well.

Am I missing some process to displaying by 'ouster::viz' ? And I wish to let me get some c++ example to visualization by using 'SIGNAL' or 'REFLECTIVITY' with XYZ coordinates.

Thank you.

kairenw commented 2 years ago

Hi @sanehk,

Do you simply need to visualize with SIGNAL or REFLECTIVITY using a utility, or do you need to write your own C++ visualization for it? If you simply need a utility, we recommend the visualizer available with the Python SDK.

In any case, the reason you're getting this is that set_xyz expects the data in different order:

     * Set the XYZ values.
     *
     * @param[in] xyz pointer to array of exactly 3n where n is number of
     * points, so that the xyz position of the ith point is i, i + n, i + 2n

Whereas you're putting the xyz position of the ith point in i*3, i*3+1, i*3+2, if that makes sense

sanehk commented 2 years ago

@kairenw I want to visualize SINAL or REFLECTIVITY using ouster_viz library in my C++ project.

I'll change set_xyz order.

Thank you~