}
};
+ G_TYPED_KERNEL(GCopy, <GMat(GMat)>, "org.opencv.core.transform.copy") {
+ static GMatDesc outMeta(GMatDesc in) {
+ return in;
+ }
+ };
+
G_TYPED_KERNEL(GConcatHor, <GMat(GMat, GMat)>, "org.opencv.imgproc.transform.concatHor") {
static GMatDesc outMeta(GMatDesc l, GMatDesc r) {
return l.withSizeDelta(+r.size.width, 0);
*/
GAPI_EXPORTS GMat crop(const GMat& src, const Rect& rect);
+/** @brief Copies a 2D matrix.
+
+The function copies the matrix.
+
+Output matrix must be of the same size and depth as input one.
+
+@note Function textual ID is "org.opencv.core.transform.copy"
+
+@param src input matrix.
+@sa crop
+*/
+GAPI_EXPORTS GMat copy(const GMat& src);
+
/** @brief Applies horizontal concatenation to given matrices.
The function horizontally concatenates two GMat matrices (with the same number of rows).
return core::GCrop::on(src, rect);
}
+GMat copy(const GMat& src)
+{
+ return core::GCopy::on(src);
+}
+
GMat concatHor(const GMat& src1, const GMat& src2)
{
return core::GConcatHor::on(src1, src2);
}
};
+GAPI_OCV_KERNEL(GCPUCopy, cv::gapi::core::GCopy)
+{
+ static void run(const cv::Mat& in, cv::Mat& out)
+ {
+ cv::Mat(in).copyTo(out);
+ }
+};
+
GAPI_OCV_KERNEL(GCPUConcatHor, cv::gapi::core::GConcatHor)
{
static void run(const cv::Mat& in1, const cv::Mat& in2, cv::Mat& out)
, GCPURemap
, GCPUFlip
, GCPUCrop
+ , GCPUCopy
, GCPUConcatHor
, GCPUConcatVert
, GCPULUT
}
};
+GAPI_FLUID_KERNEL(GFluidCopy, cv::gapi::core::GCopy, false)
+{
+ static const int Window = 1;
+
+ static void run(const View &src, Buffer &dst)
+ {
+ const auto *in = src.InLine<uchar>(0);
+ auto *out = dst.OutLine<uchar>();
+
+ GAPI_DbgAssert(dst.length() == src.length());
+ GAPI_DbgAssert(dst.meta().chan == src.meta().chan);
+ GAPI_DbgAssert(dst.meta().depth == src.meta().depth);
+
+ int width = src.length();
+ int elem_size = CV_ELEM_SIZE(CV_MAKETYPE(src.meta().depth, src.meta().chan));
+
+ int w = 0; // cycle counter
+
+ #if CV_SIMD128
+ for (; w <= width*elem_size-16; w+=16)
+ {
+ v_uint8x16 a;
+ a = v_load(&in[w]);
+ v_store(&out[w], a);
+ }
+ #endif
+
+ for (; w < width*elem_size; w++)
+ {
+ out[w] = in[w];
+ }
+ }
+};
+
} // namespace fliud
} // namespace gapi
} // namespace cv
,GFluidInRange
,GFluidResize
,GFluidSqrt
+ ,GFluidCopy
#if 0
,GFluidMean -- not fluid
,GFluidSum -- not fluid
}
};
+GAPI_OCL_KERNEL(GOCLCopy, cv::gapi::core::GCopy)
+{
+ static void run(const cv::UMat& in, cv::UMat& out)
+ {
+ cv::UMat(in).copyTo(out);
+ }
+};
+
GAPI_OCL_KERNEL(GOCLConcatHor, cv::gapi::core::GConcatHor)
{
static void run(const cv::UMat& in1, const cv::UMat& in2, cv::UMat& out)
, GOCLRemap
, GOCLFlip
, GOCLCrop
+ , GOCLCopy
, GOCLConcatHor
, GOCLConcatVert
, GOCLLUT
GAPI_TEST_FIXTURE(RemapTest, initMatrixRandU, <>, 0)
GAPI_TEST_FIXTURE(FlipTest, initMatrixRandU, FIXTURE_API(int), 1, flipCode)
GAPI_TEST_FIXTURE(CropTest, initMatrixRandU, FIXTURE_API(cv::Rect), 1, rect_to)
+GAPI_TEST_FIXTURE(CopyTest, initMatrixRandU, <>, 0)
GAPI_TEST_FIXTURE(ConcatHorTest, initNothing, <>, 0)
GAPI_TEST_FIXTURE(ConcatVertTest, initNothing, <>, 0)
GAPI_TEST_FIXTURE(ConcatVertVecTest, initNothing, <>, 0)
}
}
+TEST_P(CopyTest, AccuracyTest)
+{
+ cv::Size sz_out = sz;
+ if (dtype != -1)
+ {
+ out_mat_gapi = cv::Mat(sz_out, dtype);
+ out_mat_ocv = cv::Mat(sz_out, dtype);
+ }
+
+ // G-API code //////////////////////////////////////////////////////////////
+ cv::GMat in;
+ auto out = cv::gapi::copy(in);
+
+ cv::GComputation c(in, out);
+ c.apply(in_mat1, out_mat_gapi, getCompileArgs());
+ // OpenCV code /////////////////////////////////////////////////////////////
+ {
+ cv::Mat(in_mat1).copyTo(out_mat_ocv);
+ }
+ // Comparison //////////////////////////////////////////////////////////////
+ {
+ EXPECT_EQ(0, cv::countNonZero(out_mat_ocv != out_mat_gapi));
+ EXPECT_EQ(out_mat_gapi.size(), sz_out);
+ }
+}
+
TEST_P(ConcatHorTest, AccuracyTest)
{
cv::Size sz_out = sz;
Values(CORE_CPU),
Values(cv::Rect(10, 8, 20, 35), cv::Rect(4, 10, 37, 50))));
+INSTANTIATE_TEST_CASE_P(CopyTestCPU, CopyTest,
+ Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
+ Values(cv::Size(1280, 720),
+ cv::Size(640, 480),
+ cv::Size(128, 128)),
+ Values(-1),
+ Values(CORE_CPU)));
+
INSTANTIATE_TEST_CASE_P(LUTTestCPU, LUTTest,
Combine(Values(CV_8UC1, CV_8UC3),
Values(cv::Size(1280, 720),
Values(cv::Size(640, 400),
cv::Size(10, 480))));
+INSTANTIATE_TEST_CASE_P(CopyTestFluid, CopyTest,
+ Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
+ Values(cv::Size(1280, 720),
+ cv::Size(640, 480),
+ cv::Size(128, 128)),
+ Values(-1),
+ Values(CORE_FLUID)));
+
//----------------------------------------------------------------------
// FIXME: Clean-up test configurations which are enabled already
#if 0
Values(CORE_GPU),
Values(cv::Rect(10, 8, 20, 35), cv::Rect(4, 10, 37, 50))));
+INSTANTIATE_TEST_CASE_P(CopyTestGPU, CopyTest,
+ Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
+ Values(cv::Size(1280, 720),
+ cv::Size(640, 480),
+ cv::Size(128, 128)),
+ Values(-1),
+ Values(CORE_GPU)));
+
INSTANTIATE_TEST_CASE_P(LUTTestGPU, LUTTest,
Combine(Values(CV_8UC1, CV_8UC3),
Values(cv::Size(1280, 720),