G-API: Support GFrame for ONNX infer #19070
Conversation
|
@smirnov-alexey, please review. |
|
@mpashchenkov please extend builds section (can take from here #19009 I believe) |
| break; | ||
| } | ||
| case cv::GMetaArg::index_of<cv::GFrameDesc>(): { | ||
| // FIXME: Is there any validation for GFrame ? |
There was a problem hiding this comment.
Maybe you need to check color formats here? If there are similar cases with no checks for GFrameDesc lets just left this as is
There was a problem hiding this comment.
Added check for GFrameDesc parameters. I think it should be a function (analogue of isND()) because IE backend should do similar checks. Create a ticket for this?
|
Overall looks good, thanks! |
|
@TolyaTalamanov, @dmatveev, it is. |
| } | ||
| } | ||
|
|
||
| void preprocess(const std::unique_ptr<cv::MediaFrame::View>& view, |
There was a problem hiding this comment.
It can be just View& as for giebackend
dmatveev
left a comment
There was a problem hiding this comment.
I think it can be merged
| switch (ctx.in_shapes[in_idx]) { | ||
| case cv::GShape::GFRAME: { | ||
| const cv::MediaFrame& frame = ctx.inFrame(in_idx); | ||
| views.emplace_back(new cv::MediaFrame::View(frame.access(cv::MediaFrame::Access::R))); |
There was a problem hiding this comment.
Make sure your views is preallocated to the right size.
There was a problem hiding this comment.
it should be a reserve() somewhere earlier in the stack.
the idea is to avoid vector reallocations if possible, but since elements will be moved instead of copied, it should still work for unique pointers over views.
| break; | ||
| } | ||
| case cv::GMetaArg::index_of<cv::GFrameDesc>(): { | ||
| // FIXME: Is there any validation for GFrame ? |
… non processed input data
|
@mpashchenkov is it ready for review? |
| switch (ctx.in_shapes[in_idx]) { | ||
| case cv::GShape::GFRAME: { | ||
| const cv::MediaFrame& frame = ctx.inFrame(in_idx); | ||
| views.emplace_back(new cv::MediaFrame::View(frame.access(cv::MediaFrame::Access::R))); |
There was a problem hiding this comment.
it should be a reserve() somewhere earlier in the stack.
the idea is to avoid vector reallocations if possible, but since elements will be moved instead of copied, it should still work for unique pointers over views.
| break; | ||
| } | ||
| case cv::GShape::GMAT: { | ||
| exMat = ctx.inMat(in_idx); |
There was a problem hiding this comment.
It also requires preprocessing, isn't it?
There was a problem hiding this comment.
...resize, normalization, etc. Where does it happen now for a regular GMat input?
There was a problem hiding this comment.
oh I see you do it also in setInput(). This flow is somewhat complicated, do you have two preprocess() functions now which do different things?
dmatveev
left a comment
There was a problem hiding this comment.
Let's merge it now as it seem to work, but file a refactoring task to our tracker.
What is confusing here now is calling void extractMat(...) first and then accessing some .exMat field. This needs to be reworked to make side effects more clear.
G-API: Support GFrame for ONNX infer * Added GFrame for ONNX * Cut test * Removed IE from assert * Review comments * Added const/bbot rstrt * View instead unique_ptr in func. sig. * Added extractMat function, ONNXCompiled contains exMat - cv::Mat with non processed input data * Added meta check for inferList2
Support cv::MediaFrame for infer input in ONNX backend.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.
Custom build: