이 메서드 Zivid::Frame::pointCloud() 는 GPU 메모리에서 복사를 수행하지 않습니다.
참고
Zivid::Camera::capture() 메서드는 카메라가 raw 이미지 캡처를 완료한 후 어느 순간에 반환됩니다. Zivid::Frame::pointCloud() 에서 즉시 사용 가능합니다. 그러나 실제 포인트 클라우드 데이터는 GPU에서 처리가 완료된 후에만 사용할 수 있습니다. 데이터 복사 기능에 대한 모든 호출(아래 섹션)은 차단되고 요청된 복사 작업을 진행하기 전에 처리가 완료될 때까지 기다립니다.
Zivid.NET.Frame.PointCloud 특성을 얻을 때는 GPU 메모리에서 복사를 수행하지 않습니다.
참고
Zivid.NET.Camera.Capture() 메서드는 카메라가 raw 이미지 캡처를 완료한 후 어느 순간에 반환됩니다. Zivid.NET.Frame.PointCloud 에서 즉시 사용 가능합니다. 그러나 실제 포인트 클라우드 데이터는 GPU에서 처리가 완료된 후에만 사용할 수 있습니다. 데이터 복사 메서드(아래 섹션)에 대한 모든 호출은 차단되고 요청된 복사 작업을 진행하기 전에 처리가 완료될 때까지 기다립니다.
zivid.frame.point_cloud() 함수는 GPU 메모리에서 복사를 수행하지 않습니다.
참고
zivid.camera.capture() 메서드는 카메라가 raw 이미지 캡처를 완료한 후 어느 순간에 반환됩니다. zivid.frame.point_cloud() 에서 즉시 사용 가능합니다. 그러나 실제 포인트 클라우드 데이터는 GPU에서 처리가 완료된 후에만 사용할 수 있습니다. 데이터 복사 기능에 대한 모든 호출(아래 섹션)은 차단되고 요청된 복사 작업을 진행하기 전에 처리가 완료될 때까지 기다립니다.
std::cout<<"Capturing frame"<<std::endl;frame=camera.capture2D3D(settings);std::cout<<"Copying colors with Zivid API from GPU to CPU"<<std::endl;autocolors=frame.frame2D().value().imageBGRA_SRGB();std::cout<<"Casting the data pointer as a void*, since this is what the OpenCV matrix constructor requires."<<std::endl;auto*dataPtrZividAllocated=const_cast<void*>(static_cast<constvoid*>(colors.data()));std::cout<<"Wrapping this block of data in an OpenCV matrix. This is possible since the layout of \n"<<"Zivid::ColorBGRA_SRGB exactly matches the layout of CV_8UC4. No copying occurs in this step."<<std::endl;constcv::MatbgraZividAllocated(colors.height(),colors.width(),CV_8UC4,dataPtrZividAllocated);std::cout<<"Displaying image"<<std::endl;cv::imshow("BGRA image Zivid Allocated",bgraZividAllocated);cv::waitKey(0);
Copy selected data from GPU to CPU memory (user-allocated)
위 예에서 데이터의 소유권은 반환된 Zivid::Array2D<> 개체에 의해 유지됩니다. 또는 사전 Zivid::PointCloud::copyData(dataPtr) 에 할당된 메모리 버퍼를 제공할 수 있습니다. dataPtr 의 유형은 복사할 대상을 정의합니다(PointXYZ, ColorRGBA, 등.).
이제 위와 똑같은 사용 사례를 살펴보겠습니다. 그러나 이번에는 OpenCV가 필요한 스토리지를 할당하도록 허용합니다. 그런 다음 GPU에서 이 메모리 위치로 데이터를 직접 복사하도록 Zivid API에 요청합니다.
std::cout<<"Allocating the necessary storage with OpenCV API based on resolution info before any capturing"<<std::endl;autobgraUserAllocated=cv::Mat(resolution.height(),resolution.width(),CV_8UC4);std::cout<<"Capturing frame"<<std::endl;autoframe=camera.capture2D3D(settings);autopointCloud=frame.pointCloud();std::cout<<"Copying data with Zivid API from the GPU into the memory location allocated by OpenCV"<<std::endl;pointCloud.copyData(&(*bgraUserAllocated.begin<Zivid::ColorBGRA_SRGB>()));std::cout<<"Displaying image"<<std::endl;cv::imshow("BGRA image User Allocated",bgraUserAllocated);cv::waitKey(0);
때로는 카메라에서 촬영되는 high spatial resolution 와 같은 포인트 클라우드가 필요하지 않을 수 있습니다. 직접 포인트 클라우드를 downsample 할 수 있습니다.
참고
Sampling (3D) describes a hardware-based sub-/downsample method that reduces the resolution of the point cloud during capture while also reducing the acquisition and capture time.
std::cout<<"Setting up visualization"<<std::endl;Zivid::Visualization::Visualizervisualizer;std::cout<<"Visualizing point cloud"<<std::endl;visualizer.showMaximized();visualizer.show(frame);visualizer.resetToFit();std::cout<<"Running visualizer. Blocking until window closes."<<std::endl;visualizer.run();
Console.WriteLine("Setting up visualization");using(varvisualizer=newZivid.NET.Visualization.Visualizer()){Console.WriteLine("Visualizing point cloud");visualizer.Show(frame);visualizer.ShowMaximized();visualizer.ResetToFit();Console.WriteLine("Running visualizer. Blocking until window closes.");visualizer.Run();}
std::cout<<"Getting point cloud from frame"<<std::endl;autopointCloud=frame.pointCloud();std::cout<<"Setting up visualization"<<std::endl;Zivid::Visualization::Visualizervisualizer;std::cout<<"Visualizing point cloud"<<std::endl;visualizer.showMaximized();visualizer.show(pointCloud);visualizer.resetToFit();std::cout<<"Running visualizer. Blocking until window closes."<<std::endl;visualizer.run();
Console.WriteLine("Getting point cloud from frame");varpointCloud=frame.PointCloud;Console.WriteLine("Setting up visualization");varvisualizer=newZivid.NET.Visualization.Visualizer();Console.WriteLine("Visualizing point cloud");visualizer.Show(pointCloud);visualizer.ShowMaximized();visualizer.ResetToFit();Console.WriteLine("Running visualizer. Blocking until window closes.");visualizer.Run();
자세한 내용은 다음을 확인하세요. Visualization Tutorial, 여기서 우리는 타사 라이브러리를 사용하여 포인트 클라우드, 컬러 이미지, 깊이 맵 및 법선 시각화를 다룹니다.