@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.
* @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
* @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)
* @{
*/
-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
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()