G-API: Extend MediaFrame to be able to extract additional info besides access#20151
G-API: Extend MediaFrame to be able to extract additional info besides access#20151alalek merged 3 commits intoopencv:masterfrom
Conversation
|
@dmatveev @TolyaTalamanov @rgarnov please, review |
TolyaTalamanov
left a comment
There was a problem hiding this comment.
Great! 🔥
Only cosmetic fixes are required
| cv::MediaFrame::View::Strides ss = { m_mat.step, 0u, 0u, 0u }; | ||
| return cv::MediaFrame::View(std::move(pp), std::move(ss)); | ||
| } | ||
| cv::util::any blobParams() const override { |
There was a problem hiding this comment.
Every MediaFrame and Adapter must implement this ? No default implementation by default ?
There was a problem hiding this comment.
Agreed. Provided a default implementation and removed all the overloads
| cv::MediaFrame::View::Strides ss = { m_mat.step, 0u, 0u, 0u }; | ||
| return cv::MediaFrame::View(std::move(pp), std::move(ss), Cb{m_cb}); | ||
| } | ||
| cv::util::any blobParams() const override { |
There was a problem hiding this comment.
Is it really needed to define this default behavior manually ?
There was a problem hiding this comment.
Answered above
| cv::Mat bgr = cv::Mat::eye(240, 320, CV_8UC3); | ||
| cv::MediaFrame frame = cv::MediaFrame::Create<TestMediaBGR>(bgr); | ||
|
|
||
| cv::util::any any_params = frame.blobParams(); |
There was a problem hiding this comment.
Why not just params
There was a problem hiding this comment.
Ok, but you don't need to store it in separate variable
| InferenceEngine::ParamMap pmap({{"HELLO", 42}, | ||
| {"COLOR_FORMAT", | ||
| InferenceEngine::ColorFormat::NV12}}); | ||
| InferenceEngine::TensorDesc tdesc; |
There was a problem hiding this comment.
So, maybe it makes sense to test with non-empty TensorDesc
| auto params = cv::util::any_cast<std::pair<InferenceEngine::TensorDesc, | ||
| InferenceEngine::ParamMap>>(any_params); | ||
|
|
||
| InferenceEngine::ParamMap pmap({{"HELLO", 42}, |
There was a problem hiding this comment.
I would make it like this:
auto expected = std::make_pair(IE::TensorDesc{IE::Precision::U8, {1, 3, 300, 300}, IE::Layout::NCHW},
IE::ParamMap{{"HELLO", 42}, {"COLOR_FORMAT", IE::ColorFormat::NV12}});
auto actual = cv::util::any_cast<decltype(expected)>>(frame.params());
EXPECT_EQ(expected, actual);
There was a problem hiding this comment.
Done, thanks for the example
dmatveev
left a comment
There was a problem hiding this comment.
This PR can be simplified dramatically :)
| virtual ~IAdapter() = 0; | ||
| virtual cv::GFrameDesc meta() const = 0; | ||
| virtual MediaFrame::View access(MediaFrame::Access) = 0; | ||
| virtual cv::util::any blobParams() const = 0; |
There was a problem hiding this comment.
No as it breaks all the existing adapters. Please supply a default implementation instead (and make it safe enough to call by default - so no asserts/exceptions here if this default implementation is used).
There was a problem hiding this comment.
Got you, fixed
| } | ||
| cv::util::any blobParams() const override { | ||
| return std::make_pair<std::string, int>("hello", 42); | ||
| } |
There was a problem hiding this comment.
Please drop these changes after you introduce a default implementation
| cv::util::any blobParams() const override { | ||
| GAPI_Assert(false && "Not implemented"); | ||
| return {}; | ||
| } |
There was a problem hiding this comment.
Please drop these changes after you introduce a default implementation
| cv::util::any blobParams() const override { | ||
| GAPI_Assert(false && "Not implemented"); | ||
| return {}; | ||
| } |
|
@dmatveev @TolyaTalamanov please, review the changes |
|
@alalek How can I fix CN checks (do I need to)? I believe I got no branches in |
Ignore. These failures are infrastructure-related. |
| return cv::MediaFrame::View(std::move(pp), std::move(ss), Cb{m_cb}); | ||
| } | ||
| cv::util::any blobParams() const override { | ||
| return std::make_pair<InferenceEngine::TensorDesc, |
There was a problem hiding this comment.
I believe you don't have to specify template manually, make_pair(...) would be enough
|
@alalek can we merge this? |
…rame G-API: Extend MediaFrame to be able to extract additional info besides access * Extend MediaFrame to be able to extract additional info besides access * Add default implementation for blobParams() * Add comment on the default blobParams()
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.