-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Initial media support for G-API background subtraction demo #3535
Initial media support for G-API background subtraction demo #3535
Conversation
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 there any performance numbers? Did you test it with GPU?
cv::gapi::wip::onevpl::CfgParam createFromString(const std::string &line) { | ||
using namespace cv::gapi::wip; | ||
|
||
if (line.empty()) { | ||
throw std::runtime_error("Cannot parse CfgParam from emply line"); | ||
} | ||
|
||
std::string::size_type name_endline_pos = line.find(':'); | ||
if (name_endline_pos == std::string::npos) { | ||
throw std::runtime_error("Cannot parse CfgParam from: " + line + | ||
"\nExpected separator \":\""); | ||
} | ||
|
||
std::string name = line.substr(0, name_endline_pos); | ||
std::string value = line.substr(name_endline_pos + 1); | ||
|
||
return cv::gapi::wip::onevpl::CfgParam::create(name, value, | ||
/* vpp params strongly optional */ | ||
name.find("vpp.") == std::string::npos); | ||
} | ||
|
||
static std::vector<cv::gapi::wip::onevpl::CfgParam> parseVPLParams(const std::string& cfg_params) { | ||
std::vector<cv::gapi::wip::onevpl::CfgParam> source_cfgs; | ||
std::stringstream params_list(cfg_params); | ||
std::string line; | ||
while (std::getline(params_list, line, ';')) { | ||
source_cfgs.push_back(createFromString(line)); | ||
} | ||
return source_cfgs; | ||
} |
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 user apps shouldn't reinvent this bycicle every time.. We should ship some default implementation for this, please add it to the todo list :)
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.
From my opinion it should be default args-list parsing routine (with find-first-one-separator string ",;\n\r") which provides a std::list<std::string>
and then transforming this list into cfgParams by using createFromString
in loop on them (or CfgParam::create<string>
if works)
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.
Let it be as part of this issue: opencv/opencv#22506
@@ -169,7 +169,7 @@ custom::MaskRCNNBGReplacer::MaskRCNNBGReplacer(const std::string& model_path) : | |||
} | |||
} | |||
|
|||
cv::GMat custom::MaskRCNNBGReplacer::replace(cv::GMat in, const cv::Size& in_size, cv::GMat background) { | |||
cv::GMat custom::MaskRCNNBGReplacer::replace(cv::GFrame in, cv::GMat bgr, const cv::Size& in_size, cv::GMat background) { |
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 do you need BGR here as an explicit parameter?
Can BGR()
be called right here, in this function?
In the BGR GMat used somewhere else in the pipeline?
(If yes, we need to consider auto-optimizing 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.
BGR GMat might be used as a background in case blur
option.
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.
Could you elaborate What do you mean by auto-optimizing
That's complicated, I've only managed to run |
@eaidova Could you quickly review from |
@TolyaTalamanov From omz point of view, you need update readme, also it will be nice if you provide test for demo work with new keys. |
demos/background_subtraction_demo/cpp_gapi/background_subtraction_demo_gapi.hpp
Show resolved
Hide resolved
Yes, it actually requires additional flags for building, but it relates only to |
Running without
|
about fails: MFX is bacward compatible with Intel Media ... Library and supports vast devices variety, but VPL implementation supports only new Intel GPU/CPU devices. mfxImplDescription.ApiVersion.Version:1.12 or change VPL Source code to ignore this and reuse MFX forcibly (@TolyaTalamanov we discussed how to change condition in this piece of code) |
I installed oneVPL via installation manager following https://github.com/opencv/opencv/wiki/Graph-API#building-with-onevpl-toolkit-support. Added
|
@Wovchena So we need 2-rows changes in |
@Wovchena about 1 and 2 The use-case 2 skip this demultiplexing routing and tries to load and apply VPL library but fails because VPL library version is new and non-tested, right before extract frames from video file. The last operation would fail too, because you set CodedID for containerized video which is incorrect here So, the right facility is using command line from your first version (without specfified CodecID) and make sure that video format inside AVI is supported by VPL library codec. Little comment: For checking what video format exactly inside AVI file - you can use DEBUG level in opencv library by: |
I removed the assertion from
I guess the codec I selected doesn't match with the provided video. So I tried
It still doesn't run. How do I fix it? |
looks correct. +I suppose it is used CPU version for decode/encode. We need to force GPU device by set MFX acceleration param = MFX_ACCEL_TYPE_D3D11 (not sure i've spelled it correctly) - to choose default GPU device. |
Diff: https://github.com/opencv/opencv/compare/4.x...Wovchena:onevpl-remove-version-assertion?expand=1 |
@sivanov-work, do I understand it correctly that the demo is required to be run with |
@Wovchena |
|
This PR is bringing only basic |
I think you shouldn't have just removed assertion because execution should fall to |
Please add a note somewhere about background matting models that aren't in OMZ so I wouldn't forget next time |
opencv/opencv#22507 - this makes it work without providing codec. |
Must be fixed with the latest commit |
Done |
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, do something about warning spam like [ WARN:2@3.889] global C:\Users\vzlobin\r\opencv\modules\gapi\src\streaming\onevpl\accelerators\surface\surface_pool.cpp (66) cv::gapi::wip::onevpl::CachedPool::find_free cannot get free surface from pool, size: 21
. That doesn't seem right that correctly configured demo produces that.
@@ -83,7 +102,7 @@ Options: | |||
-target_bgr Optional. Background onto which to composite the output (by default to green field). | |||
-u Optional. List of monitors to show initially. | |||
-use_onevpl Optional. Use onevpl video decoding. | |||
-onevpl_params Optional. Parameters for onevpl video decoding. Format: <prop name>:<value>;<prop name>:<value> Semicolon separated list of oneVPL mfxVariants which is used for configuring source (see `MFXSetConfigFilterProperty` by https://spec.oneapi.io/versions/latest/elements/oneVPL/source/index.html) | |||
-onevpl_params Optional. Parameters for onevpl video decoding. OneVPL source can be fine-grained by providing configuration parameters. Format: <prop name>:<value>;<prop name>:<value> Several important configuration parameters: -mfxImplDescription.mfxDecoderDescription.decoder.CodecID values: https://spec.oneapi.io/onevpl/2.7.0/API_ref/VPL_enums.html?highlight=mfx_codec_hevc#codecformatfourcc-mfxImplDescription.AccelerationMode values: https://spec.oneapi.io/onevpl/2.7.0/API_ref/VPL_disp_api_enum.html?highlight=d3d11#mfxaccelerationmode(see `MFXSetConfigFilterProperty` by https://spec.oneapi.io/versions/latest/elements/oneVPL/source/index.html) |
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 is OneVPL source can be fine-grained by providing configuration parameters.
sentence for? To me it's the same as Parameters for onevpl video decoding.
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.
Committed your suggestion
@Wovchena This warning might be fixed by increasing onevpl frame pool size. I've added new flag It's actually produce another one:
But it doesn't spam console so much. I guess this is also fixable by providing some configuration option. @sivanov-work Could you advise us please? |
* Initial onevpl suppport * Switch to GFrame
Co-authored-by: Zlobin Vladimir <vladimir.zlobin@intel.com>
Co-authored-by: Zlobin Vladimir <vladimir.zlobin@intel.com>
Co-authored-by: Zlobin Vladimir <vladimir.zlobin@intel.com>
Co-authored-by: Zlobin Vladimir <vladimir.zlobin@intel.com>
3dbee89
to
1284917
Compare
@Wovchena Could you go through it one more time, please? I guess the majority of issues have been addressed. |
demos/background_subtraction_demo/cpp_gapi/background_subtraction_demo_gapi.hpp
Outdated
Show resolved
Hide resolved
demos/background_subtraction_demo/cpp_gapi/background_subtraction_demo_gapi.hpp
Show resolved
Hide resolved
demos/background_subtraction_demo/cpp_gapi/background_subtraction_demo_gapi.hpp
Outdated
Show resolved
Hide resolved
…ion_demo_gapi.hpp Co-authored-by: Zlobin Vladimir <vladimir.zlobin@intel.com>
Co-authored-by: Zlobin Vladimir <vladimir.zlobin@intel.com>
…ion_demo_gapi.hpp Co-authored-by: Zlobin Vladimir <vladimir.zlobin@intel.com>
Co-authored-by: Zlobin Vladimir <vladimir.zlobin@intel.com>
🍾 |
Overview
GMat
toGFrame
for input image. (Background img is stillGMat
).onevpl
support. (See--use_onevpl
,--vpl_params
)The next steps will be:
onevpl
functionalityGFrame
for background img.