mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
Merge pull request #18451 from OrestChura:oc/count_non_zero
[G-API]: countNonZero() Standard Kernel Implementation * Add countNonZero() standard kernel - API and documentation provided - OCV backend supported - accuracy and performance tests provided - some refactoring of related documentation done * Fix GOpaque functionality for OCL Backend - test for OCL Opaque usage providied * countNonZero for GPU - OCL Backend implementation for countNonZero() added - tests provided * Addressing comments
This commit is contained in:
@@ -63,6 +63,14 @@ GAPI_OCV_KERNEL(OCVGeneratePoint, ThisTest::GeneratePoint)
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCL_KERNEL(OCLGeneratePoint, ThisTest::GeneratePoint)
|
||||
{
|
||||
static void run(const cv::UMat&, cv::Point& out)
|
||||
{
|
||||
out = cv::Point(42, 42);
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCV_KERNEL(OCVFillMat, ThisTest::FillMat)
|
||||
{
|
||||
static void run(int a, int, int, cv::Size, cv::Mat& out)
|
||||
@@ -79,6 +87,16 @@ GAPI_OCV_KERNEL(OCVPaintPoint, ThisTest::PaintPoint)
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCL_KERNEL(OCLPaintPoint, ThisTest::PaintPoint)
|
||||
{
|
||||
static void run(cv::Point a, int depth, int chan, cv::Size size, cv::UMat& out)
|
||||
{
|
||||
GAPI_Assert(chan == 1);
|
||||
out.create(size, CV_MAKETYPE(depth, chan));
|
||||
cv::drawMarker(out, a, cv::Scalar(77));
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCV_KERNEL(OCVGenerateOpaque, ThisTest::GenerateOpaque)
|
||||
{
|
||||
static void run(const cv::Mat& a, const cv::Mat& b, const std::string& s,
|
||||
@@ -189,6 +207,57 @@ TEST(GOpaque, TestOpaqueCustomOut2)
|
||||
EXPECT_EQ(out2.s, str2);
|
||||
}
|
||||
|
||||
TEST(GOpaque, TestOpaqueOCLBackendIn)
|
||||
{
|
||||
cv::Point p_in = {42, 42};
|
||||
cv::Mat mat_out;
|
||||
|
||||
ThisTest::GPointOpaque in;
|
||||
cv::GMat out = ThisTest::PaintPoint::on(in, CV_8U, 1, {50, 50});
|
||||
|
||||
cv::GComputation c(cv::GIn(in), cv::GOut(out));
|
||||
c.apply(cv::gin(p_in), cv::gout(mat_out),
|
||||
cv::compile_args(cv::gapi::kernels<OCLPaintPoint>()));
|
||||
|
||||
int painted = mat_out.at<uint8_t>(42, 42);
|
||||
EXPECT_EQ(painted, 77);
|
||||
}
|
||||
|
||||
TEST(GOpaque, TestOpaqueOCLBackendBetween)
|
||||
{
|
||||
cv::Size sz = {50, 50};
|
||||
int depth = CV_8U;
|
||||
int chan = 1;
|
||||
cv::Mat mat_in = cv::Mat::zeros(sz, CV_MAKETYPE(depth, chan));
|
||||
cv::Mat mat_out;
|
||||
|
||||
cv::GMat in;
|
||||
auto betw = ThisTest::GeneratePoint::on(in);
|
||||
cv::GMat out = ThisTest::PaintPoint::on(betw, depth, chan, sz);
|
||||
|
||||
cv::GComputation c(cv::GIn(in), cv::GOut(out));
|
||||
c.apply(cv::gin(mat_in), cv::gout(mat_out),
|
||||
cv::compile_args(cv::gapi::kernels<OCLGeneratePoint, OCLPaintPoint>()));
|
||||
|
||||
int painted = mat_out.at<uint8_t>(42, 42);
|
||||
EXPECT_EQ(painted, 77);
|
||||
}
|
||||
|
||||
TEST(GOpaque, TestOpaqueOCLBackendOut)
|
||||
{
|
||||
cv::Mat input = cv::Mat(52, 52, CV_8U);
|
||||
cv::Point p_out;
|
||||
|
||||
cv::GMat in;
|
||||
ThisTest::GPointOpaque out = ThisTest::GeneratePoint::on(in);
|
||||
|
||||
cv::GComputation c(cv::GIn(in), cv::GOut(out));
|
||||
c.apply(cv::gin(input), cv::gout(p_out),
|
||||
cv::compile_args(cv::gapi::kernels<OCLGeneratePoint>()));
|
||||
|
||||
EXPECT_TRUE(p_out == cv::Point(42, 42));
|
||||
}
|
||||
|
||||
TEST(GOpaque_OpaqueRef, TestMov)
|
||||
{
|
||||
// Warning: this test is testing some not-very-public APIs
|
||||
|
||||
Reference in New Issue
Block a user