G-API: Add ROI processing in VPP preproc#21658
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.
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.
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
OrestChura
left a comment
There was a problem hiding this comment.
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.
this using can be declared at :183 and be used instead of all cv::util::optional<cv::Rect> usages
| 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.
you can use empty_roi variable here? (and on :455)
| 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.
Why it's needed?
Does it make sense to just pass cv::optional<cv::Rect>{} ?
| 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.
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.
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
| memcpy(&(original_surface_ptr->Info), | ||
| &original_frame_info, sizeof(Surface::info_t)); |
There was a problem hiding this comment.
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.
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