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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add stateful kernel to python G-API #22037
Conversation
Hi @xiong-jie-y the proposal & design looks great the only question is that really should be exposed to python? I think it should cover your needs. |
@TolyaTalamanov in your example, is the state shared across all instances of your kernel? We do have stateful kernels as special objects in G-API since the state is managed explicitly and its lifetime is well-defined. |
Yes, it's shared across all instances |
Thats not a way to go I believe :) Imagine running multiple trackers on multiple streams in the same app (and it is a pretty valid scenario). We should prioritize merging the @xiong-jie-y 's feature than |
|
||
cv::GRunArgs operator()(const GPythonContext& ctx); |
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 think it's redundant to wrap every stored std::function
to method
@dmatveev @xiong-jie-y @asmorkalov @alalek Folks, do you have any comments? Can it be merged? |
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 Anatoliy for completing this
馃挘 |
Please review both interface design and code. 馃檪
Motivation
Stateful kernel in C++ is really useful to many usecases like tracking.
This PR will enable python G-API users to use stateful kernel and expand the usecases in python G-API.
Feature Design
Here is the example video and the example code of this feature.
The example kernel is like this.
Basically it create internal state in the
setup
method and pass it to the G-API framework by returning it.run
method recieves additionalstate
argument and user can handle state with this argument.It is quite similar to the C++ stateful kernel API
GAPI_OCV_KERNEL_ST
and difference is setup method return state to the framework. This is the interface that I'd like to ask you to review 馃檪How to run the demo code?
pip install numpy click
For video input.
For video file
TODO
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.
-> No need for performance