ifm / ifm3d

Library and Utilities for working with ifm pmd-based 3D ToF Cameras
https://api.ifm3d.com
Apache License 2.0
110 stars 69 forks source link

ifm3d O3DP03 camera data getting problem #446

Closed Ken-Jia closed 5 months ago

Ken-Jia commented 7 months ago

Describe the bug auto future = fg_->WaitForFrame(); Unable to obtain frame after running function To Reproduce std::string camera_ip = "169.254.50.239"; int camera_port = 80; // 假设相机的端口号是80

auto cam = ifm3d::Device::MakeShared(camera_ip, camera_port); 
auto fg = std::make_shared<ifm3d::FrameGrabber>(cam, 50010);

fg->Start({ ifm3d::buffer_id::AMPLITUDE_IMAGE, ifm3d::buffer_id::RADIAL_DISTANCE_IMAGE, ifm3d::buffer_id::XYZ });

pcl::visualization::CloudViewer viewer("Real-time Point Cloud Viewer");

while (!viewer.wasStopped()) {
    auto frame = fg->WaitForFrame().get();
    ifm3d::Buffer xyz = frame->GetBuffer(ifm3d::buffer_id::XYZ);

    // ifm3d库从相机缓冲器获取的XYZ数据!!!!!
    ifm3d::Buffer_<ifm3d::Point3D_16S>  xyz_data = xyz;

    // Create a Point Cloud object
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);

    // Populate the Point Cloud with XYZ data
    for (const auto& point : xyz_data)
    {
        pcl::PointXYZ pcl_point;
        pcl_point.x = point.val[1];
        pcl_point.y = point.val[2];
        pcl_point.z = point.val[0];
        cloud->push_back(pcl_point);
    }

    pcl::io::savePCDFileASCII("point_cloud.pcd", *cloud);

    viewer.showCloud(cloud);
}

Expected behavior A clear and concise description of what you expected to happen.

Output/Screenshots If applicable, add console output and/or screenshots to help explain your problem.

Minimal Working Example If applicable/possible, please provide a minimal working example which demonstrates the problem and can be run standalone.

#include <iostream>
int main()
{
  std::cout << "Hello World!" << std::endl;
  return 0;
}

Configuration/Environment (please complete the following information):

Camera Configuration Please include the output of ifm3d dump

Additional context Add any other context about the problem here.

lola-masson commented 7 months ago

Could you please share the version of ifm3d you are using, and the current configuration of the device (the result of ifm3d dump). Thanks

Ken-Jia commented 7 months ago

ifm3d 1.4.3 device O3DP03 using visionassistanter could acces the camera ;also using below code has no error warning auto cam = ifm3d::Device::MakeShared(camera_ip, camera_port); auto fg = std::make_shared(cam, 50010); fg->Start({ ifm3d::buffer_id::AMPLITUDE_IMAGE, ifm3d::buffer_id::RADIAL_DISTANCE_IMAGE, ifm3d::buffer_id::XYZ });

lola-masson commented 7 months ago

Do you get an error message when you run the code you provided in the first message? Or just nothing happens?

Could you please share the JSON configuration of your device (the result of cam->Get()).

Ken-Jia commented 7 months ago

I did not notice the cam;but the fg->isRunning () is True

Ken-Jia commented 7 months ago

I try cam->Get() But cam does not have this function ;I try cam ->WhoAmI() output O3D

lola-masson commented 7 months ago

I'm sorry that's my bad, for the O3D it is cam->ToJSON().

Ken-Jia commented 7 months ago

I have anther question ; how to using c++ code to change the camera trigger mode

lola-masson commented 7 months ago

To change the trigger mode you would use the FromJSON() or the FromJSONStr(), then provide the json path to the trigger mode in the configuration. Something like this:

auto cam = ifm3d::Device::MakeShared(camera_ip);
cam->FromJSONStr(R"({"ifm3d":{"Apps":[{"TriggerMode": "1" }]}})")
github-actions[bot] commented 6 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 5 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.