Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Samples: Update to SDK 2.14.0 #267

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ Checks: >
-altera-*,
-bugprone-easily-swappable-parameters,
-concurrency-mt-unsafe,
-abseil-*
-abseil-*,
-google-build-using-namespace
WarningsAsErrors: '*'
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
CheckOptions:
- key: cert-dcl59-cpp.HeaderFileExtensions
value: h,hh,hpp,hxx
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# C++ samples

This repository contains cpp code samples for Zivid SDK v2.13.1. For
This repository contains cpp code samples for Zivid SDK v2.14.0. For
tested compatibility with earlier SDK versions, please check out
[accompanying
releases](https://github.com/zivid/zivid-cpp-samples/tree/master/../../releases).
Expand Down Expand Up @@ -66,6 +66,7 @@ from the camera can be used.
find a compromise.
- [CaptureHDRPrintNormals](https://github.com/zivid/zivid-cpp-samples/tree/master/source/Camera/Advanced/CaptureHDRPrintNormals/CaptureHDRPrintNormals.cpp) - Capture Zivid point clouds, compute normals and print a
subset.
- [CaptureViaGenICam](https://github.com/zivid/zivid-cpp-samples/tree/master/source/Camera/Advanced/CaptureViaGenICam/CaptureViaGenICam.cpp) - Capture using the GenICam interface.
- [MultiCameraCaptureInParallel](https://github.com/zivid/zivid-cpp-samples/tree/master/source/Camera/Advanced/MultiCameraCaptureInParallel/MultiCameraCaptureInParallel.cpp) - Capture point clouds with multiple cameras in parallel.
- [MultiCameraCaptureSequentially](https://github.com/zivid/zivid-cpp-samples/tree/master/source/Camera/Advanced/MultiCameraCaptureSequentially/MultiCameraCaptureSequentially.cpp) - Capture point clouds with multiple cameras sequentially.
- [MultiCameraCaptureSequentiallyWithInterleavedProcessing](https://github.com/zivid/zivid-cpp-samples/tree/master/source/Camera/Advanced/MultiCameraCaptureSequentiallyWithInterleavedProcessing/MultiCameraCaptureSequentiallyWithInterleavedProcessing.cpp) - Capture point clouds with multiple cameras sequentially
Expand Down Expand Up @@ -244,8 +245,8 @@ Note:

-----

To setup and use Zivid in one of these operating systems, please follow
their respective instructions in the following pages:
To set up and use Zivid in one of these operating systems, please follow
their respective instructions on the following pages:

- [Install Zivid + HALCON for
Windows](https://support.zivid.com/latest/api-reference/samples/halcon/install-zivid-halcon-for-windows.html)
Expand All @@ -255,6 +256,8 @@ their respective instructions in the following pages:
Program](https://support.zivid.com/latest/api-reference/samples/halcon/create-a-halcon-hello-world.html)
- [How to Run a HALCON
Sample](https://support.zivid.com/latest/api-reference/samples/halcon/how-to-run-a-halcon-sample.html)
- [Debug in
HALCON](https://support.zivid.com/latest/api-reference/samples/halcon/halcon-debug.html)
- [HALCON Sample
Videos](https://support.zivid.com/latest/api-reference/samples/halcon/halcon-sample-videos.html)

Expand All @@ -263,7 +266,7 @@ with Zivid cameras:

- 19.05 Progress, 20.05 Progress, 21.11 Progress

We recommend to use one of the HALCON versions we have tested.
We recommend using one of the HALCON versions we have tested.

## Support

Expand Down
2 changes: 1 addition & 1 deletion continuous-integration/linux/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ BUILD_ROOT_DIR="$ROOT_DIR/build/ci"

source /etc/os-release || exit
if [[ $VERSION_ID == "20.04" ]]; then
OS_SPECIFIC_OPTIONS="-DUSE_PCL=ON -DUSE_EIGEN3=ON -DUSE_OPENCV=ON -DUSE_ARUCO=ON"
OS_SPECIFIC_OPTIONS="-DUSE_PCL=ON -DUSE_EIGEN3=ON -DUSE_OPENCV=ON -DUSE_ARUCO=ON -DUSE_GENTL=ON"
EIGEN3_INCLUDE_DIR="/usr/include/eigen3"
else
echo "ERROR: found $VERSION_ID. Expected 20.04"
Expand Down
1 change: 1 addition & 0 deletions continuous-integration/linux/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ cmake -GNinja \
-DUSE_EIGEN3=ON \
-DUSE_OPENCV=ON \
-DUSE_ARUCO=ON \
-DUSE_GENTL=ON \
-DEIGEN3_INCLUDE_DIR="/usr/include/eigen3" \
"$SOURCE_DIR" || exit
cmake --build . || exit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ function install_www_deb {
rm -r $TMP_DIR || exit
}

install_www_deb "https://downloads.zivid.com/sdk/releases/2.13.1+18e79e79-1/u${VERSION_ID:0:2}/zivid_2.13.1+18e79e79-1_amd64.deb" || exit
install_www_deb "https://downloads.zivid.com/sdk/releases/2.14.0+e4a0c4a9-1/u${VERSION_ID:0:2}/zivid_2.14.0+e4a0c4a9-1_amd64.deb" || exit
install_www_deb "https://downloads.zivid.com/sdk/releases/2.14.0+e4a0c4a9-1/u${VERSION_ID:0:2}/zivid-genicam_2.14.0+e4a0c4a9-1_amd64.deb" || exit
866 changes: 866 additions & 0 deletions source/3rd-party/GenTL/include/GenTL.h

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ namespace
const auto points = pointCloud.copyPointsZ();

// Getting min and max values for X, Y, Z images
const auto *maxZ = std::max_element(points.data(), points.data() + pointCloud.size(), isLesserOrNan);
const auto *minZ = std::max_element(points.data(), points.data() + pointCloud.size(), isGreaterOrNaN);
const auto *maxZ = std::max_element(points.begin(), points.end(), isLesserOrNan);
const auto *minZ = std::max_element(points.begin(), points.end(), isGreaterOrNaN);

// Filling in OpenCV matrix with the cloud data
for(size_t i = 0; i < pointCloud.height(); i++)
Expand Down
15 changes: 12 additions & 3 deletions source/Applications/Advanced/GammaCorrection/GammaCorrection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,27 @@ Capture 2D image with gamma correction.
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

#include <clipp.h>

#include <iostream>

namespace
{
double readGamma(int argc, char **argv)
{
if(argc < 2)
double gamma{};
auto cli = clipp::group(clipp::value("gamma", gamma).doc("Gamma correction value"));
if(!parse(argc, argv, cli))
{
throw std::runtime_error("Gamma is not provided");
auto fmt = clipp::doc_formatting{};
std::cout << "SYNOPSIS:" << std::endl;
std::cout << clipp::usage_lines(cli, "GammaCorrection", fmt) << std::endl;
std::cout << "OPTIONS:" << std::endl;
std::cout << clipp::documentation(cli) << std::endl;
throw std::runtime_error{ "Gamma is not provided" };
}

return std::stod(argv[1]);
return gamma;
}

cv::Mat captureBGRAImage(Zivid::Camera &camera, const double gamma)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Perform Hand-Eye calibration.
#include <Zivid/Zivid.h>

#include <iostream>
#include <stdexcept>

namespace
{
Expand Down Expand Up @@ -184,6 +185,7 @@ namespace
std::cout << "Error: Unknown command" << std::endl;
break;
}
default: throw std::runtime_error{ "Unhandled command type" };
}
} while(!calibrate);
return handEyeInput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ be found under the main instructions for Zivid samples.

#include <iomanip>
#include <iostream>
#include <stdexcept>

namespace
{
Expand Down Expand Up @@ -44,6 +45,7 @@ namespace
case RotationConvention::zyxIntrinsic: return "zyxIntrinsic";
case RotationConvention::zyxExtrinsic: return "zyxExtrinsic";
case RotationConvention::nofROT: break;
default: throw std::runtime_error{ "Unhandled rotation convention " };
}

throw std::invalid_argument("Invalid RotationConvention");
Expand Down Expand Up @@ -80,6 +82,7 @@ namespace
* Eigen::AngleAxisf(rollPitchYaw[0], Eigen::Vector3f::UnitX()))
.matrix();
case RotationConvention::nofROT: break;
default: throw std::runtime_error{ "Unhandled rotation convention" };
}

throw std::invalid_argument("Invalid orientation");
Expand Down Expand Up @@ -117,6 +120,7 @@ namespace
case RotationConvention::xyzExtrinsic: return rotationMatrix.eulerAngles(2, 1, 0).reverse();
case RotationConvention::zyxIntrinsic: return rotationMatrix.eulerAngles(2, 1, 0);
case RotationConvention::nofROT: break;
default: throw std::runtime_error{ "Unhandled rotation convention" };
}

throw std::invalid_argument("Invalid rotation");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The YAML files for this sample can be found under the main instructions for Zivi

#include <cmath>
#include <iostream>
#include <stdexcept>

namespace
{
Expand Down Expand Up @@ -187,6 +188,7 @@ int main()
std::cout << "Entered unknown Hand-Eye calibration type" << std::endl;
break;
}
default: throw std::runtime_error{ "Unhandled robot camera configuration. " };
}
}

Expand Down Expand Up @@ -245,6 +247,7 @@ int main()
std::cout << "Entered unknown command" << std::endl;
break;
}
default: throw std::runtime_error{ "Unhandled command. " };
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace

viewer.addPointCloud<pcl::PointXYZRGB>(pointCloud);

viewer.setCameraPosition(0, 0, 100, 0, -1, 0);
viewer.setCameraPosition(0, 0, -100, 0, 0, 1000, 0, -1, 0);

std::cout << "Press r to centre and zoom the viewer so that the entire cloud is visible" << std::endl;
std::cout << "Press q to exit the viewer application" << std::endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ Use transformation matrices from Multi-Camera calibration to transform point clo
Note: This example uses experimental SDK features, which may be modified, moved, or deleted in the future without notice.
*/

#include <Zivid/Experimental/SettingsInfo.h>
#include <Zivid/Zivid.h>

#include <pcl/io/pcd_io.h>
#include <pcl/io/ply_io.h>
#include <pcl/visualization/cloud_viewer.h>

#include <clipp.h>

#include <Zivid/Experimental/SettingsInfo.h>
#include <Zivid/Zivid.h>
#include <cmath>
#include <iostream>
#include <vector>
Expand Down Expand Up @@ -175,7 +176,7 @@ int main(int argc, char **argv)
const auto xyz = pointCloud.copyPointsXYZ();
for(size_t j = 0; j < pointCloud.size(); j++)
{
if(!isnan(xyz(j).x))
if(!std::isnan(xyz(j).x))
{
stitchedPointCloud.points[validPoints].x =
xyz(j).x; // NOLINT(cppcoreguidelines-pro-type-union-access)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
Use transformation matrices from Multi-Camera calibration to transform point clouds into single coordinate frame, from a ZDF files.
*/

#include <Zivid/Zivid.h>

#include <clipp.h>

#include <pcl/io/pcd_io.h>
#include <pcl/io/ply_io.h>
#include <pcl/visualization/cloud_viewer.h>

#include <Zivid/Zivid.h>

#include <cmath>
#include <iostream>
#include <vector>
Expand Down Expand Up @@ -149,7 +149,7 @@ int main(int argc, char **argv)
const auto xyz = pointCloud.copyPointsXYZ();
for(size_t j = 0; j < pointCloud.size(); j++)
{
if(!isnan(xyz(j).x))
if(!std::isnan(xyz(j).x))
{
stitchedPointCloud.points[validPoints].x =
xyz(j).x; // NOLINT(cppcoreguidelines-pro-type-union-access)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,28 @@ namespace

case Zivid::CameraInfo::Model::ValueType::zivid2PlusM130:
case Zivid::CameraInfo::Model::ValueType::zivid2PlusM60:
case Zivid::CameraInfo::Model::ValueType::zivid2PlusL110: return 2.47;
case Zivid::CameraInfo::Model::ValueType::zivid2PlusL110:
case Zivid::CameraInfo::Model::ValueType::zivid2PlusMR130:
case Zivid::CameraInfo::Model::ValueType::zivid2PlusMR60:
case Zivid::CameraInfo::Model::ValueType::zivid2PlusLR110: return 2.47;

default: throw std::runtime_error("Unhandled enum value '" + cameraInfo.model().toString() + "'");
}
throw std::invalid_argument("Invalid camera model");
}

Zivid::Settings2D::Sampling::Color getColorSettingsForCamera(const Zivid::Camera &camera)
{
auto model = camera.info().model();
if(model.value() == Zivid::CameraInfo::Model::ValueType::zivid2PlusMR130
|| model.value() == Zivid::CameraInfo::Model::ValueType::zivid2PlusLR110
|| model.value() == Zivid::CameraInfo::Model::ValueType::zivid2PlusMR60)
{
return Zivid::Settings2D::Sampling::Color::grayscale;
}
return Zivid::Settings2D::Sampling::Color::rgb;
}

cv::Point findMarker(
const Zivid::Frame2D &projectedMarkerFrame2D,
const Zivid::Frame2D &illuminatedSceneFrame2D,
Expand Down Expand Up @@ -179,13 +196,18 @@ namespace
Zivid::Settings::Processing::Filters::Smoothing::Gaussian::Sigma{ 1.5 } };
settings.set(processing);
settings.set(Zivid::Settings::Sampling::Pixel::all);
settings.color().value().set(Zivid::Settings2D::Sampling::Pixel::all);

// We must limit Brightness to a *maximum* of 2.2, when using `all` mode.
// This code can be removed by changing the Config.yml option 'Camera/Power/Limit'.
for(auto &a : settings.acquisitions())
{
a.set(Zivid::Settings::Acquisition::Brightness(std::min(a.brightness().value(), 2.2)));
}
for(auto &a : settings.color().value().acquisitions())
{
a.set(Zivid::Settings2D::Acquisition::Brightness(std::min(a.brightness().value(), 2.2)));
}

return camera.capture(settings);
}
Expand Down Expand Up @@ -234,15 +256,17 @@ int main()

const auto settings2DZeroBrightness =
Zivid::Settings2D{ Zivid::Settings2D::Acquisitions{ Zivid::Settings2D::Acquisition{
Zivid::Settings2D::Acquisition::Brightness{ 0.0 },
Zivid::Settings2D::Acquisition::ExposureTime{ std::chrono::microseconds{ 40000 } },
Zivid::Settings2D::Acquisition::Aperture{ 2.83 } } } };
Zivid::Settings2D::Acquisition::Brightness{ 0.0 },
Zivid::Settings2D::Acquisition::ExposureTime{ std::chrono::microseconds{ 20000 } },
Zivid::Settings2D::Acquisition::Aperture{ 2.38 } } },
Zivid::Settings2D::Sampling::Color{ getColorSettingsForCamera(camera) } };

const auto settings2DMaxBrightness =
Zivid::Settings2D{ Zivid::Settings2D::Acquisitions{ Zivid::Settings2D::Acquisition{
Zivid::Settings2D::Acquisition::Brightness{ 1.8 },
Zivid::Settings2D::Acquisition::ExposureTime{ std::chrono::microseconds{ 40000 } },
Zivid::Settings2D::Acquisition::Aperture{ 2.83 } } } };
Zivid::Settings2D::Acquisition::Brightness{ 1.8 },
Zivid::Settings2D::Acquisition::ExposureTime{ std::chrono::microseconds{ 20000 } },
Zivid::Settings2D::Acquisition::Aperture{ 2.38 } } },
Zivid::Settings2D::Sampling::Color{ getColorSettingsForCamera(camera) } };

