Skip to content

Samples: Add DLPack CUDA sample and CSV output for ZividBenchmark - #293

Merged
torbsorb merged 1 commit into
masterfrom
2026-07-10-update-cpp-samples
Jul 29, 2026
Merged

Samples: Add DLPack CUDA sample and CSV output for ZividBenchmark#293
torbsorb merged 1 commit into
masterfrom
2026-07-10-update-cpp-samples

Conversation

@csu-bot-zivid

@csu-bot-zivid csu-bot-zivid commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

New sample: DLPack tensors from Zivid DeviceArrays

source/Applications/Advanced/Cuda/CaptureAndConvertToDlpackTensorOnCuda
captures a combined 2D+3D frame and builds DLPack tensors directly from
the Zivid DeviceArrays on the CUDA device — both the point cloud
(PointXYZ) and the color image (ColorRGBA_SRGB).

The sample constructs a DLManagedTensor from the building blocks each
DeviceArray exposes (device pointer, shape, strides in elements,
element data type, CUDA device) and validates its fields. The DLPack
data type is derived from the Zivid format's ValueType, so one code
path handles both float point data and 8-bit color. This is the
producer side of DLPack: a consumer such as PyTorch
(torch.from_dlpack), CuPy or JAX imports the resulting tensor for
zero-copy GPU processing. The DeviceArray is kept alive by the
tensor's manager context and released only when the consumer is done
with it, so the GPU memory stays valid as long as the tensor is held.

Building it. The sample is off by default. Configure with
-DUSE_DLPACK=ON in addition to -DUSE_CUDA=ON, and point
DLPACK_INCLUDE_DIR at the directory containing dlpack/dlpack.h
(headers from https://github.com/dmlc/dlpack). CMake fails with a clear
message if the path is missing or wrong.

ZividBenchmark: CSV output

A benchmark run now also writes its results to a CSV file, so a run can
be archived, shared, or compared across machines and cameras instead of
only being read off the console.

  • Columns: timestamp, test_category, test_name, iteration,
    median_ms, mean_ms, settings, camera_model, serial_number.
  • The settings column records the apertures, exposure times and enabled
    filters used for that test, so rows stay interpretable later.
  • System information — API version, OS, camera model, serial number and
    compute device — is written to the file as well.
  • The default filename is
    zivid_benchmark_results_<date>_<time>.csv; pass
    --csv-output <filename> to choose your own.

ZividBenchmark: capture-ordering tests are now opt-in

The six capture-ordering tests — 2D then 3D, 3D then 2D, and 3D
including 2D, each with and without the projector — now run only when
you pass --extended. A default run covers connect/disconnect, 3D, 2D,
3D+2D, 2D+3D, copy-data and save, and finishes correspondingly sooner.
Pass --extended to get the previous full set.

Docs

The HALCON compatibility list now also covers Ubuntu 26.04.

@csu-bot-zivid
csu-bot-zivid force-pushed the 2026-07-10-update-cpp-samples branch 14 times, most recently from 9c15b73 to cca15c4 Compare July 20, 2026 09:28
@csu-bot-zivid
csu-bot-zivid force-pushed the 2026-07-10-update-cpp-samples branch 15 times, most recently from f9b31f4 to c5cba2a Compare July 28, 2026 12:56
@csu-bot-zivid
csu-bot-zivid force-pushed the 2026-07-10-update-cpp-samples branch from c5cba2a to 99a28f8 Compare July 28, 2026 20:30
New sample:
- CaptureAndConvertToDlpackTensorOnCuda: capture a 2D+3D frame and
  build DLPack tensors directly from the Zivid DeviceArrays on the
  CUDA device, for both the point cloud (PointXYZ) and the color
  image (ColorRGBA_SRGB). It builds a DLManagedTensor from the
  device pointer, shape, strides in elements, element data type
  and CUDA device, and validates the result. A consumer such as
  PyTorch, CuPy or JAX can then import the tensor for zero-copy
  GPU processing. The DeviceArray is kept alive for as long as the
  consumer holds the tensor.
- The sample is off by default. Build it with -DUSE_DLPACK=ON
  alongside -DUSE_CUDA=ON, and point DLPACK_INCLUDE_DIR at the
  directory containing dlpack/dlpack.h.

ZividBenchmark:
- A run now also writes its results to a CSV file, so results can
  be archived and compared across machines or cameras. Each row
  carries a timestamp, test category, test name, iteration,
  median and mean time in milliseconds, the settings used, and
  the camera model and serial number. API version, OS and compute
  device are recorded too.
- The file is named zivid_benchmark_results_<date>_<time>.csv by
  default; pass --csv-output <filename> to choose the name.
- The six capture-ordering tests (2D then 3D, 3D then 2D, and 3D
  including 2D, each with and without the projector) now run only
  when you pass --extended, so a default run is shorter.

Docs:
- The HALCON compatibility list now also covers Ubuntu 26.04.
@torbsorb
torbsorb force-pushed the 2026-07-10-update-cpp-samples branch from 99a28f8 to c3333c6 Compare July 29, 2026 06:34
@torbsorb torbsorb changed the title Samples: Automatic updates to public repository Samples: Add DLPack CUDA sample and CSV output for ZividBenchmark Jul 29, 2026

@torbsorb torbsorb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes from the internal version; except improved README.

@torbsorb
torbsorb merged commit 8bac643 into master Jul 29, 2026
2 checks passed
@torbsorb
torbsorb deleted the 2026-07-10-update-cpp-samples branch July 29, 2026 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants