Skip to content

G-API: oneVPL (simplification) source base commit#20546

Merged
alalek merged 9 commits intoopencv:masterfrom
sivanov-work:initial_vpl_source
Aug 17, 2021
Merged

G-API: oneVPL (simplification) source base commit#20546
alalek merged 9 commits intoopencv:masterfrom
sivanov-work:initial_vpl_source

Conversation

@sivanov-work
Copy link
Copy Markdown
Contributor

@sivanov-work sivanov-work commented Aug 12, 2021

this PR is the single one in series of #20469
Introduce base oneVPLSource in gapi

It's activated by configuration stage with the following options:

It will try to search VPL in PATH and if doesn't find it then do use git clone to download & build it from sources

cmake -S . -B build_clone_vpl -DWITH_GAPI_ONEVPL=ON

or tries to find specific installed implementation by ONEVPL_DIR

cmake -S . -B build_clone_vpl -DWITH_GAPI_ONEVPL=ON -DONEVPL_DIR=<vpl_sources>

with error if not founded

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Build configuration

force_builders=Custom,Custom Win,Custom Mac
build_gapi_standalone:Linux x64=ade-0.1.1f
build_gapi_standalone:Win64=ade-0.1.1f
build_gapi_standalone:Mac=ade-0.1.1f
build_gapi_standalone:Linux x64 Debug=ade-0.1.1f

Xbuild_image:Custom=centos:7
Xbuildworker:Custom=linux-1
build_gapi_standalone:Custom=ade-0.1.1f

build_image:Custom=ubuntu-openvino-2021.3.0:20.04
build_image:Custom Win=openvino-2021.2.0
build_image:Custom Mac=openvino-2021.2.0

test_modules:Custom=gapi,python2,python3,java
test_modules:Custom Win=gapi,python2,python3,java
test_modules:Custom Mac=gapi,python2,python3,java

buildworker:Custom=linux-1
test_opencl:Custom=OFF
test_bigdata:Custom=1
test_filter:Custom=*

@sivanov-work
Copy link
Copy Markdown
Contributor Author

@alalek Could you please review cmake related part of oneVPL configuration for gapi? because it interact with default opencv configuration part. Additionally: Is it possible to create optional CI/CD configuration with -DWITH_GAPI_ONEVPL=ON and integrate it into https://pullrequest.opencv.org/ ?
Plugin-based oneVPL source is a good idea but it's expensive now for gapi-development

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently there is no images on public CI with oneVPL available.

I plan to add oneAPI builders later which have oneVPL SDK (~2-3 weeks).

// Create source
cv::Ptr<cv::gapi::wip::IStreamSource> cap;
try {
cap = cv::gapi::wip::make_vpl_src(file_path);
Copy link
Copy Markdown
Member

@alalek alalek Aug 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we implement that through "Kernel packages"?
Their definition can be header-only, but implementation requires extra dependencies, or be dynamically loadable.

/cc @dmatveev

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alalek For media sources, it is not clear yet.

Sure we can move the decode to the graph level so it becomes an "Operation" (with a single-header definition), and its implementations become "Kernels", so VPL or GStreamer could be specified via a kernel package -- and this mechanism would work there for free.

This approach has its cons, though, so I doubt if decode should be a graph operation or be a graph source. Let it (and GStreamer) be sources for now -- and for sources, probably sooner or later we'll introduce something factory-like to construct them based on capabilities, options, and so on

project(oneVPL-download NONE)

include(ExternalProject)
ExternalProject_Add(oneVPL
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use ExternalProject_Add in OpenCV.

find_package(VPL) should be enough.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about automatic "download & build" feature for oneVPL in case it not installed or not found in the system.
It completely reduces required configuration steps for developers: no need worries about how to get oneVPL, configure, sourcing PATH and so on

If ExternalProjecy_Add is abandoned cmake feature in opencv - Then I'll remove it and we loose "download & build" for oneVPL.
@alalek Please respond - did I understand you comment correctly?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider oneVPL dependency as prerequisite.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. entire file removed from PR

Comment on lines +2 to +4
if (NOT ONEVPL_DIR)
message("Search oneVPL package by PATH")
find_package(VPL QUIET)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ONEVPL_DIR may be unused in find_package(). There are tons of other methods for searching packages. We shuold not stick to this one.
Refer to CMake documentation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitely. is it unused here in this part of branch but has worth in else() branch for searching VPL in specific location

The idea behind this implementation is the following:
I) If -DWITH_ONEVPL is set ON then we tried to search it in default PATH and used found one or downloaded new from github

It works when:
a) user sourced vars.sh from oneVPL package before (Normal way as oneAPI usage suggested). In this case we do not need to find_package, just for sanity check
b) oneVPL installed by default SYSTEM PATH. In this case find_package do not use ONEVPL_DIR as well
c) If no one found, then we clone it from git hub using ExternalProjectAdd

