CARVIEW |
Navigation Menu
-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
G-API: Extend MediaFrame to be able to extract additional info besides access #20151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@dmatveev @TolyaTalamanov @rgarnov please, review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! 🔥
Only cosmetic fixes are required
@@ -1753,6 +1753,10 @@ namespace { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every MediaFrame
and Adapter
must implement this ? No default implementation by default ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Provided a default implementation and removed all the overloads
@@ -35,6 +35,10 @@ class TestMediaBGR final: public cv::MediaFrame::IAdapter { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really needed to define this default behavior manually ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just params
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, but you don't need to store it in separate variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
InferenceEngine::ParamMap pmap({{"HELLO", 42}, | ||
{"COLOR_FORMAT", | ||
InferenceEngine::ColorFormat::NV12}}); | ||
InferenceEngine::TensorDesc tdesc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, maybe it makes sense to test with non-empty TensorDesc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks for the example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR can be simplified dramatically :)
@@ -78,6 +81,7 @@ class GAPI_EXPORTS MediaFrame::IAdapter { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got you, fixed
@@ -49,6 +49,9 @@ class TestMediaBGR final: public cv::MediaFrame::IAdapter { | |||
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 { | |||
return std::make_pair<std::string, int>("hello", 42); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please drop these changes after you introduce a default implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
cv::util::any blobParams() const override { | ||
GAPI_Assert(false && "Not implemented"); | ||
return {}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please drop these changes after you introduce a default implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
cv::util::any blobParams() const override { | ||
GAPI_Assert(false && "Not implemented"); | ||
return {}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@@ -56,6 +56,15 @@ class TestMediaBGR final: public cv::MediaFrame::IAdapter { | |||
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 { | |||
return std::make_pair<InferenceEngine::TensorDesc, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you don't have to specify template manually, make_pair(...)
would be enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems I commented on these parts in another review, #20156 -- please incorporate the relevant review comments here and I think it can be merged.
Thanks!
@alalek can we merge this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alalek can you please merge this one before the freeze? Thanks
…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.