std::cout << "Capture a 2D frame with the marker" << std::endl;
const auto projectedMarkerFrame2D = projectedImageHandle.capture(settings2DZeroBrightness);
Expand Down
43 changes: 39 additions & 4 deletions source/Applications/Advanced/ReprojectPoints/ReprojectPoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,44 @@ namespace
}
}

Zivid::Settings2D get2DCaptureSettings(const Zivid::Camera &camera)
{
Zivid::Settings2D settings2D{ Zivid::Settings2D::Acquisitions{ Zivid::Settings2D::Acquisition{
Zivid::Settings2D::Acquisition::Brightness{ 0.0 },
Zivid::Settings2D::Acquisition::ExposureTime{ std::chrono::microseconds{ 20000 } },
Zivid::Settings2D::Acquisition::Aperture{ 2.83 } } } };

auto model = camera.info().model();
switch(model.value())
{
case Zivid::CameraInfo::Model::ValueType::zividTwo:
case Zivid::CameraInfo::Model::ValueType::zividTwoL100:
case Zivid::CameraInfo::Model::ValueType::zivid2PlusM130:
case Zivid::CameraInfo::Model::ValueType::zivid2PlusM60:
case Zivid::CameraInfo::Model::ValueType::zivid2PlusL110:
{
settings2D.set(Zivid::Settings2D::Sampling::Color::rgb);
break;
}
case Zivid::CameraInfo::Model::ValueType::zivid2PlusMR130:
case Zivid::CameraInfo::Model::ValueType::zivid2PlusMR60:
case Zivid::CameraInfo::Model::ValueType::zivid2PlusLR110:
{
settings2D.set(Zivid::Settings2D::Sampling::Color::grayscale);
break;
}
case Zivid::CameraInfo::Model::ValueType::zividOnePlusSmall:
case Zivid::CameraInfo::Model::ValueType::zividOnePlusMedium:
case Zivid::CameraInfo::Model::ValueType::zividOnePlusLarge:
{
throw std::runtime_error("Unsupported camera model '" + model.toString() + "'");
}
default: throw std::runtime_error("Unhandled enum value '" + model.toString() + "'");
}

return settings2D;
}

} // namespace

