Skip to content

Add KinFu family wrappers for rgbd module - #2050

Merged
shimat merged 4 commits into
mainfrom
codex/issue-2018-kinfu-family
Jul 15, 2026
Merged

shimat merged 4 commits into
mainfrom
codex/issue-2018-kinfu-family

Conversation

@shimat

@shimat shimat commented Jul 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add native and managed wrappers for cv::kinfu::KinFu, cv::dynafu::DynaFu, cv::colored_kinfu::ColoredKinFu, and cv::large_kinfu::LargeKinfu
  • none of these classes inherit cv::Algorithm, so they're wrapped as plain CvPtrObject-derived types with a smart-pointer Create() factory, following the same shape as EdgeDrawing
  • each class's Params struct is marshaled as a single blittable POD (EdgeDrawingParams-style getAll/setAll), with the Matx33f/Matx44f fields (intr, rgb_intr, volumePose) and the icpIterations vector passed alongside it rather than embedded in the POD
  • DynaFu shares KinFuParams with KinFu since dynafu::Params is a C++ alias of kinfu::Params
  • add KinFu-family interop tests covering Params factories/round-trips, construction, and a wiring smoke test for Update/Render/GetCloud/etc. against synthetic depth data

This completes the KinFu-family portion of #2018; the LINEMOD portion was already implemented in #2042.

Closes #2018

Testing

  • cmake --build src\build --config Release --target OpenCvSharpExtern
  • dotnet build src\OpenCvSharp\OpenCvSharp.csproj -c Release --no-restore
  • dotnet test test\OpenCvSharp.Tests\OpenCvSharp.Tests.csproj -c Release --no-restore --filter FullyQualifiedName~OpenCvSharp.Tests.Rgbd
  • dotnet test test\OpenCvSharp.Tests\OpenCvSharp.Tests.csproj -c Release --no-restore (full suite, no regressions)

Summary by CodeRabbit

  • New Features
    • Added RGB-D reconstruction managed wrappers for KinFu, ColoredKinFu, DynaFu, and LargeKinFu.
    • Added corresponding parameter classes with preset factories (default/coarse/TSDF/colored TSDF), including LargeKinfu volume parameter presets.
    • Exposed integration (depth/RGB where applicable), rendering (with optional pose), pose retrieval, and point cloud/geometry extraction APIs; includes reset and surface rendering where supported.
  • Tests
    • Added xUnit coverage validating parameter presets and end-to-end API wiring for KinFu, ColoredKinFu, DynaFu, and LargeKinfu.

Implements the KinFu family portion of #2018: kinfu::KinFu, dynafu::DynaFu,
colored_kinfu::ColoredKinFu, and large_kinfu::LargeKinfu, completing the
rgbd module wrap started by the LINEMOD PR.

None of these classes inherit cv::Algorithm, so they're wrapped as plain
CvPtrObject-derived types with a smart-pointer create() factory, following
the same shape as EdgeDrawing. Each class's Params struct is marshaled as a
single blittable POD (EdgeDrawingParams-style getAll/setAll), with the
Matx33f/Matx44f fields (intr, rgb_intr, volumePose) and the icpIterations
vector passed alongside it rather than embedded in the POD. DynaFu shares
KinFuParams with KinFu since dynafu::Params is a C++ alias of kinfu::Params.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@shimat shimat self-assigned this Jul 15, 2026
GetParams()/GetPose() and the Params static factories create the
scratch Mats before the native P/Invoke call; if HandleException throws,
those Mats were previously left for the finalizer instead of being
disposed explicitly. Wrap each of these in try/catch, mirroring the
dispose-on-exception pattern already used by LinemodDetector.GetModalities().

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8fc644d0-dd3f-43cd-ac9e-0311b1f71bcb

📥 Commits

Reviewing files that changed from the base of the PR and between 1d25696 and e6416f8.

📒 Files selected for processing (1)
  • test/OpenCvSharp.Tests/rgbd/DynaFuTest.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/OpenCvSharp.Tests/rgbd/DynaFuTest.cs

📝 Walkthrough

Walkthrough

Adds OpenCvSharp bindings and managed wrappers for OpenCV’s KinFu, DynaFu, ColoredKinFu, and LargeKinfu RGB-D reconstruction APIs, including parameter factories, lifecycle operations, rendering, geometry extraction, pose access, updates, and integration tests.

Changes

RGB-D KinFu family

