示例

直接使用您喜欢的编程语言对 Zivid 相机进行编程。

备注

一些 Zivid 示例需要使用到 Sample Data(示例数据)。

示例列表

  • Camera

    • Basic

      • Capture - Capture colored point cloud, save 2D image, save 3D ZDF, and export PLY, using the Zivid camera.

      • CaptureFromFileCamera - Capture point clouds, with color, with the Zivid file camera.

      • CaptureHDRCompleteSettings - Capture point clouds, with color, from the Zivid camera with fully configured settings.

      • CaptureWithSettingsFromYML - Capture images and point clouds, with and without color, from the Zivid camera with settings from YML file.

      • Connect - Connect to a Zivid camera using the different available methods.

      • CreateFileCameraFromZDFWithDiagnostics - Capture a frame with diagnostics enabled and create a file camera from it.

    • Advanced

    • InfoUtilOther

      • CameraInfo - List connected cameras and print camera version and state information for each connected camera.

      • CameraUserData - Store user data on the Zivid camera.

      • CaptureWithDiagnostics - Capture a 2D+3D frame and a 2D frame from the Zivid camera with diagnostics enabled.

      • CheckHealth - Poll the camera health check from a separate thread while capturing, printing statuses and values each second.

      • FirmwareUpdater - Update firmware on the Zivid camera.

      • FrameInfo - Read frame info from the Zivid camera.

      • GetCameraIntrinsics - Read intrinsic parameters from the Zivid camera (OpenCV model) or estimate them from the point cloud.

      • MeasureSceneConditions - Measure ambient light in the scene and report the flickering frequency when flickering is detected.

      • Warmup - Short example of a basic way to warm up the camera with specified time and capture cycle.

      • Network

    • Maintenance

  • Applications

访问 zivid-ros Github 存储库。

安装

  1. 安装 Zivid 软件

  2. 下载 Zivid Sample Data

Windows

点击键盘上的 Win+R 键启动命令提示符,然后键入 cmd ,接着按下 Enter。

Navigate to a location where you want to clone the repository, then run the following command:

git clone https://github.com/zivid/zivid-cpp-samples

使用 CMake 配置示例解决方案,在 Visual Studio 中打开示例,生成并运行。更多相关信息,请参阅 使用 CMake 配置 C++ 示例并在 Windows 的 Visual Studio 中构建它们。

Ubuntu

点击键盘上的 Ctrl + Alt + T 键打开终端。

Navigate to a location where you want to clone the repository, then run the following command:

git clone https://github.com/zivid/zivid-cpp-samples
cd zivid-cpp-samples

生成项目:

mkdir build
cd build
cmake <options, see below> ../source
cmake --build .

部分示例依赖于外部库,特别是 Eigen 3、OpenCV、PCL 或 HALCON。如果您不想安装这些库,可以通过向 cmake 分别传递以下选项来禁用依赖于它们的示例: cmake: -DUSE_EIGEN3=OFF , -DUSE_OPENCV=OFF , -DUSE_PCL=OFF , -DUSE_HALCON=OFF 。

有关如何安装可选依赖项并配置示例以使用它们的说明,请参阅 使用可选依赖项配置 C++ 示例 。

现在可以从生成的目录运行示例,例如:

./CaptureFromFileCameraVis3D

如需获取更多相关信息,请访问 GitHub zivid-cpp-samples 存储库。

  1. 安装 Zivid 软件

  2. 下载 Zivid Sample Data

点击键盘上的 Win+R 键启动命令提示符,然后键入 cmd ,接着按下 Enter。

Navigate to a location where you want to clone the repository, then run the following command:

git clone https://github.com/zivid/zivid-csharp-samples

在 Visual Studio 中打开 ZividNETSamples.sln,生成并运行它。如果您不确定如何操作,请查看 使用 Visual Studio 构建 C# 示例。

一些示例依赖于外部库,特别是 MathNet.Numerics 和 System.ValueTuple 。在构建示例时,将通过 NuGet 自动安装这些库。

如需获取更多相关信息,请访问 GitHub zivid-csharp-samples 存储库。

备注

这些示例的推荐 Python 版本是 3.7 - 3.9 。

请注意,Open3D 不适用于 Python 3.13 及更高版本。

  1. 安装 Zivid 软件。

  2. 下载 Zivid Sample Data。

  3. 查看 Zivid Python 示例存储库:

    git clone http://github.com/zivid/zivid-python-samples.git
    
  4. 使用 IDE 或命令行安装 runtime requirements:

cd zivid-python-samples
pip install -r requirements.txt

备注

如果 Open3D 安装失败,请确保您使用的是 Open3D 支持的 Python 版本。或者,您也可以运行以下命令,仅安装非 Open3D 示例所需的依赖项:

pip install ./modules
  1. 打开并运行其中一个示例。

    备注

    在 Windows 上运行 GUI 示例应该通过 pythonw 完成。

如需获取更多相关信息,请访问 GitHub zivid-python-samples 存储库。

Zivid 提供两种与 HALCON 接口的方式:

  1. 通过 Zivid SDK,利用 HALCON 提供的 C++/C# 库。我们同时提供 C++ 和 C# 。(推荐)

  2. 直接使用 Zivid 软件 附带的 GenICam GenTL producer 。

Zivid 和 HALCON 与 Windows 10 和 11 以及 Ubuntu 20.04、22.04、24.04、26.04 兼容。

备注

自 SDK 2.10 起,移除了对 Ubuntu 18.04 的支持。

要在这些操作系统之一中设置和使用 Zivid,请按照以下页面中各自的说明进行操作:

如需获取更多相关信息,请访问 GitHub zivid-halcon-samples 存储库。

已停止支持 MATLAB。请访问旧版本(<= 2.15)以获取支持。

如需获取更多相关信息,请访问 GitHub zivid-matlab-samples 存储库。

查看 zivid-ros GitHub 存储库以获取安装说明、代码示例以及如何开始使用 Zivid ROS 2 驱动程序。如果您使用的是 ROS 1,请参阅 zivid-ros-1 分支。

等同示例

相机

Sample

C++

C#

Python

HDevelop

Basic

Capture

✓

✓

✓

✓

CaptureFromFileCamera

✓

✓

✓

CaptureHdrCompleteSettings

✓

✓

✓

✓

CaptureSavePly

✓

CaptureWithSettingsFromYml

✓

✓

✓

✓

Connect

✓

✓

✓

ConnectToSerialNumberCamera

✓

CreateFileCameraFromZdfWithDiagnostics

✓

✓

✓

Advanced

AllocateMemoryForPointCloudData

✓

Capture2DAnd3D

✓

✓

CaptureAndPrintNormals

✓

✓

✓

CaptureHalconViaGenICam

✓

✓

CaptureHalconViaZivid

✓

✓

CaptureViaGenICam

✓

Advanced/MultiCamera

MultiCameraCaptureInParallel

✓

MultiCameraCaptureSequentially

✓

MultiCameraCaptureSequentiallyWithInterleavedProcessing

✓

InfoUtilOther

adapt_settings_for_flickering_ambient_light

✓

CameraInfo

✓

✓

✓

CameraUserData

✓

✓

✓

CaptureWithDiagnostics

✓

✓

✓

CheckHealth

✓

✓

✓

context_manager_with_zivid

✓

ExploreSettingsMetaData

✓

FirmwareUpdater

✓

✓

✓

FrameInfo

✓

✓

✓

GetCameraIntrinsics

✓

✓

✓

MeasureSceneConditions

✓

✓

✓

QuerySettingsAndParameters

✓

SettingsInfo

✓

Warmup

✓

✓

✓

✓

ZividBenchmark

✓

InfoUtilOther/Network

AutomaticNetworkConfigurationForCameras

✓

✓

✓

NetworkConfiguration

✓

✓

✓

Maintenance

CorrectCameraInField

✓

✓

✓

ResetCameraInField

✓

✓

✓

VerifyCameraInField

✓

✓

✓

VerifyCameraInFieldFromZdf

✓

✓

✓

visualize_benchmark_results

✓

应用

Sample

C++

C#

Python

HDevelop

Basic/Visualization

CaptureAndVisualizeNormals

✓

✓