int main()
Expand Down Expand Up @@ -132,10 +170,7 @@ int main()

auto projectedImageHandle = Zivid::Projection::showImage(camera, projectorImage);

const Zivid::Settings2D settings2D{ Zivid::Settings2D::Acquisitions{ Zivid::Settings2D::Acquisition{
Zivid::Settings2D::Acquisition::Brightness{ 0.0 },
Zivid::Settings2D::Acquisition::ExposureTime{ std::chrono::microseconds{ 20000 } },
Zivid::Settings2D::Acquisition::Aperture{ 2.83 } } } };
const auto settings2D = get2DCaptureSettings(camera);

std::cout << "Capturing a 2D image with the projected image" << std::endl;
const auto frame2D = projectedImageHandle.capture(settings2D);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace
viewer.addPointCloudNormals<pcl::PointXYZRGBNormal>(
pointCloudWithNormals, normalsSkipped, 1, "normals", viewNormals);

viewer.setCameraPosition(0, 0, -100, 0, -1, 0);
viewer.setCameraPosition(0, 0, -100, 0, 0, 1000, 0, -1, 0);

std::cout << "Press r to centre and zoom the viewer so that the entire cloud is visible" << std::endl;
std::cout << "Press q to exit the viewer application" << std::endl;
Expand Down
Loading
Loading