II) another option is passing ONEVPL_DIR as external oneVPL package location:
a) In this case we force find_package to find oneVPL by ONEVPL_DIR only (do not check PATH). It's else() branch for this if-condition. I suggest this options for "Custom-oneVPL" package to work-around issues which are not fixed in main oneVPL repo or official release package or some customization

If I understood your previous comment about ExternalProject_Add correctly then you suggest to eliminate "download&build" from github feature and we should retain I-a,b and II-a

But I find "download&build" very usefull at least for current development :) (May we wrapped it by additional FORCE_DOWNLOAD_ONEVPL flag ?)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No download. No check for ONEVPL_DIR.
Just find_package(VPL)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed. just bare find_package is used at now

message("No oneVPL found, clone it from repository")
set(ONEVPL_PROJECT_PREFIX "${OpenCV_BINARY_DIR}/3rdparty/oneVPL")
configure_file("${CMAKE_CURRENT_LIST_DIR}/DownloadOneVPL.cmake.in" ${ONEVPL_PROJECT_PREFIX}/oneVPL-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't support cross-compilation at least.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do no nothing about that before... But current oneVPL implementation for GAPI means Windows only
cc @dmatveev could you confirm or reject it?

@alalek & @dmatveev what do you think about wrapped externalProject_add and such non-cross execute_process for WINDOWS only (if this kind of check in present in build system) or some kind of DEV_* cmake flag?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do no nothing about that before... But current oneVPL implementation for GAPI means Windows only
cc @dmatveev could you confirm or reject it?

Our target use-cases are Windows only but VPL is cross-platform (I believe) so we could continue using/testing it on Linux, too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. removed

@dmatveev dmatveev self-assigned this Aug 16, 2021
@dmatveev dmatveev added this to the 4.5.4 milestone Aug 16, 2021
Copy link
Copy Markdown
Contributor

@dmatveev dmatveev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok to go, looking forward for the initial implementation PR.

endif()
endif()

if(WITH_GAPI_ONEVPL)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be WITH_GAPI_ or just WITH_? The above two options don't have GAPI in the name.. @alalek do any other modules react to WITH_VPL?

// Create source
cv::Ptr<cv::gapi::wip::IStreamSource> cap;
try {
cap = cv::gapi::wip::make_vpl_src(file_path);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alalek For media sources, it is not clear yet.

Sure we can move the decode to the graph level so it becomes an "Operation" (with a single-header definition), and its implementations become "Kernels", so VPL or GStreamer could be specified via a kernel package -- and this mechanism would work there for free.

This approach has its cons, though, so I doubt if decode should be a graph operation or be a graph source. Let it (and GStreamer) be sources for now -- and for sources, probably sooner or later we'll introduce something factory-like to construct them based on capabilities, options, and so on

@sivanov-work
Copy link
Copy Markdown
Contributor Author

@alalek
Could you please merge it on? in case of no objections about WITH_GAPI_ ONEVPL ...
There are ~4 dependent PRs pending


if(WITH_GAPI_ONEVPL)
find_package(VPL)
set(HAVE_GAPI_ONEVPL TRUE)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if(VPL_FOUND)
  set(HAVE_GAPI_ONEVPL TRUE)
endif()

here and below

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied in both places

Comment on lines +239 to +243
if (!writer.isOpened()) {
const auto sz = cv::Size{outMat.cols, outMat.rows};
writer.open(output, cv::VideoWriter::fourcc('M','J','P','G'), 25.0, sz);
CV_Assert(writer.isOpened());
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense to open writer before the main processing loop.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied

@alalek alalek merged commit 46fb88c into opencv:master Aug 17, 2021
@alalek alalek mentioned this pull request Oct 15, 2021
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
G-API: oneVPL (simplification) source base commit

* oneVPL source initial

* Fix compilation

* Fix compilation path

* Fix NO VPL compile

* Fix unused vars

* Fix unused vars in example

* Simplify oneVPL search: no custom path & download

* Fix standalone GAPI

* Apply comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants