github.com/kaydxh/golang@v0.0.131/pkg/gocv/cgo/third_path/opencv4/include/opencv2/gapi/gscalar.hpp (about)

     1  // This file is part of OpenCV project.
     2  
     3  // It is subject to the license terms in the LICENSE file found in the top-level directory
     4  // of this distribution and at http://opencv.org/license.html.
     5  //
     6  // Copyright (C) 2018 Intel Corporation
     7  
     8  
     9  #ifndef OPENCV_GAPI_GSCALAR_HPP
    10  #define OPENCV_GAPI_GSCALAR_HPP
    11  
    12  #include <ostream>
    13  
    14  #include <opencv2/gapi/opencv_includes.hpp>
    15  #include <opencv2/gapi/gcommon.hpp> // GShape
    16  #include <opencv2/gapi/util/optional.hpp>
    17  
    18  namespace cv
    19  {
    20  // Forward declaration; GNode and GOrigin are an internal
    21  // (user-inaccessible) classes.
    22  class GNode;
    23  struct GOrigin;
    24  
    25  /** \addtogroup gapi_data_objects
    26   * @{
    27   */
    28  /**
    29   * @brief GScalar class represents cv::Scalar data in the graph.
    30   *
    31   * GScalar may be associated with a cv::Scalar value, which becomes
    32   * its constant value bound in graph compile time. cv::GScalar describes a
    33   * functional relationship between operations consuming and producing
    34   * GScalar objects.
    35   *
    36   * GScalar is a virtual counterpart of cv::Scalar, which is usually used
    37   * to represent the GScalar data in G-API during the execution.
    38   *
    39   * @sa Scalar
    40   */
    41  class GAPI_EXPORTS_W_SIMPLE GScalar
    42  {
    43  public:
    44      /**
    45       * @brief Constructs an empty GScalar
    46       *
    47       * Normally, empty G-API data objects denote a starting point of
    48       * the graph. When an empty GScalar is assigned to a result of some
    49       * operation, it obtains a functional link to this operation (and
    50       * is not empty anymore).
    51       */
    52      GAPI_WRAP GScalar();
    53  
    54      /**
    55       * @brief Constructs a value-initialized GScalar
    56       *
    57       * In contrast with GMat (which can be either an explicit graph input
    58       * or a result of some operation), GScalars may have their values
    59       * be associated at graph construction time. It is useful when
    60       * some operation has a GScalar input which doesn't change during
    61       * the program execution, and is set only once. In this case,
    62       * there is no need to declare such GScalar as a graph input.
    63       *
    64       * @note The value of GScalar may be overwritten by assigning some
    65       * other GScalar to the object using `operator=` -- on the
    66       * assigment, the old GScalar value is discarded.
    67       *
    68       * @param s a cv::Scalar value to associate with this GScalar object.
    69       */
    70      explicit GScalar(const cv::Scalar& s);
    71  
    72      /**
    73       * @overload
    74       * @brief Constructs a value-initialized GScalar
    75       *
    76       * @param s a cv::Scalar value to associate with this GScalar object.
    77       */
    78      explicit GScalar(cv::Scalar&& s);       // Constant value move-constructor from cv::Scalar
    79  
    80      /**
    81       * @overload
    82       * @brief Constructs a value-initialized GScalar
    83       *
    84       * @param v0 A `double` value to associate with this GScalar. Note
    85       *  that only the first component of a four-component cv::Scalar is
    86       *  set to this value, with others remain zeros.
    87       *
    88       * This constructor overload is not marked `explicit` and can be
    89       * used in G-API expression code like this:
    90       *
    91       * @snippet modules/gapi/samples/api_ref_snippets.cpp gscalar_implicit
    92       *
    93       * Here operator+(GMat,GScalar) is used to wrap cv::gapi::addC()
    94       * and a value-initialized GScalar is created on the fly.
    95       *
    96       * @overload
    97       */
    98      GScalar(double v0);                                // Constant value constructor from double
    99  
   100      /// @private
   101      GScalar(const GNode &n, std::size_t out);          // Operation result constructor
   102      /// @private
   103      GOrigin& priv();                                   // Internal use only
   104      /// @private
   105      const GOrigin& priv()  const;                      // Internal use only
   106  
   107  private:
   108      std::shared_ptr<GOrigin> m_priv;
   109  };
   110  
   111  /** @} */
   112  
   113  /**
   114   * \addtogroup gapi_meta_args
   115   * @{
   116   */
   117  struct GAPI_EXPORTS_W_SIMPLE GScalarDesc
   118  {
   119      // NB.: right now it is empty
   120  
   121      inline bool operator== (const GScalarDesc &) const
   122      {
   123          return true; // NB: implement this method if GScalar meta appears
   124      }
   125  
   126      inline bool operator!= (const GScalarDesc &rhs) const
   127      {
   128          return !(*this == rhs);
   129      }
   130  };
   131  
   132  GAPI_EXPORTS_W inline GScalarDesc empty_scalar_desc() { return GScalarDesc(); }
   133  
   134  GAPI_EXPORTS GScalarDesc descr_of(const cv::Scalar &scalar);
   135  
   136  std::ostream& operator<<(std::ostream& os, const cv::GScalarDesc &desc);
   137  
   138  } // namespace cv
   139  
   140  #endif // OPENCV_GAPI_GSCALAR_HPP