forked from Rightpoint/opencv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request opencv#17493 from TolyaTalamanov:at/python-binding…
…s-gapi * Implement G-API python bindings * Fix hdr_parser * Drop initlization with brackets using regexp * Handle bracket initilization another way * Add test for core operations * Declaration and definition of View constructor now in different files * Refactor tests * Remove combine decorator from tests * Fix comment to review * Fix test * Fix comments to review * Remove GCompilerArgs implementation from python Co-authored-by: Pinaev <[email protected]>
- Loading branch information
1 parent
afe9993
commit c708f50
Showing
18 changed files
with
128 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ ocv_add_module(gapi | |
opencv_imgproc | ||
OPTIONAL | ||
opencv_video | ||
WRAP | ||
python | ||
) | ||
|
||
if(MSVC) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using gapi_GKernelPackage = cv::gapi::GKernelPackage; | ||
|
||
template<> | ||
bool pyopencv_to(PyObject* obj, std::vector<GCompileArg>& value, const ArgInfo& info) | ||
{ | ||
return pyopencv_to_generic_vec(obj, value, info); | ||
} | ||
|
||
template<> | ||
PyObject* pyopencv_from(const std::vector<GCompileArg>& value) | ||
{ | ||
return pyopencv_from_generic_vec(value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#error This is a shadow header file, which is not intended for processing by any compiler. \ | ||
Only bindings parser should handle this file. | ||
|
||
namespace cv | ||
{ | ||
GAPI_EXPORTS_W GCompileArgs compile_args(gapi::GKernelPackage pkg); | ||
} // namespace cv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env python | ||
|
||
import numpy as np | ||
import cv2 as cv | ||
|
||
from tests_common import NewOpenCVTests | ||
|
||
|
||
# Plaidml is an optional backend | ||
pkgs = [ | ||
cv.gapi.core.ocl.kernels(), | ||
cv.gapi.core.cpu.kernels(), | ||
cv.gapi.core.fluid.kernels() | ||
# cv.gapi.core.plaidml.kernels() | ||
] | ||
|
||
|
||
class gapi_core_test(NewOpenCVTests): | ||
|
||
def test_add(self): | ||
# TODO: Extend to use any type and size here | ||
sz = (1280, 720) | ||
in1 = np.random.randint(0, 100, sz).astype(np.uint8) | ||
in2 = np.random.randint(0, 100, sz).astype(np.uint8) | ||
|
||
# OpenCV | ||
expected = in1 + in2 | ||
|
||
# G-API | ||
g_in1 = cv.GMat() | ||
g_in2 = cv.GMat() | ||
g_out = cv.gapi.add(g_in1, g_in2) | ||
comp = cv.GComputation(g_in1, g_in2, g_out) | ||
|
||
for pkg in pkgs: | ||
actual = comp.apply(in1, in2, args=cv.compile_args(pkg)) | ||
# Comparison | ||
self.assertEqual(0.0, cv.norm(expected, actual, cv.NORM_INF)) | ||
|
||
|
||
if __name__ == '__main__': | ||
NewOpenCVTests.bootstrap() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters