Skip to content

G-API: Extend python bindings#20271

Merged
alalek merged 6 commits intoopencv:masterfrom
TolyaTalamanov:at/extend-python-bindings
Jun 30, 2021
Merged

G-API: Extend python bindings#20271
alalek merged 6 commits intoopencv:masterfrom
TolyaTalamanov:at/extend-python-bindings

Conversation

@TolyaTalamanov
Copy link
Copy Markdown
Contributor

  • Wrap timestamp, seqNo, seq_id
  • Wrap copy
  • Wrap parseSSD, parseYolo

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
# disabled due high memory usage: test_opencl:Custom=ON
test_opencl:Custom=OFF
test_bigdata:Custom=1
test_filter:Custom=*

* Wrap timestamp, seqNo, seq_id
* Wrap copy
* Wrap parseSSD, parseYolo
@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@mpashchenkov Have a look, please

{
if (!obj || obj == Py_None)
{
return true;
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.

Why does the if return true here?

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.

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 is used for handling "default values" of arguments

@TolyaTalamanov TolyaTalamanov requested a review from alalek June 24, 2021 08:09
@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@alalek @mpashchenkov Could you have a look, please ?

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.

what is about adding of test code for new functionality?

}

template<>
bool pyopencv_to(PyObject* obj, int64& value, const ArgInfo& info)
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.

Bindings generator doesn't support int64 type in functions signatures. No plans to add that due to ambiguous using and compatibility issues with other languages. Consider using int / size_t instead.

It makes sense to add note here.

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.

Can I implement pyopencv_to(int64_t) with static_cast to size_t ?

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.

Main problem with size_t is that it is unsigned.

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 this implementation. Looks like it isn't necessary to read int64 data from python so far.

{
if (!obj || obj == Py_None)
{
return 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.

this is used for handling "default values" of arguments

@TolyaTalamanov TolyaTalamanov force-pushed the at/extend-python-bindings branch from 75993c7 to a998612 Compare June 28, 2021 08:12
HANDLE_CASE(RECT, cv::Rect);
HANDLE_CASE(UNKNOWN, cv::GArg);
UNSUPPORTED(UINT64);
UNSUPPORTED(INT64);
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.

Unsupported for pyopencv_to

return EPtr{new GraphMetaExecutable(graph, nodes)};
}

virtual bool controlsMerge() const override
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.

@dmatveev FYI

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.

what is about adding of test code for new functionality?

Added test: seq_id, seqNo, timestamp.
Already testing: parseSSD, networks
Didn't add test for parseYolo since there is no suitable model on CI

@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@alalek Could you have a look, please ?

@TolyaTalamanov TolyaTalamanov force-pushed the at/extend-python-bindings branch from 0f5fae4 to dcfddce Compare June 28, 2021 14:51
{
PyErr_SetString(PyExc_TypeError, "Unsupported type for cv.GIn()/cv.GOut()");
return NULL;
util::throw_error(std::logic_error("Unsupported type for GProtoArgs"));
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.

Does the message appear in error log? Why is not PyErr_SetString?

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.

has_frame, (ts, seqno, seqid) = ccomp.pull()

if not has_frame:
break
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 the if contain an error message?

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 don't think so, in fact I just put it in case video less than 10 frames

@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@alalek Can it be merged ?

@alalek alalek merged commit fb7ef76 into opencv:master Jun 30, 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
…bindings

G-API: Extend python bindings

* Extend G-API bindings

* Wrap timestamp, seqNo, seq_id
* Wrap copy
* Wrap parseSSD, parseYolo

* Rewrap cv.gapi.networks

* Add test for metabackend in pytnon

* Remove int64 pyopencv_to
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