原教程及代码链接:
本教程将介绍如何使用ZED作为位置跟踪器。程序将循环,直到1000位置被抓住。我们假设你已经遵循了以前的教程。
在示例目录中打开一个终端,并执行以下命令:
mkdir build
cd build
cmake ..
make
// Create a ZED camera object
Camera zed;// Set configuration parameters
InitParameters init_params;
init_params.camera_resolution = RESOLUTION_HD720; // Use HD720 video mode (default fps: 60)
dinate_system = COORDINATE_SYSTEM_RIGHT_HANDED_Y_UP; // Use a right-handed Y-up coordinate system
dinate_units = UNIT_METER; // Set units in meters// Open the camera
ERROR_CODE err = zed.open(init_params);
if (err != SUCCESS)exit(-1);
// Enable positional tracking with default parameters
sl::TrackingParameters tracking_parameters;
err = ableTracking(tracking_parameters);
if (err != SUCCESS)exit(-1);
在上面的例子中,我们留下默认的跟踪参数。有关可用参数的列表,请查看在线文档。
// Track the camera position during 1000 frames
int i = 0;
sl::Pose zed_pose;
while (i < 1000) {if (ab() == SUCCESS) {Position(zed_pose, REFERENCE_FRAME_WORLD); // Get the pose of the left eye of the camera with reference to the world frame// Display the translation and timestampprintf("Translation: Tx: %.3f, Ty: %.3f, Tz: %.3f, Timestamp: %llun", Translation().tx, Translation().ty, Translation().tz, zed_pose.timestamp);// Display the orientation quaternionprintf("Orientation: Ox: %.3f, Oy: %.3f, Oz: %.3f, Ow: %.3fnn", Orientation().ox, Orientation().oy, Orientation().oz, Orientation().ow);i++;}
}
这将循环,直到ZED被跟踪1000帧。我们在控制台窗口中显示照相机翻译(以米为单位),并在退出应用程序之前关闭相机。
// Disable positional tracking and close the camera
zed.disableTracking();
zed.close();
return 0;
您现在可以使用ZED作为内向外位置跟踪器。您还可以阅读下一个教程,了解如何使用空间映射。
本文发布于:2024-02-05 01:23:55,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170720862261769.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |