快速捕获教程
介绍
本教程介绍了使用Zivid SDK捕获点云的最基本方法。
如果您使用的是MATLAB,请查 看 Zivid Quick Capture Tutorial for MATLAB
先决条件
安装 Zivid软件 。
对于Python:安装 zivid-python
初始化
调用Zivid SDK中的任何API都需要初始化Zivid应用程序并在程序运行时使其保持活动状态。
Zivid::Application zivid;
var zivid = new Zivid.NET.Application();
app = zivid.Application()
连接
auto camera = zivid.connectCamera();
var camera = zivid.ConnectCamera();
camera = app.connect_camera()
配置
const auto suggestSettingsParameters = Zivid::CaptureAssistant::SuggestSettingsParameters{
Zivid::CaptureAssistant::SuggestSettingsParameters::AmbientLightFrequency::none,
Zivid::CaptureAssistant::SuggestSettingsParameters::MaxCaptureTime{ std::chrono::milliseconds{ 1200 } }
};
std::cout << "Running Capture Assistant with parameters:\n" << suggestSettingsParameters << std::endl;
auto settings = Zivid::CaptureAssistant::suggestSettings(camera, suggestSettingsParameters);
var suggestSettingsParameters = new Zivid.NET.CaptureAssistant.SuggestSettingsParameters {
AmbientLightFrequency =
Zivid.NET.CaptureAssistant.SuggestSettingsParameters.AmbientLightFrequencyOption.none,
MaxCaptureTime = Duration.FromMilliseconds(1200)
};
Console.WriteLine("Running Capture Assistant with parameters:\n{0}", suggestSettingsParameters);
var settings = Zivid.NET.CaptureAssistant.Assistant.SuggestSettings(camera, suggestSettingsParameters);
suggest_settings_parameters = zivid.capture_assistant.SuggestSettingsParameters(
max_capture_time=datetime.timedelta(milliseconds=1200),
ambient_light_frequency=zivid.capture_assistant.SuggestSettingsParameters.AmbientLightFrequency.none,
)
print(f"Running Capture Assistant with parameters: {suggest_settings_parameters}")
settings = zivid.capture_assistant.suggest_settings(camera, suggest_settings_parameters)
捕获
const auto frame = camera.capture(settings);
using(var frame = camera.Capture(settings))
with camera.capture(settings) as frame:
保存
const auto dataFile = "Frame.zdf";
frame.save(dataFile);
var dataFile = "Frame.zdf";
frame.Save(dataFile);
data_file = "Frame.zdf"
frame.save(data_file)
通过API选择要使用的格式。请查看 Point Cloud 获取支持格式的列表。
小技巧
您可以在 Zivid Studio 中打开并查看 Frame.zdf
文件 。
结论
本教程展示了使用Zivid SDK连接相机、捕获和保存图像的最基本的方法。
如需了解更深入的教程,请查看完整的 捕获教程。