Conversation
2e2ce45 to
77f55fc
Compare
| { | ||
| args.emplace_back(reinterpret_cast<pyopencv_GMat_t*>(item)->v); | ||
| } | ||
| else if (PyObject_TypeCheck(item, reinterpret_cast<PyTypeObject*>(pyopencv_GArrayP2f_TypePtr))) |
There was a problem hiding this comment.
Since each instance for GArray and GOpaque is a separate object we need to have a huge if here, we can make a separate object for Python that will contain all types for GArray and GOpaque and will be created like this:
g_in = GArray(cv.detail.OpaqueKind.RECT).
I didn't do this because OpaqueKind is located in the internal namespace detail, let's discuss it locally
There was a problem hiding this comment.
Not relevant
b716e9c to
353267e
Compare
|
@TolyaTalamanov Please rebase this PR |
f563c41 to
0c015e1
Compare
|
@dkurt @smirnov-alexey Could you take a look, please ? |
ea95239 to
6c6180c
Compare
| return GRunArgsP{ GRunArgP(detail::wrap_host_helper<Ts>::wrap_out(args))... }; | ||
| } | ||
|
|
||
| // NB: Used by python wrapper |
There was a problem hiding this comment.
Where should it be placed ?
There was a problem hiding this comment.
Are you going to address this?
| }; | ||
|
|
||
| using GArrayP2f = GArray<cv::Point2f>; | ||
| using GRects = GArray<cv::Rect>; |
There was a problem hiding this comment.
Does it make sense to implement wrapper for GArray & GOpaque to avoid making using for every GArray & GOpaque type ?
There was a problem hiding this comment.
Do you really need using everywhere? And why does it bother you? I don't think you need an extra wrapper here
There was a problem hiding this comment.
It is impossible to wrap template object into python, so I just make using and wrap it in shadow_gapi.hpp
|
|
||
| // NB: Used by python wrapper | ||
| using GSize = GOpaque<cv::Size>; | ||
| using GRect = GOpaque<cv::Rect>; |
There was a problem hiding this comment.
Does it make sense to implement wrapper for GArray & GOpaque to avoid making using for every GArray & GOpaque type ?
|
|
||
| // NB: Python wrapper generate T_U for T<U> | ||
| // This behavior is only observed for inputs | ||
| using GOpaque_Size = cv::GOpaque<cv::Size>; |
There was a problem hiding this comment.
Should it be fixed on python code generator side ?
There was a problem hiding this comment.
Oh I see what do you mean by using using. Does this behavior block us?
There was a problem hiding this comment.
No, it can be fixed like this
| { | ||
| args.emplace_back(reinterpret_cast<pyopencv_GArrayP2f_t*>(item)->v.strip()); | ||
| } | ||
| else if (PyObject_TypeCheck(item, reinterpret_cast<PyTypeObject*>(pyopencv_GSize_TypePtr))) |
There was a problem hiding this comment.
Looks really ugly
|
@smirnov-alexey @dmatveev Could you check that ? |
| struct GTypeInfo; | ||
| using GTypesInfo = std::vector<GTypeInfo>; | ||
|
|
||
| using ExtractArgsCallback = std::function<cv::GRunArgs(const cv::GTypesInfo& info)>; |
There was a problem hiding this comment.
Is it relevant to garg.hpp at all?
There was a problem hiding this comment.
I don't think so, maybe we need a special place to move python stuff to there
There was a problem hiding this comment.
Just put a FIXME here (mentioning where it is actually required)
|
|
||
| # G-API | ||
| g_in = cv.GMat() | ||
| g_out = cv.gapi.boundingRect(g_in) |
There was a problem hiding this comment.
So does this work without defining GOpaque<Size> as GSize ?
There was a problem hiding this comment.
No, because it's needed to wrap GOpaque<Size> into python somehow
There was a problem hiding this comment.
Not relevant
use cv.GOpaqueT(cv.gapi.CV_SIZE)
| comp = cv.GComputation(cv.GIn(g_in), cv.GOut(g_out)) | ||
|
|
||
| actual = comp.apply(cv.gin(points)) | ||
| print('actual = ', actual) |
There was a problem hiding this comment.
Also.
I want to create a graph which has GOpaque<cv::Rect> among of its inputs. How does it looks like in Python?
There was a problem hiding this comment.
g_in = cv.GRect()
BTW, need to remove this print
There was a problem hiding this comment.
Not relevant
8f1e0e6 to
4b85848
Compare
4b85848 to
e5b7976
Compare
| } | ||
|
|
||
| template<> | ||
| bool pyopencv_to_generic_vec<bool>(PyObject* obj, std::vector<bool>& value, const ArgInfo& info) |
There was a problem hiding this comment.
@alalek Do you mind if I add this specialization ?
|
@dmatveev @smirnov-alexey Could you have a look ? |
|
@TolyaTalamanov I would recommend to switch the build to openvino 2021.01 due to red tests |
| } | ||
| } | ||
|
|
||
| cv::detail::GOpaqueU strip() { |
There was a problem hiding this comment.
Actually, I would rename that
There was a problem hiding this comment.
Why ? What's your suggestion ?
There was a problem hiding this comment.
I think it's a bit harsh word but maybe it's just me:) You could use unpack or extract
There was a problem hiding this comment.
Ok, don't think that it's really big effort to change that. Let's wait for the @dmatveev comments.
smirnov-alexey
left a comment
There was a problem hiding this comment.
There are some minor comments left but overall looks good
dmatveev
left a comment
There was a problem hiding this comment.
Too much changes here. Type lists are constantly duplicated. The graph compilation flow is not clear now. No description provided to the MR.
If possible, I'd break it into smaller parts for an easier review. With such massive changes it is quite easy to break old contracts.
| struct GTypeInfo; | ||
| using GTypesInfo = std::vector<GTypeInfo>; | ||
|
|
||
| using ExtractArgsCallback = std::function<cv::GRunArgs(const cv::GTypesInfo& info)>; |
There was a problem hiding this comment.
Just put a FIXME here (mentioning where it is actually required)
|
|
||
| /// @private -- Exclude this function from OpenCV documentation | ||
| GAPI_WRAP GRunArgs apply(GRunArgs &&ins, GCompileArgs &&args = {}); | ||
| GAPI_WRAP GRunArgs apply(const cv::ExtractArgsCallback& callback, GCompileArgs &&args = {}); |
There was a problem hiding this comment.
This cv::ExtractArgsCallback shouldn't be in cv::. cv::detail:: is better.
| */ | ||
| GAPI_WRAP void setSource(GRunArgs &&ins); | ||
| void setSource(GRunArgs &&ins); | ||
| GAPI_WRAP void setSource(const cv::ExtractArgsCallback& callback); |
There was a problem hiding this comment.
Please separate these two, and make this 2nd setSource "private" for doxygen.
| CV_SIZE, | ||
| CV_RECT, | ||
| CV_SCALAR, | ||
| CV_MAT, |
There was a problem hiding this comment.
Please declare this list of CV_XXX / type pairs once, and avoid all the code duplication below.
|
|
||
| struct GAPI_EXPORTS_W_SIMPLE GArrayT | ||
| { | ||
| using Storage = MakeVariantType< cv::GArray |
| { | ||
| if (PyObject_TypeCheck(obj, reinterpret_cast<PyTypeObject*>(pyopencv_GOpaqueT_TypePtr))) | ||
| { | ||
| auto& opaque = reinterpret_cast<pyopencv_GOpaqueT_t*>(obj)->v; |
|
|
||
| auto ins = callback(m_priv->m_lastCompiled.priv().inInfo()); | ||
|
|
||
| // NB: After getting the arguments, recompile the graph with the correct meta |
There was a problem hiding this comment.
Double compilation may be costly
There was a problem hiding this comment.
..especially when dealing with NNs.
| util::throw_error(std::logic_error("Unsupported kind for GArray")); | ||
| } | ||
| cv::detail::VectorRef ref; | ||
| util::get<cv::detail::ConstructVec>(info.ctor)(ref); |
There was a problem hiding this comment.
Not sure if any other function in this file/class operates on the same low level of abstraction - it is all built on some higher-level entities. Please keep the abstraction level.
| // FIXME: select which executor will be actually used, | ||
| // make GExecutor abstract. | ||
| pE.reset(new GExecutor(std::move(pg))); | ||
| } |
There was a problem hiding this comment.
Is the above comment still valid after your changes?
| std::unique_ptr<ade::Graph> pG = generateGraph(); | ||
| runPasses(*pG); | ||
| compileIslands(*pG); | ||
| if (!m_metas.empty()) |
There was a problem hiding this comment.
Can compilation go a wrong way now? What if I call a regular compile() (like in e.g. v4.2) with an empty metadata vector - what will happen?
|
Was split and merged |
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