mirror of
https://github.com/opencv/opencv.git
synced 2025-06-11 03:33:28 +08:00
Merge pull request #18309 from TolyaTalamanov:at/wrap-apply-overloads
[G-API] Wrap cv::gapi::mean kernel into python * Wrap cv::gapi::mean kernel into python * Fix test
This commit is contained in:
parent
1604ea3b27
commit
a258404a58
@ -744,7 +744,7 @@ Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref
|
||||
@note Function textual ID is "org.opencv.core.math.mean"
|
||||
@param src input matrix.
|
||||
*/
|
||||
GAPI_EXPORTS GScalar mean(const GMat& src);
|
||||
GAPI_EXPORTS_W GScalar mean(const GMat& src);
|
||||
|
||||
/** @brief Calculates x and y coordinates of 2D vectors from their magnitude and angle.
|
||||
|
||||
|
@ -181,7 +181,7 @@ public:
|
||||
* @param in input GMat of the defined unary computation
|
||||
* @param out output GScalar of the defined unary computation
|
||||
*/
|
||||
GComputation(GMat in, GScalar out); // Unary overload (scalar)
|
||||
GAPI_WRAP GComputation(GMat in, GScalar out); // Unary overload (scalar)
|
||||
|
||||
/**
|
||||
* @brief Defines a binary (two inputs -- one output) computation
|
||||
@ -286,7 +286,7 @@ public:
|
||||
* @param args compilation arguments for underlying compilation
|
||||
* process.
|
||||
*/
|
||||
void apply(cv::Mat in, cv::Scalar &out, GCompileArgs &&args = {}); // Unary overload (scalar)
|
||||
GAPI_WRAP void apply(cv::Mat in, CV_OUT cv::Scalar &out, GCompileArgs &&args = {}); // Unary overload (scalar)
|
||||
|
||||
/**
|
||||
* @brief Execute a binary computation (with compilation on the fly)
|
||||
|
@ -26,10 +26,10 @@ struct GOrigin;
|
||||
* @{
|
||||
*/
|
||||
|
||||
class GAPI_EXPORTS GScalar
|
||||
class GAPI_EXPORTS_W_SIMPLE GScalar
|
||||
{
|
||||
public:
|
||||
GScalar(); // Empty constructor
|
||||
GAPI_WRAP GScalar(); // Empty constructor
|
||||
explicit GScalar(const cv::Scalar& s); // Constant value constructor from cv::Scalar
|
||||
explicit GScalar(cv::Scalar&& s); // Constant value move-constructor from cv::Scalar
|
||||
|
||||
|
@ -38,5 +38,23 @@ class gapi_core_test(NewOpenCVTests):
|
||||
self.assertEqual(0.0, cv.norm(expected, actual, cv.NORM_INF))
|
||||
|
||||
|
||||
def test_mean(self):
|
||||
sz = (1280, 720, 3)
|
||||
in_mat = np.random.randint(0, 100, sz).astype(np.uint8)
|
||||
|
||||
# OpenCV
|
||||
expected = cv.mean(in_mat)
|
||||
|
||||
# G-API
|
||||
g_in = cv.GMat()
|
||||
g_out = cv.gapi.mean(g_in)
|
||||
comp = cv.GComputation(g_in, g_out)
|
||||
|
||||
for pkg in pkgs:
|
||||
actual = comp.apply(in_mat, args=cv.compile_args(pkg))
|
||||
# Comparison
|
||||
self.assertEqual(0.0, cv.norm(expected, actual, cv.NORM_INF))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
NewOpenCVTests.bootstrap()
|
||||
|
Loading…
Reference in New Issue
Block a user