Add a cv::dnn binding (Net class: readNet / setInput / forward)#102
Open
TroyHernandez wants to merge 1 commit into
Open
Add a cv::dnn binding (Net class: readNet / setInput / forward)#102TroyHernandez wants to merge 1 commit into
TroyHernandez wants to merge 1 commit into
Conversation
Exposes OpenCV's dnn module through a Net class: readNet() loads a model (ONNX, Caffe, TF, etc.), setInput() preprocesses an Image with blobFromImage, and forward() runs inference. Output tensors are converted from OpenCV's row-major layout to correctly-shaped column-major R arrays of arbitrary dimensionality. No build-list change (dnn is already compiled). Refs swarm-lab#101
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a binding for OpenCV's
dnnmodule, as discussed in #101 (PR 1 of 2:dnnfirst, YuNet face detection to follow).What
A
Netclass wrappingcv::dnn::Net:readNet(model, config = "", framework = "")loads a model (ONNX, Caffe, TF, Darknet, ...).net$setInput(image, scalefactor, size, mean, swapRB, crop, name)preprocesses anImageviablobFromImageand sets it as input.net$forward(name)runs a forward pass and returns the output tensor as a numeric array, with OpenCV's row-major layout converted to a correctly-shaped column-major R array of arbitrary dimensionality.net$getLayerNames(),net$empty(), and anisNet()helper round it out.Notes
dnnis already inROpenCVLite's default module list, so this compiles against what's already there (noBUILD_LISTchange, no contrib module, no new system dependency).src/dnn.h), anRCPP_MODULE, and an R wrapper (R/dnn.R), mirroring theImage/Videoclasses.forward, and returns correctly-shaped arrays.Targets
develop. Happy to adjust the API/conventions however you prefer.🤖 Generated with Claude Code