CARVIEW |
Navigation Menu
-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
G-API: Add ROI processing in VPP preproc #21658
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
modules/gapi/src/streaming/onevpl/engine/preproc/preproc_engine.cpp
Outdated
Show resolved
Hide resolved
modules/gapi/src/streaming/onevpl/engine/preproc/preproc_engine.cpp
Outdated
Show resolved
Hide resolved
modules/gapi/test/streaming/gapi_streaming_vpp_preproc_test.cpp
Outdated
Show resolved
Hide resolved
decoded_frame = cv::MediaFrame(); | ||
preproc_number++; | ||
} | ||
} catch (...) {} |
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.
what's the reason to have catch here? Normally if ASSERT_TRUE
fails you may catch it (I believe those macros throw exceptions in gtest as the overall test suite execution continues after that)
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 don't exactly remember reasons why it was done as throwing exception (this code copy-pasted from older and older PR):
Maybe, I don't want to wrap each function in NO_THROW macro (3 at least), because as far i remember, some pp_*
have no default ctors. Also in any tests throwing exception and breaking while-loop is expected behavior
modules/gapi/src/streaming/onevpl/engine/preproc/preproc_engine.cpp
Outdated
Show resolved
Hide resolved
modules/gapi/src/streaming/onevpl/engine/preproc/preproc_engine.cpp
Outdated
Show resolved
Hide resolved
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.
some cosmetic-rearranging comments
testing::ValuesIn(files)); | ||
|
||
using roi_t = cv::Rect; | ||
using roi_t = cv::util::optional<cv::Rect>; |
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 using
can be declared at :183 and be used instead of all cv::util::optional<cv::Rect>
usages
preproc_roi_args_t {"highgui/video/big_buck_bunny.h265", | ||
MFX_CODEC_HEVC, MFX_ACCEL_MODE_VIA_D3D11, | ||
out_frame_info_t{cv::GFrameDesc {cv::MediaFormat::NV12, {1920, 1280}}}, | ||
roi_t{0,0,100,100}}, | ||
roi_t{}}, |
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.
you can use empty_roi
variable here? (and on :455)
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.
Looks good
@@ -181,6 +181,8 @@ using acceleration_t = int; | |||
using out_frame_info_t = cv::GFrameDesc; | |||
using preproc_args_t = std::tuple<source_t, decoder_t, acceleration_t, out_frame_info_t>; | |||
|
|||
static cv::util::optional<cv::Rect> empty_roi; |
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 it's needed?
Does it make sense to just pass cv::optional<cv::Rect>{}
?
TEST_CYCLE() | ||
{ | ||
source_ptr->pull(out); | ||
cv::MediaFrame frame = cv::util::get<cv::MediaFrame>(out); | ||
cv::util::optional<pp_params> param = preproc_engine.is_applicable(frame); | ||
pp_session sess = preproc_engine.initialize_preproc(param.value(), | ||
required_frame_param); | ||
(void)preproc_engine.run_sync(sess, frame); | ||
(void)preproc_engine.run_sync(sess, frame, empty_roi); |
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.
Honestly, I didn't understand how it works
Does it do crop
if roi
is passed and doesn't do crop
otherwise.
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.
optinal cv::Rect passed through engine and falls in pipeline execution, please check apply_roi
:
https://github.com/opencv/opencv/pull/21658/files#diff-d281efabce2ff069582bd99d9c40e910c4386b65d60010ed9e4b106f4f2b237bR39
If no roi stored in optional then no crop operation would happen
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.
π thanks
memcpy(&(original_surface_ptr->Info), | ||
&original_frame_info, sizeof(Surface::info_t)); |
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 may be way to C-ish, and unsafe for C++ data types if any. Would operator= work better where? Just wondering
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 is packed C-structure in VPL/MFX without operator=. I didn't implement our custom operator= because it doesn't protect us from VPL API changes ( when new fields will added in such c-structure from vpl side)
@alalek Could you merge it please? Minor comments elapsed which may be implemented in the next PRs |
G-API: Add ROI processing in VPP preproc * Add ROI in VPP prepro * Apply comments
Add ROI processing for core part of VPP preproc which is essential from #21554
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.
Build Configuration