Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[G-API] Adding GMat operators to the standalone mode #19311

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions modules/gapi/cmake/standalone.cmake
Expand Up @@ -15,6 +15,8 @@ file(GLOB FLUID_includes "${FLUID_ROOT}/include/opencv2/*.hpp"
"${FLUID_ROOT}/include/opencv2/gapi/own/*.hpp"
"${FLUID_ROOT}/include/opencv2/gapi/fluid/*.hpp")
file(GLOB FLUID_sources "${FLUID_ROOT}/src/api/g*.cpp"
"${FLUID_ROOT}/src/api/kernels_core.cpp"
"${FLUID_ROOT}/src/api/operators.cpp"
Comment on lines +18 to +19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It bloats our standalone build .a file. Can you please measure the size before/after?

Also -- not sure if kernels_core will work in the standalone mode at all - since the dispatch thing is different when it is used in the IE preproc.

"${FLUID_ROOT}/src/api/rmat.cpp"
"${FLUID_ROOT}/src/api/media.cpp"
"${FLUID_ROOT}/src/compiler/*.cpp"
Expand Down
11 changes: 9 additions & 2 deletions modules/gapi/include/opencv2/gapi/core.hpp
Expand Up @@ -12,8 +12,6 @@

#include <utility> // std::tuple

#include <opencv2/imgproc.hpp>

#include <opencv2/gapi/gmat.hpp>
#include <opencv2/gapi/gscalar.hpp>
#include <opencv2/gapi/gkernel.hpp>
Expand Down Expand Up @@ -505,6 +503,8 @@ namespace core {
}
};


#if !defined(GAPI_STANDALONE)
G_TYPED_KERNEL(
GKMeansND,
<std::tuple<GOpaque<double>,GMat,GMat>(GMat,int,GMat,TermCriteria,int,KmeansFlags)>,
Expand Down Expand Up @@ -575,6 +575,8 @@ namespace core {
return std::make_tuple(empty_gopaque_desc(), empty_array_desc(), empty_array_desc());
}
};

#endif //!defined(GAPI_STANDALONE)
} // namespace core

namespace streaming {
Expand Down Expand Up @@ -1392,6 +1394,7 @@ CV_64F.
*/
GAPI_EXPORTS std::tuple<GMat, GMat> integral(const GMat& src, int sdepth = -1, int sqdepth = -1);

#if !defined(GAPI_STANDALONE)
/** @brief Applies a fixed-level threshold to each matrix element.

The function applies fixed-level thresholding to a single- or multiple-channel matrix.
Expand Down Expand Up @@ -1441,6 +1444,8 @@ Input and output matrices must be CV_8UC1.

@sa threshold
*/
#endif //!defined(GAPI_STANDALONE)

GAPI_EXPORTS GMat inRange(const GMat& src, const GScalar& threshLow, const GScalar& threshUp);

//! @} gapi_matrixop
Expand Down Expand Up @@ -1848,6 +1853,7 @@ GAPI_EXPORTS GMat warpAffine(const GMat& src, const Mat& M, const Size& dsize, i
int borderMode = cv::BORDER_CONSTANT, const Scalar& borderValue = Scalar());
//! @} gapi_transform

#if !defined(GAPI_STANDALONE)
/** @brief Finds centers of clusters and groups input samples around the clusters.

The function kmeans implements a k-means algorithm that finds the centers of K clusters
Expand Down Expand Up @@ -1941,6 +1947,7 @@ Gets dimensions from rectangle.
*/
GAPI_EXPORTS GOpaque<Size> size(const GOpaque<Rect>& r);
} //namespace streaming
#endif //!defined(GAPI_STANDALONE)
} //namespace gapi
} //namespace cv

Expand Down
2 changes: 2 additions & 0 deletions modules/gapi/include/opencv2/gapi/own/mat.hpp
Expand Up @@ -209,6 +209,8 @@ namespace cv { namespace gapi { namespace own {
*/
int depth() const {return CV_MAT_DEPTH(flags);}

Size size() const { return Size{rows, cols};}

/** @brief Returns the number of matrix channels.

The method returns the number of matrix channels.
Expand Down
4 changes: 4 additions & 0 deletions modules/gapi/src/api/kernels_core.cpp
Expand Up @@ -264,6 +264,7 @@ std::tuple<GMat, GMat> integral(const GMat& src, int sdepth, int sqdepth)
return core::GIntegral::on(src, sdepth, sqdepth);
}

#if !defined(GAPI_STANDALONE)
GMat threshold(const GMat& src, const GScalar& thresh, const GScalar& maxval, int type)
{
GAPI_Assert(type != cv::THRESH_TRIANGLE && type != cv::THRESH_OTSU);
Expand All @@ -275,6 +276,7 @@ std::tuple<GMat, GScalar> threshold(const GMat& src, const GScalar& maxval, int
GAPI_Assert(type == cv::THRESH_TRIANGLE || type == cv::THRESH_OTSU);
return core::GThresholdOT::on(src, maxval, type);
}
#endif //!defined(GAPI_STANDALONE)

GMat inRange(const GMat& src, const GScalar& threshLow, const GScalar& threshUp)
{
Expand Down Expand Up @@ -383,6 +385,7 @@ GMat warpAffine(const GMat& src, const Mat& M, const Size& dsize, int flags,
return core::GWarpAffine::on(src, M, dsize, flags, borderMode, borderValue);
}

#if !defined(GAPI_STANDALONE)
std::tuple<GOpaque<double>,GMat,GMat> kmeans(const GMat& data, const int K, const GMat& bestLabels,
const TermCriteria& criteria, const int attempts,
const KmeansFlags flags)
Expand Down Expand Up @@ -426,6 +429,7 @@ GOpaque<Size> streaming::size(const GOpaque<Rect>& r)
{
return streaming::GSizeR::on(r);
}
#endif //!defined(GAPI_STANDALONE)

} //namespace gapi
} //namespace cv
1 change: 0 additions & 1 deletion modules/gapi/src/api/operators.cpp
Expand Up @@ -7,7 +7,6 @@

#include "precomp.hpp"

#include <opencv2/gapi/imgproc.hpp>
#include <opencv2/gapi/core.hpp>
#include <opencv2/gapi/gscalar.hpp>
#include <opencv2/gapi/operators.hpp>
Expand Down