Skip to content

Commit 3d25658

Browse files
committed
Samples: Automatic updates to public repository
Remember to do the following: 1. Ensure that modified/deleted/new files are correct 2. Make this commit message relevant for the changes 3. Force push 4. Delete branch after PR is merged If this commit is an update from one SDK version to another, make sure to create a release tag for previous version.
1 parent 8bac643 commit 3d25658

3 files changed

Lines changed: 40 additions & 13 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ from the camera can be used.
177177
CUDA device using OpenCV.
178178
- [CaptureAndConvertToDlpackTensorOnCuda] - Capture a 2D+3D frame
179179
with the Zivid SDK and build DLPack tensors directly from the
180-
Zivid DeviceArrays on the CUDA device.
180+
Zivid DeviceArrays on the CUDA
181181
- **Transform**
182182
- [TransformPointCloudFromMillimetersToMeters] - Transform point
183183
cloud data from millimeters to meters.

source/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ set(Clipp_DEPENDING
157157
CaptureViaGenICam
158158
CaptureWithSettingsFromYML
159159
CaptureWritePCLVis3D
160+
Connect
160161
ConvertZDF
161162
GammaCorrection
162163
HandEyeCalibration

source/Camera/Basic/Connect/Connect.cpp

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,43 @@
11
/*
22
Connect to a Zivid camera using the different available methods.
33
4-
Replace the IP address and serial number in the code with the ones of your camera.
4+
Replace the IP address, serial number and hostname in the code with the ones of your camera,
5+
or provide them with --serial, --ip and --hostname.
56
*/
67

78
#include <Zivid/Zivid.h>
89

10+
#include <clipp.h>
11+
912
#include <iostream>
1013

1114
namespace
1215
{
16+
struct CameraIdentifiers
17+
{
18+
std::string serialNumber{ "2020C0DE" };
19+
std::string ipAddress{ "172.28.60.5" };
20+
std::string hostname{ "zivid-2020C0DE.local" };
21+
};
22+
23+
CameraIdentifiers parseOptions(int argc, char **argv)
24+
{
25+
CameraIdentifiers identifiers;
26+
auto cli =
27+
(clipp::option("--serial")
28+
& clipp::value("serial number", identifiers.serialNumber).doc("Serial number of the camera"),
29+
clipp::option("--ip") & clipp::value("ip address", identifiers.ipAddress).doc("IP address of the camera"),
30+
clipp::option("--hostname")
31+
& clipp::value("hostname", identifiers.hostname).doc("Hostname of the camera"));
32+
33+
if(!clipp::parse(argc, argv, cli))
34+
{
35+
std::cout << clipp::usage_lines(cli, "Connect") << std::endl;
36+
throw std::runtime_error{ "Invalid usage" };
37+
}
38+
return identifiers;
39+
}
40+
1341
void printDiscoveredCameras(Zivid::Application &zivid)
1442
{
1543
std::cout << "Discovered cameras:" << std::endl;
@@ -21,41 +49,39 @@ namespace
2149
}
2250
} // namespace
2351

24-
int main()
52+
int main(int argc, char **argv)
2553
{
2654
try
2755
{
56+
const auto identifiers = parseOptions(argc, argv);
57+
2858
Zivid::Application zivid;
2959

3060
printDiscoveredCameras(zivid);
3161

32-
std::cout << "The serial number, IP address and hostname below are placeholders. "
33-
"Replace them with the ones of your camera."
34-
<< std::endl;
35-
3662
{
3763
std::cout << "Connecting to the first available camera" << std::endl;
3864
auto camera = zivid.connectCamera();
3965
camera.disconnect();
4066
}
4167

4268
{
43-
std::cout << "Connecting to the camera with a specific serial number" << std::endl;
44-
auto camera = zivid.connectCamera(Zivid::CameraInfo::SerialNumber{ "2020C0DE" });
69+
std::cout << "Connecting to the camera with serial number " << identifiers.serialNumber << std::endl;
70+
auto camera = zivid.connectCamera(Zivid::CameraInfo::SerialNumber{ identifiers.serialNumber });
4571
camera.disconnect();
4672
}
4773

4874
{
49-
std::cout << "Connecting to the camera at a specific IP address" << std::endl;
50-
auto camera = zivid.connectCamera(Zivid::CameraAddress{ "172.28.60.5" });
75+
std::cout << "Connecting to the camera at IP address " << identifiers.ipAddress << std::endl;
76+
auto camera = zivid.connectCamera(Zivid::CameraAddress{ identifiers.ipAddress });
5177
camera.disconnect();
5278
}
5379

5480
{
55-
std::cout << "Connecting to the camera at a specific hostname" << std::endl;
81+
std::cout << "Connecting to the camera at hostname " << identifiers.hostname << std::endl;
5682
// The default hostname format is "zivid-<serial-number>.local".
5783
// The hostname cannot be read or set through the SDK.
58-
auto camera = zivid.connectCamera(Zivid::CameraAddress{ "zivid-2020C0DE.local" });
84+
auto camera = zivid.connectCamera(Zivid::CameraAddress{ identifiers.hostname });
5985
camera.disconnect();
6086
}
6187

0 commit comments

Comments
 (0)