Skip to content

Convert WeChatQRCode test model fixtures from Caffe to ONNX - #2078

Merged
shimat merged 3 commits into
mainfrom
wechat-qrcode-onnx-models-2075
Jul 20, 2026
Merged

Convert WeChatQRCode test model fixtures from Caffe to ONNX#2078
shimat merged 3 commits into
mainfrom
wechat-qrcode-onnx-models-2075

Conversation

@shimat

@shimat shimat commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • OpenCV 5.x's wechat_qrcode module (and OpenCvSharp's WeChatQRCode wrapper) only accepts single-file ONNX models now - the Caffe importer has been removed entirely (readNetFromONNX/readNet on a .caffemodel now fail with "Caffe importer has been removed"). The Caffe-format fixtures checked into this repo (detect.prototxt/.caffemodel, sr.prototxt/.caffemodel) were stale leftovers from the 4.x era, so every model-dependent case in WeChatQRCodeTest.cs was silently skipped via SkipIfModelFilesNotFound(), both locally and in CI.
  • Replaced them with detect.onnx/sr.onnx, converted from the same published weights (opencv/opencv_3rdparty:wechat_qrcode_20210119, Apache License 2.0 - see the added NOTICE.md). No architecture or weight changes, just a format conversion.
  • Related to Where can I download the onnx model required for WeChatQRCode? #2075, where a user asked where to get these ONNX models. As it turns out, opencv_extra's 5.x branch (not its default branch, which is why we missed it at first) does list an ONNX conversion of the same models via download_models.py, sourced from an unlicensed personal GitHub releases repo (omrope79/opencv-test-models). We verified it against our own conversion (equivalent detection output) but converted independently anyway, since our version carries clear attribution back to the original Apache-2.0 source and doesn't depend on an unlicensed third-party mirror.

Testing

  • dotnet test --filter "FullyQualifiedName~WeChatQRCode": all 10 tests pass, 0 skipped (previously 7 of them were skipped for lack of model files).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Added licensing and attribution information for the QR code recognition model assets.
  • Chores

    • Updated QR code recognition test resources to use ONNX model artifacts.
    • Removed obsolete Caffe model definition files.
    • Retained the existing recognition behavior while simplifying the packaged test assets.

OpenCV 5.x's wechat_qrcode module (and WeChatQRCode's OpenCvSharp wrapper)
only accepts single-file ONNX models now; the Caffe importer has been
removed entirely. The Caffe-format fixtures checked into this repo
(detect.prototxt/.caffemodel, sr.prototxt/.caffemodel) were therefore stale
and every model-dependent WeChatQRCodeTest case was silently skipped.

Replace them with detect.onnx/sr.onnx, converted from the same published
weights (opencv/opencv_3rdparty:wechat_qrcode_20210119, Apache License 2.0;
see NOTICE.md). All 7 model-dependent tests in WeChatQRCodeTest.cs now run
and pass instead of being skipped.

Refs #2075
@shimat shimat self-assigned this Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 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: d93a54e4-46de-47be-bc13-aa32c4cdfb13

📥 Commits

Reviewing files that changed from the base of the PR and between e1baa1d and 665a043.

📒 Files selected for processing (1)
  • test/OpenCvSharp.Tests/_data/wechat_qrcode/NOTICE.md

📝 Walkthrough

Walkthrough

The WeChat QR code test assets replace the Caffe detection and super-resolution prototxt files with an ONNX super-resolution model and add NOTICE documentation covering model provenance, licensing, and conversion details.

Changes

WeChat QR model assets

Layer / File(s) Summary
ONNX model and asset documentation
test/OpenCvSharp.Tests/_data/wechat_qrcode/sr.onnx, test/OpenCvSharp.Tests/_data/wechat_qrcode/NOTICE.md
Adds the serialized super-resolution ONNX graph with embedded parameters and documents its source, Apache 2.0 licensing, and Caffe-to-ONNX conversion. The detect.prototxt and sr.prototxt Caffe definitions are removed.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: migrating WeChatQRCode test fixtures from Caffe to ONNX.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wechat-qrcode-onnx-models-2075

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: 1

🤖 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 `@test/OpenCvSharp.Tests/_data/wechat_qrcode/NOTICE.md`:
- Around line 1-12: Update the prose paragraphs in NOTICE.md to use one source
line per paragraph, removing mid-sentence hard wraps while preserving the
existing wording, links, code spans, and paragraph separation.
🪄 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: 50cbfc6a-0b36-43b5-8509-08fbe12bdd6e

📥 Commits

Reviewing files that changed from the base of the PR and between 4847ff4 and a3c46e8.

📒 Files selected for processing (5)
  • test/OpenCvSharp.Tests/_data/wechat_qrcode/NOTICE.md
  • test/OpenCvSharp.Tests/_data/wechat_qrcode/detect.onnx
  • test/OpenCvSharp.Tests/_data/wechat_qrcode/detect.prototxt
  • test/OpenCvSharp.Tests/_data/wechat_qrcode/sr.onnx
  • test/OpenCvSharp.Tests/_data/wechat_qrcode/sr.prototxt
💤 Files with no reviewable changes (2)
  • test/OpenCvSharp.Tests/_data/wechat_qrcode/detect.prototxt
  • test/OpenCvSharp.Tests/_data/wechat_qrcode/sr.prototxt

Comment thread test/OpenCvSharp.Tests/_data/wechat_qrcode/NOTICE.md Outdated
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
The conversion tooling moved to its own repository (shimat/caffe-ssd-to-onnx)
rather than living under tools/ here, since it's reusable for other
Caffe-SSD models, not specific to OpenCvSharp.
@shimat
shimat merged commit 4aa709f into main Jul 20, 2026
15 checks passed
@shimat
shimat deleted the wechat-qrcode-onnx-models-2075 branch July 20, 2026 16:38
@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.

1 participant