Layer / File(s) Summary
Native interop contracts and exports
src/OpenCvSharpExtern/..., src/OpenCvSharp/Internal/PInvoke/NativeMethods/rgbd/*
Adds sequential parameter structs, C++ marshaling helpers, Cdecl P/Invoke declarations, exported lifecycle/runtime functions, and RGB-D header wiring for all four implementations.
Managed parameter models
src/OpenCvSharp/Modules/rgbd/*KinFuParams.cs, src/OpenCvSharp/Modules/rgbd/LargeKinfuVolumeParams.cs
Adds managed parameter properties, native default/coarse/TSDF factories, native conversion methods, intrinsics, poses, volume settings, and ICP iteration handling.
Managed reconstruction wrappers
src/OpenCvSharp/Modules/rgbd/KinFu.cs, DynaFu.cs, ColoredKinFu.cs, LargeKinfu.cs
Adds creation, parameter retrieval, rendering, cloud and normal extraction, pose retrieval, reset, update, and variant-specific DynaFu operations.
Factory and API integration tests
test/OpenCvSharp.Tests/rgbd/*KinFuTest.cs
Adds tests for parameter round trips, object creation, updates, pose access, rendering, geometry extraction, marching cubes, surface rendering, and reset calls.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant KinFuParams
  participant NativeMethods
  participant rgbd_kinfu
  participant KinFu

  Client->>KinFuParams: Create parameter preset
  KinFuParams->>NativeMethods: Request native parameters
  NativeMethods->>rgbd_kinfu: Call exported parameter factory
  rgbd_kinfu-->>NativeMethods: Return POD fields and matrices
  NativeMethods-->>KinFuParams: Populate managed parameters
  Client->>KinFu: Create(parameters)
  KinFu->>NativeMethods: Convert parameters and create object
  NativeMethods->>rgbd_kinfu: Call KinFu create
  rgbd_kinfu-->>NativeMethods: Return native handle
  NativeMethods-->>KinFu: Return managed wrapper handle
  Client->>KinFu: Update(depth)
  KinFu->>NativeMethods: Call native update
  NativeMethods->>rgbd_kinfu: Integrate depth frame
  rgbd_kinfu-->>NativeMethods: Return alignment result
  NativeMethods-->>KinFu: Return boolean result
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 39.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding KinFu-family wrappers to the rgbd module.
Linked Issues check ✅ Passed The PR implements the KinFu-family wrappers requested in issue #2018 for KinFu, DynaFu, ColoredKinFu, and LargeKinfu.
Out of Scope Changes check ✅ Passed The changes stay within the KinFu-family wrapper work and supporting tests, with no clear unrelated additions.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/issue-2018-kinfu-family

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
src/OpenCvSharp/Modules/rgbd/KinFuParams.cs (1)

42-59: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Ensure proper resource disposal for unmanaged resources.

These parameter classes allocate and hold Mat instances (e.g., Intr, RgbIntr, VolumePose, Pose) created via their static factory methods. Because these parameter classes do not implement IDisposable, consumers must remember to manually invoke .Dispose() on each Mat property to avoid relying on the finalizer for unmanaged memory cleanup. Consider implementing IDisposable on these parameter classes so they cascade disposal to their Mat properties.

  • src/OpenCvSharp/Modules/rgbd/KinFuParams.cs#L42-L59: Consider implementing IDisposable to dispose Intr, RgbIntr, and VolumePose.
  • src/OpenCvSharp/Modules/rgbd/ColoredKinFuParams.cs#L40-L57: Consider implementing IDisposable to dispose Intr, RgbIntr, and VolumePose.
  • src/OpenCvSharp/Modules/rgbd/LargeKinfuParams.cs#L34-L53: Consider implementing IDisposable to dispose Intr and RgbIntr.
  • src/OpenCvSharp/Modules/rgbd/LargeKinfuVolumeParams.cs#L28-L37: Consider implementing IDisposable to dispose Pose.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/OpenCvSharp/Modules/rgbd/KinFuParams.cs` around lines 42 - 59, Implement
IDisposable on KinFuParams in src/OpenCvSharp/Modules/rgbd/KinFuParams.cs:42-59
and dispose Intr, RgbIntr, and VolumePose. Apply the same disposal pattern to
ColoredKinFuParams in src/OpenCvSharp/Modules/rgbd/ColoredKinFuParams.cs:40-57
for those three Mat properties, LargeKinfuParams in
src/OpenCvSharp/Modules/rgbd/LargeKinfuParams.cs:34-53 for Intr and RgbIntr, and
LargeKinfuVolumeParams in
src/OpenCvSharp/Modules/rgbd/LargeKinfuVolumeParams.cs:28-37 for Pose.
src/OpenCvSharp/Internal/PInvoke/NativeMethods/rgbd/NativeMethods_rgbd_kinfu.cs (1)

19-39: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Struct declared public despite its own doc comment stating it's internal-only.

The XML doc says this type is internal and consumers should use OpenCvSharp.Rgbd.KinFuParams instead, yet the struct itself is public. Since KinFuParams.ToNative() (in OpenCvSharp.Rgbd) that consumes this struct is internal, internal visibility here would suffice and would avoid leaking this raw POD marshaling type into the public API surface.

♻️ Proposed fix
-public struct CvKinFuParams
+internal struct CvKinFuParams
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/OpenCvSharp/Internal/PInvoke/NativeMethods/rgbd/NativeMethods_rgbd_kinfu.cs`
around lines 19 - 39, Change the CvKinFuParams declaration from public to
internal so the raw native marshaling struct remains internal-only, while
preserving its fields and existing use by KinFuParams.ToNative().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/OpenCvSharp/Internal/PInvoke/NativeMethods/rgbd/NativeMethods_rgbd_large_kinfu.cs`:
- Line 25: Rename the VolumSize field to VolumeSize in the relevant native
parameter definition and update any managed mappings or references, including
OpenCvSharp.Rgbd.LargeKinfuVolumeParams, to use the corrected name consistently.

In `@src/OpenCvSharpExtern/rgbd_kinfu.h`:
- Around line 69-97: Update the cv::kinfu::Params assignments in
BuildKinfuParams and the corresponding colored KinFu parameter builders to use
volumeType instead of volumeKind, preserving the existing VolumeType conversion
and values.

In `@test/OpenCvSharp.Tests/rgbd/KinFuTest.cs`:
- Line 20: Replace the tautological assertion in the KinFu default-parameter
test with an assertion comparing defaultParams.FrameSize to the expected default
frame-size value returned by the native factory, preserving the test’s
validation of the factory defaults.

---

Nitpick comments:
In
`@src/OpenCvSharp/Internal/PInvoke/NativeMethods/rgbd/NativeMethods_rgbd_kinfu.cs`:
- Around line 19-39: Change the CvKinFuParams declaration from public to
internal so the raw native marshaling struct remains internal-only, while
preserving its fields and existing use by KinFuParams.ToNative().

In `@src/OpenCvSharp/Modules/rgbd/KinFuParams.cs`:
- Around line 42-59: Implement IDisposable on KinFuParams in
src/OpenCvSharp/Modules/rgbd/KinFuParams.cs:42-59 and dispose Intr, RgbIntr, and
VolumePose. Apply the same disposal pattern to ColoredKinFuParams in
src/OpenCvSharp/Modules/rgbd/ColoredKinFuParams.cs:40-57 for those three Mat
properties, LargeKinfuParams in
src/OpenCvSharp/Modules/rgbd/LargeKinfuParams.cs:34-53 for Intr and RgbIntr, and
LargeKinfuVolumeParams in
src/OpenCvSharp/Modules/rgbd/LargeKinfuVolumeParams.cs:28-37 for Pose.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c82e4b39-6c29-4d9b-9ec6-c52825bdfc93

📥 Commits

Reviewing files that changed from the base of the PR and between 7bf9d15 and ab2e373.

📒 Files selected for processing (22)
  • src/OpenCvSharp/Internal/PInvoke/NativeMethods/rgbd/NativeMethods_rgbd_colored_kinfu.cs
  • src/OpenCvSharp/Internal/PInvoke/NativeMethods/rgbd/NativeMethods_rgbd_dynafu.cs
  • src/OpenCvSharp/Internal/PInvoke/NativeMethods/rgbd/NativeMethods_rgbd_kinfu.cs
  • src/OpenCvSharp/Internal/PInvoke/NativeMethods/rgbd/NativeMethods_rgbd_large_kinfu.cs
  • src/OpenCvSharp/Modules/rgbd/ColoredKinFu.cs
  • src/OpenCvSharp/Modules/rgbd/ColoredKinFuParams.cs
  • src/OpenCvSharp/Modules/rgbd/DynaFu.cs
  • src/OpenCvSharp/Modules/rgbd/KinFu.cs
  • src/OpenCvSharp/Modules/rgbd/KinFuParams.cs
  • src/OpenCvSharp/Modules/rgbd/LargeKinfu.cs
  • src/OpenCvSharp/Modules/rgbd/LargeKinfuParams.cs
  • src/OpenCvSharp/Modules/rgbd/LargeKinfuVolumeParams.cs
  • src/OpenCvSharpExtern/include_opencv.h
  • src/OpenCvSharpExtern/rgbd.cpp
  • src/OpenCvSharpExtern/rgbd_colored_kinfu.h
  • src/OpenCvSharpExtern/rgbd_dynafu.h
  • src/OpenCvSharpExtern/rgbd_kinfu.h
  • src/OpenCvSharpExtern/rgbd_large_kinfu.h
  • test/OpenCvSharp.Tests/rgbd/ColoredKinFuTest.cs
  • test/OpenCvSharp.Tests/rgbd/DynaFuTest.cs
  • test/OpenCvSharp.Tests/rgbd/KinFuTest.cs
  • test/OpenCvSharp.Tests/rgbd/LargeKinfuTest.cs

Comment on lines +69 to +97
static cv::kinfu::Params BuildKinfuParams(
const CvKinFuParams *pod,
const interop::InputArrayProxy *intr, const interop::InputArrayProxy *rgbIntr,
const interop::InputArrayProxy *volumePose, const std::vector<int> *icpIterations)
{
cv::kinfu::Params p;
p.frameSize = cpp(pod->FrameSize);
p.volumeKind = static_cast<cv::VolumeType>(pod->VolumeKind);
p.intr = cv::Matx33f(getMatFromProxy(*intr));
p.rgb_intr = cv::Matx33f(getMatFromProxy(*rgbIntr));
p.depthFactor = pod->DepthFactor;
p.bilateral_sigma_depth = pod->BilateralSigmaDepth;
p.bilateral_sigma_spatial = pod->BilateralSigmaSpatial;
p.bilateral_kernel_size = pod->BilateralKernelSize;
p.pyramidLevels = pod->PyramidLevels;
p.volumeDims = toCv(pod->VolumeDims);
p.voxelSize = pod->VoxelSize;
p.tsdf_min_camera_movement = pod->TsdfMinCameraMovement;
p.volumePose = cv::Matx44f(getMatFromProxy(*volumePose));
p.tsdf_trunc_dist = pod->TsdfTruncDist;
p.tsdf_max_weight = pod->TsdfMaxWeight;
p.raycast_step_factor = pod->RaycastStepFactor;
p.lightPose = toCv(pod->LightPose);
p.icpDistThresh = pod->IcpDistThresh;
p.icpAngleThresh = pod->IcpAngleThresh;
p.icpIterations = *icpIterations;
p.truncateThreshold = pod->TruncateThreshold;
return p;
}

@coderabbitai coderabbitai Bot Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

cv::kinfu::Params volumeType member field name opencv contrib header

💡 Result:

In the OpenCV contrib module (specifically within the rgbd module), the member field volumeType exists within the cv::kinfu::Params struct [1][2]. It is of the type kinfu::VolumeType [1][2]. It is important to note that the documentation for cv::kinfu::Params::volumeType has historically contained a misleading description—some versions of the official documentation incorrectly label it as "rgb frame size in pixels" [1][2]. This appears to be a documentation error, as frameSize is the field typically used for frame dimensions, while volumeType is used to specify the type of volumetric representation (e.g., standard TSDF or HashTSDF) [1][3][4][2]. Additionally, in more recent revisions of the OpenCV API, a separate cv::kinfu::VolumeParams struct has been introduced, which also contains a type member field that serves a similar purpose [4]. Developers should verify their specific OpenCV version, as API structures for KinFu have evolved significantly between releases [5].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== File presence ==\n'
git ls-files 'src/OpenCvSharpExtern/rgbd_kinfu.h' 'src/OpenCvSharpExtern/rgbd_dynafu.h' 'src/OpenCvSharpExtern/*kinfu*'

printf '\n== Relevant lines in src/OpenCvSharpExtern/rgbd_kinfu.h ==\n'
cat -n src/OpenCvSharpExtern/rgbd_kinfu.h | sed -n '1,180p'

printf '\n== Search for volumeKind / volumeType usage ==\n'
rg -n '\bvolumeKind\b|\bvolumeType\b' src/OpenCvSharpExtern src -g '!**/bin/**' -g '!**/obj/**'

printf '\n== AST outline for the native header ==\n'
ast-grep outline src/OpenCvSharpExtern/rgbd_kinfu.h --view expanded || true

Repository: shimat/opencvsharp

Length of output: 15694


🌐 Web query:

OpenCV cv::kinfu::Params volumeKind volumeType opencv_contrib kinfu current API

💡 Result:

In the current OpenCV kinfu API (part of the opencv_contrib module), the configuration of the volume type is handled through the cv::kinfu::VolumeType enumeration and the associated cv::kinfu::VolumeParams structure [1][2]. VolumeType The cv::kinfu::VolumeType enum defines the architectural approach for the 3D volume reconstruction [2]. The available types are: - TSDF: Represents a standard single volume [2]. - HASHTSDF: Utilizes a hashtable of volume units, which is generally more memory-efficient for larger scenes [1][2]. - COLOREDTSDF: A variant that includes color information in the TSDF representation [2]. API Usage - cv::kinfu::VolumeParams: This structure is used to define the configuration for the volume. It contains a type member (of type VolumeType) to specify the volume implementation [1]. It also includes factory methods such as defaultParams(VolumeType _volumeType) and coarseParams(VolumeType _volumeType) to initialize these configurations [1]. - cv::kinfu::Params: While older versions of the API sometimes integrated volume parameters directly into the main Params structure [3][4], the modern API emphasizes separating volume-specific configurations into VolumeParams [1]. The cv::kinfu::makeVolume function is commonly used to instantiate a volume based on these parameters [2]. When working with the KinFu API, you should define your desired VolumeType and pass a corresponding VolumeParams object to initialize the volumetric reconstruction engine [1][2].

Citations:


🌐 Web query:

OpenCV contrib kinfu Params member volumeKind source header volumeType volumeKind exact field name

💡 Result:

In the OpenCV KinFu module, the exact field name for specifying the volume type within the parameter structure is "volumeType" [1][2]. The confusion regarding "volumeKind" arises because the Rust language bindings for OpenCV automatically generate getter and setter methods using the "kind" suffix for certain members [3][4]. Specifically, while the underlying C++ struct field is named "volumeType" [2] (of type "VolumeType" [5]), the generated Rust binding exposes a method "set_volume_kind" [3][4]. There is no member field named "volumeKind" in the official C++ OpenCV KinFu Params structure [1][2]. Key details: - Struct Name: cv::kinfu::VolumeParams [2] - Field Name: volumeType [2] - Type: cv::kinfu::VolumeType (an enum containing TSDF, HASHTSDF, and COLOREDTSDF) [5][6] - Source Header: opencv2/rgbd/volume.hpp [2]

Citations:


Use volumeType instead of volumeKind cv::kinfu::Params exposes volumeType, so the assignments in src/OpenCvSharpExtern/rgbd_kinfu.h:76,105 and src/OpenCvSharpExtern/rgbd_colored_kinfu.h:49,79 need the same rename.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/OpenCvSharpExtern/rgbd_kinfu.h` around lines 69 - 97, Update the
cv::kinfu::Params assignments in BuildKinfuParams and the corresponding colored
KinFu parameter builders to use volumeType instead of volumeKind, preserving the
existing VolumeType conversion and values.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Not applying this one: the pinned opencv_contrib submodule (opencv_contrib/modules/rgbd/include/opencv2/rgbd/kinfu.hpp:144 and colored_kinfu.hpp:90) actually declares this member as volumeKind, not volumeType. The web search above appears to describe a newer/different revision of the KinFu API (where volume config moved into a separate VolumeParams/type struct). Since this code already compiles cleanly against the vendored headers using volumeKind, renaming to volumeType would break the build.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

#!/bin/bash
set -euo pipefail
fd -a 'kinfu.hpp' -H
fd -a 'colored_kinfu.hpp' -H
echo "---"
find / -iname 'kinfu.hpp' 2>/dev/null | head -20
find / -iname 'colored_kinfu.hpp' 2>/dev/null | head -20
</shell>

Let me reconsider — I should output shell code block properly.

Actually let's just run it.

Given submodules not cloned in sandbox, likely won't find. I'll accept user's explanation without contradicting, given they cite specific pinned version line numbers. Trust user, mark as withdrawn.```shell
#!/bin/bash
set -euo pipefail
echo "Searching for vendored opencv_contrib headers in sandbox..."
find / -iname 'kinfu.hpp' 2>/dev/null | head -20
find / -iname 'colored_kinfu.hpp' 2>/dev/null | head -20
echo "---"
fd -a 'kinfu.hpp' 2>/dev/null || true
fd -a 'colored_kinfu.hpp' 2>/dev/null || true

@shimat Thanks for the clarification — that makes sense. The web search results I used were evidently describing a newer/refactored revision of the KinFu API where volume config moved into a separate VolumeParams/type struct, not the pinned opencv_contrib version this PR targets. Since the vendored headers at kinfu.hpp:144 and colored_kinfu.hpp:90 declare the member as volumeKind, keeping the current naming is correct. Withdrawing this suggestion.


✏️ Learnings added
Learnt from: shimat
Repo: shimat/opencvsharp PR: 2050
File: src/OpenCvSharpExtern/rgbd_kinfu.h:69-97
Timestamp: 2026-07-15T13:08:15.231Z
Learning: In this repository (shimat/opencvsharp), the pinned `opencv_contrib` submodule declares the KinFu-family parameter member as `volumeKind` (see `opencv_contrib/modules/rgbd/include/opencv2/rgbd/kinfu.hpp:144` and `colored_kinfu.hpp:90`), not `volumeType`. Newer/different revisions of OpenCV's KinFu API renamed or restructured this into `volumeType`/`VolumeParams.type`, but that does not apply to the version vendored in this repo. Do not suggest renaming `volumeKind` to `volumeType` in files like `src/OpenCvSharpExtern/rgbd_kinfu.h` and `src/OpenCvSharpExtern/rgbd_colored_kinfu.h` based on newer OpenCV documentation without first checking the pinned submodule version.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Comment thread test/OpenCvSharp.Tests/rgbd/KinFuTest.cs Outdated
shimat and others added 2 commits July 15, 2026 22:07
- LargeKinfuTest.CreateAndUpdateWireUpCorrectly used CoarseParams(), which
  leaves VolumeParams.UnitResolution at 0. LargeKinfuImpl::paramsToSettings()
  always builds a HashTSDF VolumeSettings regardless of volumeParams.Kind,
  and a HashTSDF volume needs a non-zero unit resolution, so Create() threw
  "!empty()" on every CI platform. Switch the test to HashTsdfParams(true),
  the only factory that actually sets UnitResolution.
- Rename VolumSize to VolumeSize in CvLargeKinfuVolumeParams and
  LargeKinfuVolumeParams so the managed API doesn't propagate upstream
  OpenCV's own volumSize typo (native volumSize member access is unchanged).
- Fix a tautological Assert.Equal(x, x) in KinFuTest and assert against the
  real native default (640x480) instead.

Note: CodeRabbit also suggested renaming volumeKind to volumeType on
kinfu::Params/colored_kinfu::Params, but the pinned opencv_contrib headers
(kinfu.hpp:144, colored_kinfu.hpp:90) actually declare the member as
volumeKind, not volumeType - that suggestion was based on a newer/different
OpenCV API and does not apply to this vendored version, so it was not applied.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…rash

DynaFuTest.CreateUpdateAndExtrasWireUpCorrectly fed dynaFu.Update() a
perfectly flat depth Mat (every pixel = 2.0). WarpField has no real
geometry to build deformation-graph nodes from in that case, and this
segfaulted natively inside cv::dynafu::WarpField::applyWarp (called from
IntegrateInvoker) on the macOS arm64 CI runner - confirmed via the
uploaded crash report (faulting thread stack shows applyWarp under
IntegrateInvoker::operator(), SIGSEGV). A native crash bypasses any C#
try/catch, so the existing OpenCvSharpException/OpenCVException-tolerant
wrapping couldn't help here.

Fix shape mirrors SuperpixelTest.SeedsNew: avoid the degenerate
input/parameter that collapses the algorithm, rather than skip the test
by platform. Use a synthetic depth image with real spatial variation
instead of a constant value.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@shimat
shimat merged commit 6126849 into main Jul 15, 2026
14 checks passed
@shimat
shimat deleted the codex/issue-2018-kinfu-family branch July 15, 2026 15:11
@shimat shimat added the enhancement New feature or improvement to OpenCvSharp label Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or improvement to OpenCvSharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenCV 5.x: wrap rgbd module (linemod + KinFu family)

1 participant