CaptureFromFileCameraVis3D

✓

✓

✓

CaptureVis3D

✓

✓

✓

CaptureWritePclVis3D

✓

ProjectImageStartAndStop

✓

✓

✓

ReadPclVis3D

✓

read_zdf_vis_3d

✓

Basic/FileFormats

ConvertZdf

✓

✓

ReadIterateZdf

✓

✓

✓

ReadPly

✓

Zdf2Ply

✓

Advanced

auto_2d_settings

✓

CaptureUndistort2D

✓

✓

color_balance

✓

CreateDepthMap

✓

✓

Downsample

✓

✓

✓

GammaCorrection

✓

✓

MaskPointCloud

✓

✓

✓

Advanced/Visualization

CaptureVis3DInLoop

✓

✓

✓

CaptureVis3DInLoopWithKeypressExit

✓

✓

✓

Advanced/Cuda

CaptureAndConvertImageWithOpenCvOnCuda

✓

CaptureAndConvertToDlpackTensorOnCuda

✓

✓

capture_and_process_image_with_cupy_on_cuda

✓

capture_and_render_point_cloud_with_opengl_on_cuda

✓

capture_and_segment_image_with_pytorch_on_cuda

✓

Advanced/Transform

get_checkerboard_pose_from_zdf

✓

TransformPointCloudFromMillimetersToMeters

✓

✓

✓

TransformPointCloudViaArucoMarker

✓

✓

✓

TransformPointCloudViaCheckerboard

✓

✓

✓

Advanced/Roi

RoiBoxViaArucoMarker

✓

✓

✓

RoiBoxViaCheckerboard

✓

✓

✓

Advanced/Stitching

StitchContinuouslyRotatingObject

✓

✓

✓

StitchUsingRobotMountedCamera

✓

✓

✓

StitchViaLocalPointCloudRegistration

✓

✓

✓

Advanced/Barcode

BarcodeDetector

✓

✓

Advanced/HandEyeCalibration

EyeInHandCalibration3DObject

✓

EyeInHandCalibrationMvTecPlate

✓

HandEyeCalibration

✓

✓

✓

hand_eye_gui

✓

JsonHomogeneousMatrixToHalconPose

✓

pose_conversion_gui

✓

PoseConversions

✓

✓

✓

UtilizeHandEyeCalibration

✓

✓

✓

verify_hand_eye_with_visualization

✓

Advanced/HandEyeCalibration/UrHandEyeCalibration

universal_robots_perform_hand_eye_calibration

✓

Advanced/HandEyeCalibration/RobodkHandEyeCalibration

robodk_hand_eye_calibration

✓

robodk_verify_hand_eye_calibration

✓

Advanced/MultiCamera

MultiCameraCalibration

✓

✓

✓

MultiCameraCalibrationFromZdf

✓

✓

StitchByTransformation

✓

✓

StitchByTransformationFromZdf

✓

✓

Advanced/Projector

ProjectAndFindMarker

✓

✓

ReadProjectAndCaptureImage

✓

✓

✓

ReprojectPoints

✓

✓

Advanced/RobotGuidance

robodk_robot_guidance

✓

Advanced/ObjectMatching

SurfaceMatchingCreateModel

✓

SurfaceMatchingCreateModelFromFile

✓

SurfaceMatchingFindModel

✓

SurfaceMatchingFindModelFromFile

✓

操作步骤

Sample

C++

C#

Python

HDevelop

CalcCalplatePoseEyeInHand

✓

CalcCalplatePoseEyeToHand

✓

GenerateRGBAndRgbImages

✓

GetFirstAvailableZividDevice

✓

GetSettingsForZividCameraModel

✓

GetZividCameraWidth

✓

GetZividPresetFile

✓

GetZividSampleDataDir

✓

模块

Sample

C++

C#

Python

HDevelop

Zividsamples

calibration_board_utils

✓

camera_verification

✓

color_to_grayscale

✓

display

✓

paths

✓

robodk_tools

✓

save_load_matrix

✓

save_load_transformation_matrix

✓

save_residuals

✓

settings_utils

✓

transformation_matrix

✓

white_balance_calibration

✓