@@ -6,54 +6,59 @@ Capture a point cloud, with colors, using Zivid SDK, transform it to a Halcon po
66#include < halconcpp/HalconCpp.h>
77
88#include < algorithm>
9- #include < chrono>
109#include < iostream>
1110
1211namespace
1312{
14- Zivid::Settings get2DAnd3DSettings (const Zivid::Camera &camera)
13+ std::string presetPath (const Zivid::Camera &camera)
1514 {
16- auto settings = Zivid::Settings{ Zivid::Settings::Acquisitions{ Zivid::Settings::Acquisition{} },
17- Zivid::Settings::Color{ Zivid::Settings2D{
18- Zivid::Settings2D::Acquisitions{ Zivid::Settings2D::Acquisition{} } } } };
15+ const std::string presetsPath = std::string (ZIVID_SAMPLE_DATA_DIR) + " /Settings" ;
1916
20- auto model = camera.info ().model ();
21- switch (model.value ())
17+ switch (camera.info ().model ().value ())
2218 {
2319 case Zivid::CameraInfo::Model::ValueType::zividTwo:
20+ {
21+ return presetsPath + " /Zivid_Two_M70_ManufacturingSpecular.yml" ;
22+ }
2423 case Zivid::CameraInfo::Model::ValueType::zividTwoL100:
2524 {
26- settings.set (Zivid::Settings::Sampling::Pixel::all);
27- settings.color ().value ().set (Zivid::Settings2D::Sampling::Pixel::all);
28- break ;
25+ return presetsPath + " /Zivid_Two_L100_ManufacturingSpecular.yml" ;
2926 }
3027 case Zivid::CameraInfo::Model::ValueType::zivid2PlusM130:
28+ {
29+ return presetsPath + " /Zivid_Two_Plus_M130_ConsumerGoodsQuality.yml" ;
30+ }
3131 case Zivid::CameraInfo::Model::ValueType::zivid2PlusM60:
32+ {
33+ return presetsPath + " /Zivid_Two_Plus_M60_ConsumerGoodsQuality.yml" ;
34+ }
3235 case Zivid::CameraInfo::Model::ValueType::zivid2PlusL110:
3336 {
34- settings.set (Zivid::Settings::Sampling::Pixel::blueSubsample2x2);
35- settings.color ().value ().set (Zivid::Settings2D::Sampling::Pixel::blueSubsample2x2);
36- break ;
37+ return presetsPath + " /Zivid_Two_Plus_L110_ConsumerGoodsQuality.yml" ;
3738 }
3839 case Zivid::CameraInfo::Model::ValueType::zivid2PlusMR130:
40+ {
41+ return presetsPath + " /Zivid_Two_Plus_MR130_ConsumerGoodsQuality.yml" ;
42+ }
3943 case Zivid::CameraInfo::Model::ValueType::zivid2PlusMR60:
44+ {
45+ return presetsPath + " /Zivid_Two_Plus_MR60_ConsumerGoodsQuality.yml" ;
46+ }
4047 case Zivid::CameraInfo::Model::ValueType::zivid2PlusLR110:
48+ {
49+ return presetsPath + " /Zivid_Two_Plus_LR110_ConsumerGoodsQuality.yml" ;
50+ }
4151 case Zivid::CameraInfo::Model::ValueType::zivid3XL250:
4252 {
43- settings.set (Zivid::Settings::Sampling::Pixel::by2x2);
44- settings.color ().value ().set (Zivid::Settings2D::Sampling::Pixel::by2x2);
45- break ;
53+ return presetsPath + " /Zivid_Three_XL250_DepalletizationQuality.yml" ;
4654 }
4755 case Zivid::CameraInfo::Model::ValueType::zividOnePlusSmall:
4856 case Zivid::CameraInfo::Model::ValueType::zividOnePlusMedium:
49- case Zivid::CameraInfo::Model::ValueType::zividOnePlusLarge:
50- {
51- throw std::runtime_error (" Unsupported camera model '" + model.toString () + " '" );
52- }
53- default : throw std::runtime_error (" Unhandled enum value '" + model.toString () + " '" );
54- }
57+ case Zivid::CameraInfo::Model::ValueType::zividOnePlusLarge: break ;
5558
56- return settings;
59+ default : throw std::runtime_error (" Unhandled enum value '" + camera.info ().model ().toString () + " '" );
60+ }
61+ throw std::invalid_argument (" Invalid camera model" );
5762 }
5863
5964 void savePointCloud (const HalconCpp::HObjectModel3D &model, const std::string &fileName)
@@ -77,7 +82,7 @@ namespace
7782
7883 if (colorsRGBA.height () != height || colorsRGBA.width () != width)
7984 {
80- throw std::runtime_error (" Color image size does not match point cloud size " );
85+ throw std::runtime_error (" the 2D image resolution must match the 3D point cloud resolution " );
8186 }
8287
8388 int numberOfValidPoints =
@@ -175,7 +180,8 @@ int main()
175180 auto camera = zivid.connectCamera ();
176181
177182 std::cout << " Configuring capture settings" << std::endl;
178- const auto settings = get2DAnd3DSettings (camera);
183+ const auto settingsPath = presetPath (camera);
184+ const auto settings = Zivid::Settings (settingsPath);
179185
180186 std::cout << " Capturing frame" << std::endl;
181187 const auto frame = camera.capture2D3D (settings);
0 commit comments