return std::make_tuple(empty_gopaque_desc(), empty_array_desc(), empty_array_desc());
}
};
+
+ G_TYPED_KERNEL(GTranspose, <GMat(GMat)>, "org.opencv.core.transpose") {
+ static GMatDesc outMeta(GMatDesc in) {
+ return in.withSize({in.size.height, in.size.width});
+ }
+ };
} // namespace core
namespace streaming {
kmeans(const GArray<Point3f>& data, const int K, const GArray<int>& bestLabels,
const TermCriteria& criteria, const int attempts, const KmeansFlags flags);
+
+/** @brief Transposes a matrix.
+
+The function transposes the matrix:
+\f[\texttt{dst} (i,j) = \texttt{src} (j,i)\f]
+
+@note
+ - Function textual ID is "org.opencv.core.transpose"
+ - No complex conjugation is done in case of a complex matrix. It should be done separately if needed.
+
+@param src input array.
+*/
+GAPI_EXPORTS GMat transpose(const GMat& src);
+
+
namespace streaming {
/** @brief Gets dimensions from Mat.
cv::GCompileArgs>> {};
class KMeans3DPerfTest : public TestPerfParams<tuple<int, int, cv::KmeansFlags,
cv::GCompileArgs>> {};
+ class TransposePerfTest : public TestPerfParams<tuple<compare_f, cv::Size, MatType, cv::GCompileArgs>> {};
class ResizePerfTest : public TestPerfParams<tuple<compare_f, MatType, int, cv::Size, cv::Size, cv::GCompileArgs>> {};
class ResizeFxFyPerfTest : public TestPerfParams<tuple<compare_f, MatType, int, cv::Size, double, double, cv::GCompileArgs>> {};
class ParseSSDBLPerfTest : public TestPerfParams<tuple<cv::Size, float, int, cv::GCompileArgs>>, public ParserSSDTest {};
//------------------------------------------------------------------------------
+PERF_TEST_P_(TransposePerfTest, TestPerformance)
+{
+ compare_f cmpF;
+ cv::Size sz_in;
+ MatType type = -1;
+ cv::GCompileArgs compile_args;
+ std::tie(cmpF, sz_in, type, compile_args) = GetParam();
+
+ initMatrixRandU(type, sz_in, type, false);
+
+ // OpenCV code ///////////////////////////////////////////////////////////
+ cv::transpose(in_mat1, out_mat_ocv);
+
+ // G-API code ////////////////////////////////////////////////////////////
+ cv::GMat in;
+ auto out = cv::gapi::transpose(in);
+ cv::GComputation c(cv::GIn(in), cv::GOut(out));
+
+ // Warm-up graph engine:
+ c.apply(cv::gin(in_mat1), cv::gout(out_mat_gapi), std::move(compile_args));
+
+ TEST_CYCLE()
+ {
+ c.apply(cv::gin(in_mat1), cv::gout(out_mat_gapi));
+ }
+
+ // Comparison ////////////////////////////////////////////////////////////
+ {
+ EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
+ }
+
+ SANITY_CHECK_NOTHING();
+}
+
+//------------------------------------------------------------------------------
+
PERF_TEST_P_(ResizePerfTest, TestPerformance)
{
compare_f cmpF = get<0>(GetParam());
cv::KMEANS_PP_CENTERS | cv::KMEANS_USE_INITIAL_LABELS),
Values(cv::compile_args(CORE_CPU))));
+INSTANTIATE_TEST_CASE_P(TransposePerfTestCPU, TransposePerfTest,
+ Combine(Values(AbsExact().to_compare_f()),
+ Values(szSmall128, szVGA, sz720p, sz1080p),
+ Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1,
+ CV_8UC2, CV_16UC2, CV_16SC2, CV_32FC2,
+ CV_8UC3, CV_16UC3, CV_16SC3, CV_32FC3),
+ Values(cv::compile_args(CORE_CPU))));
+
INSTANTIATE_TEST_CASE_P(ResizePerfTestCPU, ResizePerfTest,
Combine(Values(AbsExact().to_compare_f()),
Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(0.0),
Values(cv::compile_args(CORE_GPU))));
+INSTANTIATE_TEST_CASE_P(TransposePerfTestGPU, TransposePerfTest,
+ Combine(Values(AbsExact().to_compare_f()),
+ Values(szSmall128, szVGA, sz720p, sz1080p),
+ Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1,
+ CV_8UC2, CV_16UC2, CV_16SC2, CV_32FC2,
+ CV_8UC3, CV_16UC3, CV_16SC3, CV_32FC3),
+ Values(cv::compile_args(CORE_GPU))));
+
INSTANTIATE_TEST_CASE_P(ResizePerfTestGPU, ResizePerfTest,
Combine(Values(AbsSimilarPoints(2, 0.05).to_compare_f()),
Values(CV_8UC1, CV_16UC1, CV_16SC1),
return core::GKMeans3D::on(data, K, bestLabels, criteria, attempts, flags);
}
+
+GMat transpose(const GMat& src)
+{
+ return core::GTranspose::on(src);
+}
+
GOpaque<Size> streaming::size(const GMat& src)
{
return streaming::GSize::on(src);
}
};
+GAPI_OCV_KERNEL(GCPUTranspose, cv::gapi::core::GTranspose)
+{
+ static void run(const cv::Mat& in, cv::Mat& out)
+ {
+ cv::transpose(in, out);
+ }
+};
+
+
GAPI_OCV_KERNEL(GCPUParseSSDBL, cv::gapi::nn::parsers::GParseSSDBL)
{
static void run(const cv::Mat& in_ssd_result,
, GCPUKMeansNDNoInit
, GCPUKMeans2D
, GCPUKMeans3D
+ , GCPUTranspose
, GCPUParseSSDBL
, GOCVParseSSD
, GCPUParseYolo
}
};
+
+GAPI_OCL_KERNEL(GOCLTranspose, cv::gapi::core::GTranspose)
+{
+ static void run(const cv::UMat& in, cv::UMat& out)
+ {
+ cv::transpose(in, out);
+ }
+};
+
cv::gapi::GKernelPackage cv::gapi::core::ocl::kernels()
{
static auto pkg = cv::gapi::kernels
, GOCLConcatVert
, GOCLLUT
, GOCLConvertTo
+ , GOCLTranspose
>();
return pkg;
}
GAPI_TEST_FIXTURE(KMeansNDTest, initMatrixRandU, FIXTURE_API(CompareMats, int, cv::KmeansFlags), 3, cmpF, K, flags)
GAPI_TEST_FIXTURE(KMeans2DTest, initNothing, FIXTURE_API(int, cv::KmeansFlags), 2, K, flags)
GAPI_TEST_FIXTURE(KMeans3DTest, initNothing, FIXTURE_API(int, cv::KmeansFlags), 2, K, flags)
+GAPI_TEST_FIXTURE(TransposeTest, initMatrixRandU, FIXTURE_API(CompareMats), 1, cmpF)
+
GAPI_TEST_EXT_BASE_FIXTURE(ParseSSDBLTest, ParserSSDTest, initNothing,
FIXTURE_API(float, int), 2, confidence_threshold, filter_label)
kmeansTestBody(in_vector, sz, type, K, flags, getCompileArgs());
}
+TEST_P(TransposeTest, Test)
+{
+ // G-API code //////////////////////////////////////////////////////////////
+ cv::GMat in;
+ auto out = cv::gapi::transpose(in);
+
+ cv::GComputation c(in, out);
+ c.apply(in_mat1, out_mat_gapi, getCompileArgs());
+ // OpenCV code /////////////////////////////////////////////////////////////
+ {
+ cv::transpose(in_mat1, out_mat_ocv);
+ }
+ // Comparison //////////////////////////////////////////////////////////////
+ {
+ EXPECT_TRUE(cmpF(out_mat_ocv, out_mat_gapi));
+ }
+}
// PLEASE DO NOT PUT NEW ACCURACY TESTS BELOW THIS POINT! //////////////////////
TEST_P(BackendOutputAllocationTest, EmptyOutput)
* @param ... list of names of user-defined parameters. if there are no parameters, the list
* must be empty.
*/
+ //TODO: Consider to remove `Number` and use `std::tuple_size<decltype(std::make_tuple(__VA_ARGS__))>::value`
#define GAPI_TEST_FIXTURE(Fixture, InitF, API, Number, ...) \
struct Fixture : public TestWithParams API { \
static_assert(Number == AllParams::specific_params_size, \
Values(cv::KMEANS_RANDOM_CENTERS | cv::KMEANS_USE_INITIAL_LABELS,
cv::KMEANS_PP_CENTERS | cv::KMEANS_USE_INITIAL_LABELS)));
+INSTANTIATE_TEST_CASE_P(TransposeTestCPU, TransposeTest,
+ Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1,
+ CV_8UC2, CV_16UC2, CV_16SC2, CV_32FC2,
+ CV_8UC3, CV_16UC3, CV_16SC3, CV_32FC3),
+ Values(cv::Size(1280, 720),
+ cv::Size(640, 480),
+ cv::Size(128, 128)),
+ Values(-1),
+ Values(CORE_CPU),
+ Values(AbsExact().to_compare_obj())));
// PLEASE DO NOT PUT NEW ACCURACY TESTS BELOW THIS POINT! //////////////////////
INSTANTIATE_TEST_CASE_P(BackendOutputAllocationTestCPU, BackendOutputAllocationTest,
Values(-1),
Values(CORE_GPU)));
+INSTANTIATE_TEST_CASE_P(TransposeTestGPU, TransposeTest,
+ Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1,
+ CV_8UC2, CV_16UC2, CV_16SC2, CV_32FC2,
+ CV_8UC3, CV_16UC3, CV_16SC3, CV_32FC3),
+ Values(cv::Size(1280, 720),
+ cv::Size(640, 480),
+ cv::Size(128, 128)),
+ Values(-1),
+ Values(CORE_GPU),
+ Values(AbsExact().to_compare_obj())));
// PLEASE DO NOT PUT NEW ACCURACY TESTS BELOW THIS POINT! //////////////////////
INSTANTIATE_TEST_CASE_P(BackendOutputAllocationTestGPU, BackendOutputAllocationTest,