Merge pull request #13030 from dmatveev:tutorial
* G-API: First steps with tutorial * G-API Tutorial: First iteration * G-API port of anisotropic image segmentation tutorial; * Currently works via OpenCV only; * Some new kernels have been required. * G-API Tutorial: added chapters on execution code, inspection, and profiling * G-API Tutorial: make Fluid kernel headers public For some reason, these headers were not moved to the public headers subtree during the initial development. Somehow it even worked for the existing workloads. * G-API Tutorial: Fix a couple of issues found during the work * Introduced Phase & Sqrt kernels, OCV & Fluid versions * Extended GKernelPackage to allow kernel removal & policies on include() All the above stuff needs to be tested, tests will be added later * G-API Tutorial: added chapter on running Fluid backend * G-API Tutorial: fix a number of issues in the text * G-API Tutorial - some final updates - Fixed post-merge issues after Sobel kernel renaming; - Simplified G-API code a little bit; - Put a conclusion note in text. * G-API Tutorial - fix build issues in test/perf targets Public headers were refactored but tests suites were not updated in time * G-API Tutorial: Added tests & reference docs on new kernels * Phase * Sqrt * G-API Tutorial: added link to the tutorial from the main module doc * G-API Tutorial: Added tests on new GKernelPackage functionality * G-API Tutorial: Extended InRange tests to cover 32F * G-API Tutorial: Misc fixes * Avoid building examples when gapi module is not there * Added a volatile API disclaimer to G-API root documentation page * G-API Tutorial: Fix perf tests build issue This change came from master where Fluid kernels are still used incorrectly. * G-API Tutorial: Fixed channels support in Sqrt/Phase fluid kernels Extended tests to cover this case * G-API Tutorial: Fix text problems found on team review
This commit is contained in:
committed by
Alexander Alekhin
parent
1d10d56651
commit
85fad1504a
@@ -144,6 +144,12 @@ namespace core {
|
||||
}
|
||||
};
|
||||
|
||||
G_TYPED_KERNEL(GPhase, <GMat(GMat, GMat, bool)>, "org.opencv.core.math.phase") {
|
||||
static GMatDesc outMeta(const GMatDesc &inx, const GMatDesc &, bool) {
|
||||
return inx;
|
||||
}
|
||||
};
|
||||
|
||||
G_TYPED_KERNEL(GMask, <GMat(GMat,GMat)>, "org.opencv.core.pixelwise.mask") {
|
||||
static GMatDesc outMeta(GMatDesc in, GMatDesc) {
|
||||
return in;
|
||||
@@ -447,6 +453,12 @@ namespace core {
|
||||
return rdepth < 0 ? in : in.withDepth(rdepth);
|
||||
}
|
||||
};
|
||||
|
||||
G_TYPED_KERNEL(GSqrt, <GMat(GMat)>, "org.opencv.core.math.sqrt") {
|
||||
static GMatDesc outMeta(GMatDesc in) {
|
||||
return in;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//! @addtogroup gapi_math
|
||||
@@ -738,6 +750,35 @@ in radians (which is by default), or in degrees.
|
||||
*/
|
||||
GAPI_EXPORTS std::tuple<GMat, GMat> cartToPolar(const GMat& x, const GMat& y,
|
||||
bool angleInDegrees = false);
|
||||
|
||||
/** @brief Calculates the rotation angle of 2D vectors.
|
||||
|
||||
The function cv::phase calculates the rotation angle of each 2D vector that
|
||||
is formed from the corresponding elements of x and y :
|
||||
\f[\texttt{angle} (I) = \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))\f]
|
||||
|
||||
The angle estimation accuracy is about 0.3 degrees. When x(I)=y(I)=0 ,
|
||||
the corresponding angle(I) is set to 0.
|
||||
@param x input floating-point array of x-coordinates of 2D vectors.
|
||||
@param y input array of y-coordinates of 2D vectors; it must have the
|
||||
same size and the same type as x.
|
||||
@param angleInDegrees when true, the function calculates the angle in
|
||||
degrees, otherwise, they are measured in radians.
|
||||
@return array of vector angles; it has the same size and same type as x.
|
||||
*/
|
||||
GAPI_EXPORTS GMat phase(const GMat& x, const GMat &y, bool angleInDegrees = false);
|
||||
|
||||
/** @brief Calculates a square root of array elements.
|
||||
|
||||
The function cv::gapi::sqrt calculates a square root of each input array element.
|
||||
In case of multi-channel arrays, each channel is processed
|
||||
independently. The accuracy is approximately the same as of the built-in
|
||||
std::sqrt .
|
||||
@param src input floating-point array.
|
||||
@return output array of the same size and type as src.
|
||||
*/
|
||||
GAPI_EXPORTS GMat sqrt(const GMat &src);
|
||||
|
||||
//! @} gapi_math
|
||||
//!
|
||||
//! @addtogroup gapi_pixelwise
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#ifndef OPENCV_GAPI_FLUID_CORE_HPP
|
||||
#define OPENCV_GAPI_FLUID_CORE_HPP
|
||||
|
||||
#include <opencv2/gapi/gkernel.hpp> // GKernelPackage
|
||||
#include <opencv2/gapi/own/exports.hpp> // GAPI_EXPORTS
|
||||
|
||||
namespace cv { namespace gapi { namespace core { namespace fluid {
|
||||
|
||||
GAPI_EXPORTS GKernelPackage kernels();
|
||||
|
||||
}}}}
|
||||
|
||||
#endif // OPENCV_GAPI_FLUID_CORE_HPP
|
||||
@@ -0,0 +1,20 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#ifndef OPENCV_GAPI_FLUID_IMGPROC_HPP
|
||||
#define OPENCV_GAPI_FLUID_IMGPROC_HPP
|
||||
|
||||
#include <opencv2/gapi/gkernel.hpp> // GKernelPackage
|
||||
#include <opencv2/gapi/own/exports.hpp> // GAPI_EXPORTS
|
||||
|
||||
namespace cv { namespace gapi { namespace imgproc { namespace fluid {
|
||||
|
||||
GAPI_EXPORTS GKernelPackage kernels();
|
||||
|
||||
}}}}
|
||||
|
||||
#endif // OPENCV_GAPI_FLUID_IMGPROC_HPP
|
||||
@@ -313,6 +313,9 @@ namespace gapi {
|
||||
// by API textual id.
|
||||
bool includesAPI(const std::string &id) const;
|
||||
|
||||
// Remove ALL implementations of the given API (identified by ID)
|
||||
void removeAPI(const std::string &id);
|
||||
|
||||
public:
|
||||
// Return total number of kernels (accross all backends)
|
||||
std::size_t size() const;
|
||||
@@ -331,8 +334,16 @@ namespace gapi {
|
||||
// Removes all the kernels related to the given backend
|
||||
void remove(const GBackend& backend);
|
||||
|
||||
template<typename KAPI>
|
||||
void remove()
|
||||
{
|
||||
removeAPI(KAPI::id());
|
||||
}
|
||||
|
||||
// Check if package contains ANY implementation of a kernel API
|
||||
// by API type.
|
||||
// FIXME: Rename to includes() and distinguish API/impl case by
|
||||
// statically?
|
||||
template<typename KAPI>
|
||||
bool includesAPI() const
|
||||
{
|
||||
@@ -354,11 +365,16 @@ namespace gapi {
|
||||
|
||||
// Put a new kernel implementation into package
|
||||
// FIXME: No overwrites allowed?
|
||||
template<typename KImpl> void include()
|
||||
template<typename KImpl>
|
||||
void include(const cv::unite_policy up = cv::unite_policy::KEEP)
|
||||
{
|
||||
auto backend = KImpl::backend();
|
||||
auto kernel_id = KImpl::API::id();
|
||||
auto kernel_impl = GKernelImpl{KImpl::kernel()};
|
||||
if (up == cv::unite_policy::REPLACE) removeAPI(kernel_id);
|
||||
else GAPI_Assert(up == cv::unite_policy::KEEP);
|
||||
|
||||
// Regardless of the policy, store new impl in its storage slot.
|
||||
m_backend_kernels[backend][kernel_id] = std::move(kernel_impl);
|
||||
}
|
||||
|
||||
@@ -366,8 +382,8 @@ namespace gapi {
|
||||
std::vector<GBackend> backends() const;
|
||||
|
||||
friend GAPI_EXPORTS GKernelPackage combine(const GKernelPackage &,
|
||||
const GKernelPackage &,
|
||||
const cv::unite_policy);
|
||||
const GKernelPackage &,
|
||||
const cv::unite_policy);
|
||||
};
|
||||
|
||||
template<typename... KK> GKernelPackage kernels()
|
||||
@@ -389,8 +405,8 @@ namespace gapi {
|
||||
// Return a new package based on `lhs` and `rhs`,
|
||||
// with unity policy defined by `policy`.
|
||||
GAPI_EXPORTS GKernelPackage combine(const GKernelPackage &lhs,
|
||||
const GKernelPackage &rhs,
|
||||
const cv::unite_policy policy);
|
||||
const GKernelPackage &rhs,
|
||||
const cv::unite_policy policy);
|
||||
} // namespace gapi
|
||||
|
||||
namespace detail
|
||||
|
||||
Reference in New Issue
Block a user