我有这个非常简单的工具,可以使用Opencv在线显示激光雷达传感器数据。我想为它创建一个GUI,但我是该领域的菜鸟。对材料或示例的任何建议? GUI现在只需要做两件事:
以下是我根据一些YouTube视频提出的内容。我该怎么办?
private: int Display_Point_Cloud() {
// Create Viewer
cv: :viz::Viz3d viewer("Velodyne");
const boost: :asio::ip::address address=boost::asio::ip::address::from_string("192.168.1.77");
const unsigned short port=2368;
velodyne: :VLP16Capture capture(address, port);
std: :vector<velodyne::Laser> lasers;
capture>>lasers;
std: :vector<cv::Vec3f> buffer (lasers.size());
for (const velodyne: :Laser& laser: lasers) {
const double distance=static_cast<double>(laser.distance);
const double azimuth=laser.azimuth * CV_PI / 180.0;
const double vertical=laser.vertical * CV_PI / 180.0;
float x=static_cast<float>((distance * std: :cos(vertical)) * std::sin(azimuth));
float y=static_cast<float>((distance * std: :cos(vertical)) * std::cos(azimuth));
float z=static_cast<float>((distance * std: :sin(vertical)));
if (x==0.0f && y==0.0f && z==0.0f) {
x=std: :numeric_limits<float>::quiet_NaN();
y=std: :numeric_limits<float>::quiet_NaN();
z=std: :numeric_limits<float>::quiet_NaN();
}
buffer.push_back(cv::Vec3f(x, y, z));
}
// Create Widget
cv::Mat cloudMat=cv::Mat(static_cast<int>(buffer.size()), 1, CV_32FC3, &buffer[0]);
cv::viz::WCloud cloud(cloudMat);
// Show Point Cloud
viewer.showWidget("Cloud", cloud);
viewer.spinOnce();
// Close All Viewers
cv::viz::unregisterAllWindows();
return 0;
}
private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) {}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
Display_Point_Cloud();
}
}
;