fix:make zerocolor edge
This commit is contained in:
@@ -1796,7 +1796,7 @@ contains a 0-based cluster index for the \f$i^{th}\f$ sample.
|
||||
|
||||
@note
|
||||
- Function textual ID is "org.opencv.core.kmeansND"
|
||||
- In case of an N-dimensional points' set given, input GMat can have the following traits:
|
||||
- In case of an N-dimentional points' set given, input GMat can have the following traits:
|
||||
2 dimensions, a single row or column if there are N channels,
|
||||
or N columns if there is a single channel. Mat should have @ref CV_32F depth.
|
||||
- Although, if GMat with height != 1, width != 1, channels != 1 given as data, n-dimensional
|
||||
@@ -1806,7 +1806,7 @@ samples are considered given in amount of A, where A = height, n = width * chann
|
||||
width = 1, height = A, where A is samples amount, or width = bestLabels.width,
|
||||
height = bestLabels.height if bestLabels given;
|
||||
- the cluster centers are returned as 1-channel GMat with sizes
|
||||
width = n, height = K, where n is samples' dimensionality and K is clusters' amount.
|
||||
width = n, height = K, where n is samples' dimentionality and K is clusters' amount.
|
||||
- As one of possible usages, if you want to control the initial labels for each attempt
|
||||
by yourself, you can utilize just the core of the function. To do that, set the number
|
||||
of attempts to 1, initialize labels each time using a custom algorithm, pass them with the
|
||||
@@ -1814,7 +1814,7 @@ of attempts to 1, initialize labels each time using a custom algorithm, pass the
|
||||
|
||||
@param data Data for clustering. An array of N-Dimensional points with float coordinates is needed.
|
||||
Function can take GArray<Point2f>, GArray<Point3f> for 2D and 3D cases or GMat for any
|
||||
dimensionality and channels.
|
||||
dimentionality and channels.
|
||||
@param K Number of clusters to split the set by.
|
||||
@param bestLabels Optional input integer array that can store the supposed initial cluster indices
|
||||
for every sample. Used when ( flags = #KMEANS_USE_INITIAL_LABELS ) flag is set.
|
||||
|
||||
@@ -443,12 +443,7 @@ struct OCVStCallHelper<Impl, std::tuple<Ins...>, std::tuple<Outs...>> :
|
||||
template<int... IIs, int... OIs>
|
||||
static void call_impl(GCPUContext &ctx, detail::Seq<IIs...>, detail::Seq<OIs...>)
|
||||
{
|
||||
auto state_ptr = ctx.state().get<std::shared_ptr<typename Impl::State>>();
|
||||
if (state_ptr == nullptr) {
|
||||
CV_Error(cv::Error::StsNullPtr, "Stateful kernel's state is not initialized. "
|
||||
"Make sure the setup() function properly initializes the state.");
|
||||
}
|
||||
auto& st = *state_ptr;
|
||||
auto& st = *ctx.state().get<std::shared_ptr<typename Impl::State>>();
|
||||
call_and_postprocess<decltype(get_in<Ins>::get(ctx, IIs))...>
|
||||
::call(st, get_in<Ins>::get(ctx, IIs)..., get_out<Outs>::get(ctx, OIs)...);
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ struct GAPI_EXPORTS_W_SIMPLE GMatDesc
|
||||
static inline GMatDesc empty_gmat_desc() { return GMatDesc{-1,-1,{-1,-1}}; }
|
||||
|
||||
namespace gapi { namespace detail {
|
||||
/** Checks GMatDesc fields if the passed matrix is a set of n-dimensional points.
|
||||
/** Checks GMatDesc fields if the passed matrix is a set of n-dimentional points.
|
||||
@param in GMatDesc to check.
|
||||
@param n expected dimensionality.
|
||||
@return the amount of points. In case input matrix can't be described as vector of points
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace imgproc {
|
||||
GAPI_Assert (in.depth == CV_32S || in.depth == CV_32F);
|
||||
int amount = detail::checkVector(in, 2u);
|
||||
GAPI_Assert(amount != -1 &&
|
||||
"Input Mat can't be described as vector of 2-dimensional points");
|
||||
"Input Mat can't be described as vector of 2-dimentional points");
|
||||
}
|
||||
return empty_gopaque_desc();
|
||||
}
|
||||
@@ -242,7 +242,7 @@ namespace imgproc {
|
||||
static GOpaqueDesc outMeta(GMatDesc in,DistanceTypes,double,double,double) {
|
||||
int amount = detail::checkVector(in, 2u);
|
||||
GAPI_Assert(amount != -1 &&
|
||||
"Input Mat can't be described as vector of 2-dimensional points");
|
||||
"Input Mat can't be described as vector of 2-dimentional points");
|
||||
return empty_gopaque_desc();
|
||||
}
|
||||
};
|
||||
@@ -276,7 +276,7 @@ namespace imgproc {
|
||||
static GOpaqueDesc outMeta(GMatDesc in,int,double,double,double) {
|
||||
int amount = detail::checkVector(in, 3u);
|
||||
GAPI_Assert(amount != -1 &&
|
||||
"Input Mat can't be described as vector of 3-dimensional points");
|
||||
"Input Mat can't be described as vector of 3-dimentional points");
|
||||
return empty_gopaque_desc();
|
||||
}
|
||||
};
|
||||
@@ -1235,7 +1235,7 @@ weights \f$w_i\f$ are adjusted to be inversely proportional to \f$\rho(r_i)\f$ .
|
||||
|
||||
@note
|
||||
- Function textual ID is "org.opencv.imgproc.shape.fitLine2DMat"
|
||||
- In case of an N-dimensional points' set given, Mat should be 2-dimensional, have a single row
|
||||
- In case of an N-dimentional points' set given, Mat should be 2-dimensional, have a single row
|
||||
or column if there are N channels, or have N columns if there is a single channel.
|
||||
|
||||
@param src Input set of 2D points stored in one of possible containers: Mat,
|
||||
@@ -1307,7 +1307,7 @@ weights \f$w_i\f$ are adjusted to be inversely proportional to \f$\rho(r_i)\f$ .
|
||||
|
||||
@note
|
||||
- Function textual ID is "org.opencv.imgproc.shape.fitLine3DMat"
|
||||
- In case of an N-dimensional points' set given, Mat should be 2-dimensional, have a single row
|
||||
- In case of an N-dimentional points' set given, Mat should be 2-dimensional, have a single row
|
||||
or column if there are N channels, or have N columns if there is a single channel.
|
||||
|
||||
@param src Input set of 3D points stored in one of possible containers: Mat,
|
||||
|
||||
@@ -51,12 +51,6 @@ public:
|
||||
GAPI_WRAP
|
||||
PyParams& cfgDisableMemPattern();
|
||||
|
||||
GAPI_WRAP
|
||||
PyParams& cfgSessionOptions(const std::map<std::string, std::string>& options);
|
||||
|
||||
GAPI_WRAP
|
||||
PyParams& cfgOptLevel(const int opt_level);
|
||||
|
||||
GBackend backend() const;
|
||||
std::string tag() const;
|
||||
cv::util::any params() const;
|
||||
|
||||
@@ -15,12 +15,10 @@
|
||||
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
#include <opencv2/gapi/util/any.hpp>
|
||||
#include <opencv2/gapi/util/optional.hpp>
|
||||
|
||||
#include <opencv2/core/cvdef.h> // GAPI_EXPORTS
|
||||
#include <opencv2/gapi/gkernel.hpp> // GKernelPackage
|
||||
#include <opencv2/gapi/infer.hpp> // Generic
|
||||
#include <opencv2/gapi/infer/workload_type.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
@@ -353,10 +351,8 @@ struct ParamDesc {
|
||||
std::unordered_map<std::string, std::pair<cv::Scalar, cv::Scalar> > generic_mstd;
|
||||
std::unordered_map<std::string, bool> generic_norm;
|
||||
|
||||
std::map<std::string, std::string> session_options;
|
||||
std::vector<cv::gapi::onnx::ep::EP> execution_providers;
|
||||
bool disable_mem_pattern;
|
||||
cv::util::optional<int> opt_level;
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
@@ -638,30 +634,6 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Configures session options for ONNX Runtime.
|
||||
|
||||
This function is used to set various session options for the ONNX Runtime
|
||||
session by accepting a map of key-value pairs.
|
||||
|
||||
@param options A map of session option to be applied to the ONNX Runtime session.
|
||||
@return the reference on modified object.
|
||||
*/
|
||||
Params<Net>& cfgSessionOptions(const std::map<std::string, std::string>& options) {
|
||||
desc.session_options.insert(options.begin(), options.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Configures optimization level for ONNX Runtime.
|
||||
|
||||
@param opt_level [optimization level]: Valid values are 0 (disable), 1 (basic), 2 (extended), 99 (all).
|
||||
Please see onnxruntime_c_api.h (enum GraphOptimizationLevel) for the full list of all optimization levels.
|
||||
@return the reference on modified object.
|
||||
*/
|
||||
Params<Net>& cfgOptLevel(const int opt_level) {
|
||||
desc.opt_level = cv::util::make_optional(opt_level);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// BEGIN(G-API's network parametrization API)
|
||||
GBackend backend() const { return cv::gapi::onnx::backend(); }
|
||||
std::string tag() const { return Net::tag(); }
|
||||
@@ -689,7 +661,7 @@ public:
|
||||
@param model_path path to model file (.onnx file).
|
||||
*/
|
||||
Params(const std::string& tag, const std::string& model_path)
|
||||
: desc{ model_path, 0u, 0u, {}, {}, {}, {}, {}, {}, {}, {}, {}, true, {}, {}, {}, {}, false, {} }, m_tag(tag) {}
|
||||
: desc{model_path, 0u, 0u, {}, {}, {}, {}, {}, {}, {}, {}, {}, true, {}, {}, {}, false }, m_tag(tag) {}
|
||||
|
||||
/** @see onnx::Params::cfgMeanStdDev. */
|
||||
void cfgMeanStdDev(const std::string &layer,
|
||||
@@ -733,16 +705,6 @@ public:
|
||||
desc.disable_mem_pattern = true;
|
||||
}
|
||||
|
||||
/** @see onnx::Params::cfgSessionOptions. */
|
||||
void cfgSessionOptions(const std::map<std::string, std::string>& options) {
|
||||
desc.session_options.insert(options.begin(), options.end());
|
||||
}
|
||||
|
||||
/** @see onnx::Params::cfgOptLevel. */
|
||||
void cfgOptLevel(const int opt_level) {
|
||||
desc.opt_level = cv::util::make_optional(opt_level);
|
||||
}
|
||||
|
||||
// BEGIN(G-API's network parametrization API)
|
||||
GBackend backend() const { return cv::gapi::onnx::backend(); }
|
||||
std::string tag() const { return m_tag; }
|
||||
@@ -753,16 +715,8 @@ protected:
|
||||
std::string m_tag;
|
||||
};
|
||||
|
||||
class WorkloadTypeONNX : public WorkloadType {};
|
||||
using WorkloadTypeONNXPtr = std::shared_ptr<cv::gapi::onnx::WorkloadTypeONNX>;
|
||||
|
||||
} // namespace onnx
|
||||
} // namespace gapi
|
||||
namespace detail {
|
||||
template<> struct CompileArgTag<cv::gapi::onnx::WorkloadTypeONNXPtr> {
|
||||
static const char* tag() { return "gapi.onnx.workload_type"; }
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_GAPI_INFER_HPP
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <opencv2/gapi/own/exports.hpp> // GAPI_EXPORTS
|
||||
#include <opencv2/gapi/gkernel.hpp> // GKernelType[M], GBackend
|
||||
#include <opencv2/gapi/infer.hpp> // Generic
|
||||
#include <opencv2/gapi/infer/workload_type.hpp>
|
||||
|
||||
#include <map>
|
||||
|
||||
@@ -67,8 +66,6 @@ struct ParamDesc {
|
||||
LayerVariantAttr<std::vector<float>> scale_values;
|
||||
|
||||
LayerVariantAttr<int> interpolation;
|
||||
|
||||
bool clamp_outputs = false;
|
||||
};
|
||||
|
||||
struct CompiledModel {
|
||||
@@ -102,8 +99,6 @@ struct ParamDesc {
|
||||
PluginConfigT config;
|
||||
|
||||
size_t nireq = 1;
|
||||
|
||||
bool ensure_named_tensors = false;
|
||||
};
|
||||
|
||||
// NB: Just helper to avoid code duplication.
|
||||
@@ -210,24 +205,6 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Ensures the model has named tensors.
|
||||
|
||||
This function is used to ensure that all tensors in the model have names.
|
||||
It goes through all input and output nodes of the model and sets the names
|
||||
if they are not set. This is neccessary for models with nameless tensors.
|
||||
|
||||
If a tensor does not have a name, it will be assigned a default name
|
||||
based on the producer node's friendly name. If the producer node has multiple
|
||||
outputs, the name will be in the form "node_name:N", where N is the output index.
|
||||
|
||||
@param flag If true, then it guarantees that all tensors will have names.
|
||||
@return reference to this parameter structure.
|
||||
*/
|
||||
Params<Net>& cfgEnsureNamedTensors(bool flag = true) {
|
||||
m_desc.ensure_named_tensors = flag;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Specifies tensor layout for an input layer.
|
||||
|
||||
The function is used to set tensor layout for an input layer.
|
||||
@@ -359,24 +336,6 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Enables or disables clamping of model outputs in the PrePostProcessor.
|
||||
|
||||
By default, output values are clamped to the valid range for the output precision
|
||||
by the device or plugin. Enabling this option moves clamping to the PrePostProcessor stage.
|
||||
|
||||
@note This feature is only available with OpenVINO 2025.2 and newer.
|
||||
|
||||
@param flag If true, clamping is performed in the PrePostProcessor;
|
||||
otherwise, it is handled by the device or plugin.
|
||||
@return reference to this parameter structure.
|
||||
*/
|
||||
Params<Net>&
|
||||
cfgClampOutputs(bool flag = true) {
|
||||
detail::getModelToSetAttrOrThrow(m_desc.kind, "clamp outputs")
|
||||
.clamp_outputs = std::move(flag);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Specifies the new shape for input layers.
|
||||
|
||||
The function is used to set new shape for input layers.
|
||||
@@ -565,12 +524,6 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @see ov::Params::cfgEnsureNamedTensors. */
|
||||
Params& cfgEnsureNamedTensors(bool flag = true) {
|
||||
m_desc.ensure_named_tensors = flag;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @see ov::Params::cfgInputTensorLayout. */
|
||||
Params& cfgInputTensorLayout(std::string layout) {
|
||||
detail::getModelToSetAttrOrThrow(m_desc.kind, "input tensor layout")
|
||||
@@ -646,14 +599,6 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @see ov::Params::cfgClampOutputs. */
|
||||
Params&
|
||||
cfgClampOutputs(bool flag = true) {
|
||||
detail::getModelToSetAttrOrThrow(m_desc.kind, "clamp outputs")
|
||||
.clamp_outputs = std::move(flag);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @see ov::Params::cfgReshape. */
|
||||
Params& cfgReshape(std::vector<size_t> new_shape) {
|
||||
detail::getModelToSetAttrOrThrow(m_desc.kind, "reshape")
|
||||
@@ -746,9 +691,6 @@ namespace wip { namespace ov {
|
||||
*/
|
||||
struct benchmark_mode { };
|
||||
|
||||
class WorkloadTypeOV : public WorkloadType {};
|
||||
using WorkloadTypeOVPtr = std::shared_ptr<cv::gapi::wip::ov::WorkloadTypeOV>;
|
||||
|
||||
} // namespace ov
|
||||
} // namespace wip
|
||||
|
||||
@@ -760,10 +702,6 @@ namespace detail
|
||||
{
|
||||
static const char* tag() { return "gapi.wip.ov.benchmark_mode"; }
|
||||
};
|
||||
template<> struct CompileArgTag<cv::gapi::wip::ov::WorkloadTypeOVPtr>
|
||||
{
|
||||
static const char* tag() { return "gapi.wip.ov.workload_type"; }
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace cv
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
// 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) 2025 Intel Corporation
|
||||
|
||||
#ifndef OPENCV_WORKLOADTYPE_HPP
|
||||
#define OPENCV_WORKLOADTYPE_HPP
|
||||
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
using Callback = std::function<void(const std::string &type)>;
|
||||
|
||||
class WorkloadListener {
|
||||
Callback callback;
|
||||
public:
|
||||
uint64_t id;
|
||||
WorkloadListener(const Callback &cb, uint64_t listener_id) : callback(cb), id(listener_id) {}
|
||||
|
||||
void operator()(const std::string &type) const {
|
||||
if (callback) {
|
||||
callback(type);
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const WorkloadListener& other) const {
|
||||
return id == other.id;
|
||||
}
|
||||
};
|
||||
|
||||
class WorkloadType {
|
||||
std::vector<WorkloadListener> listeners;
|
||||
uint64_t nextId = 1;
|
||||
public:
|
||||
uint64_t addListener(const Callback &cb) {
|
||||
uint64_t id = nextId++;
|
||||
listeners.emplace_back(cb, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void removeListener(uint64_t id) {
|
||||
auto it = std::remove_if(listeners.begin(), listeners.end(),
|
||||
[id](const WorkloadListener& entry) { return entry.id == id; });
|
||||
if (it != listeners.end()) {
|
||||
listeners.erase(it, listeners.end());
|
||||
}
|
||||
}
|
||||
|
||||
void set(const std::string &type) {
|
||||
for (const auto &listener : listeners) {
|
||||
listener(type);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif // OPENCV_WORKLOADTYPE_HPP
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <opencv2/core/base.hpp>
|
||||
#define GAPI_Assert CV_Assert
|
||||
|
||||
#if !defined(NDEBUG) || defined(CV_STATIC_ANALYSIS)
|
||||
#if defined _DEBUG || defined CV_STATIC_ANALYSIS
|
||||
# define GAPI_DbgAssert CV_DbgAssert
|
||||
#else
|
||||
# define GAPI_DbgAssert(expr) GAPI_DbgAssertNoOp(expr)
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
#ifndef OPENCV_GAPI_PYSRC_PYTHONSTREAMSOURCE_HPP
|
||||
#define OPENCV_GAPI_PYSRC_PYTHONSTREAMSOURCE_HPP
|
||||
#include <opencv2/gapi/streaming/source.hpp>
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
|
||||
/**
|
||||
* @brief Creates a G-API IStreamSource that delegates to a Python-defined source.
|
||||
*
|
||||
* This factory function wraps a Python object (for example, an instance of a class
|
||||
* implementing a `pull()` and a `descr_of()` method) into a `cv::gapi::wip::IStreamSource`,
|
||||
* enabling it to be used within a G-API computation graph. The OpenCV Python bindings
|
||||
* automatically convert the PyObject into a `cv::Ptr<IStreamSource>`.
|
||||
*
|
||||
* @param src
|
||||
* A `cv::Ptr<IStreamSource>` that internally holds the original Python object.
|
||||
*
|
||||
* @return
|
||||
* A `cv::Ptr<IStreamSource>` that wraps the provided Python object. On each frame pull,
|
||||
* G-API will:
|
||||
* - Acquire the Python GIL
|
||||
* - Call the Python object’s `pull()` method
|
||||
* - Convert the resulting NumPy array to a `cv::Mat`
|
||||
* - Pass the `cv::Mat` into the G-API pipeline
|
||||
*
|
||||
* @note
|
||||
* In Python, you can use the returned `make_py_src` as follows:
|
||||
*
|
||||
* @code{.py}
|
||||
* class MyClass:
|
||||
* def __init__(self):
|
||||
* # Initialize your source
|
||||
* def pull(self):
|
||||
* # Return the next frame as a numpy.ndarray or None for end-of-stream
|
||||
* def descr_of(self):
|
||||
* # Return a numpy.ndarray that describes the format of the frames
|
||||
*
|
||||
* # Create a G-API source from a Python class
|
||||
* py_src = cv.gapi.wip.make_py_src(MyClass())
|
||||
*
|
||||
* # Define a simple graph: input → copy → output
|
||||
* g_in = cv.GMat()
|
||||
* g_out = cv.gapi.copy(g_in)
|
||||
* graph = cv.GComputation(g_in, g_out)
|
||||
*
|
||||
* # Compile the pipeline for streaming and assign the source
|
||||
* pipeline = graph.compileStreaming()
|
||||
* pipeline.setSource([py_src])
|
||||
* pipeline.start()
|
||||
* @endcode
|
||||
*/
|
||||
|
||||
CV_EXPORTS_W cv::Ptr<cv::gapi::wip::IStreamSource>
|
||||
make_py_src(const cv::Ptr<cv::gapi::wip::IStreamSource>& src);
|
||||
|
||||
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
|
||||
#endif // OPENCV_GAPI_PYSRC_PYTHONSTREAMSOURCE_HPP
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
// disable MSVC warning on "multiple copy constructors specified"
|
||||
#pragma warning(push)
|
||||
# pragma warning(disable: 4521)
|
||||
#endif
|
||||
|
||||
@@ -185,7 +184,7 @@ namespace util
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
// Enable "multiple copy constructors specified" back
|
||||
# pragma warning(pop)
|
||||
# pragma warning(default: 4521)
|
||||
#endif
|
||||
|
||||
#endif // OPENCV_GAPI_UTIL_ANY_HPP
|
||||
|
||||
Reference in New Issue
Block a user