github.com/kaydxh/golang@v0.0.131/pkg/gocv/cgo/third_path/opencv4/include/opencv2/gapi/gframe.hpp (about) 1 // This file is part of OpenCV project. 2 // It is subject to the license terms in the LICENSE file found in the top-level directory 3 // of this distribution and at http://opencv.org/license.html. 4 // 5 // Copyright (C) 2020 Intel Corporation 6 7 8 #ifndef OPENCV_GAPI_GFRAME_HPP 9 #define OPENCV_GAPI_GFRAME_HPP 10 11 #include <ostream> 12 #include <memory> // std::shared_ptr 13 14 #include <opencv2/gapi/opencv_includes.hpp> 15 #include <opencv2/gapi/gcommon.hpp> // GShape 16 17 #include <opencv2/gapi/gmat.hpp> 18 #include <opencv2/gapi/own/assert.hpp> 19 20 // TODO GAPI_EXPORTS or so 21 namespace cv 22 { 23 // Forward declaration; GNode and GOrigin are an internal 24 // (user-inaccessible) classes. 25 class GNode; 26 struct GOrigin; 27 28 /** \addtogroup gapi_data_objects 29 * @{ 30 */ 31 /** 32 * @brief GFrame class represents an image or media frame in the graph. 33 * 34 * GFrame doesn't store any data itself, instead it describes a 35 * functional relationship between operations consuming and producing 36 * GFrame objects. 37 * 38 * GFrame is introduced to handle various media formats (e.g., NV12 or 39 * I420) under the same type. Various image formats may differ in the 40 * number of planes (e.g. two for NV12, three for I420) and the pixel 41 * layout inside. GFrame type allows to handle these media formats in 42 * the graph uniformly -- the graph structure will not change if the 43 * media format changes, e.g. a different camera or decoder is used 44 * with the same graph. G-API provides a number of operations which 45 * operate directly on GFrame, like `infer<>()` or 46 * renderFrame(); these operations are expected to handle different 47 * media formats inside. There is also a number of accessor 48 * operations like BGR(), Y(), UV() -- these operations provide 49 * access to frame's data in the familiar cv::GMat form, which can be 50 * used with the majority of the existing G-API operations. These 51 * accessor functions may perform color space converion on the fly if 52 * the image format of the GFrame they are applied to differs from the 53 * operation's semantic (e.g. the BGR() accessor is called on an NV12 54 * image frame). 55 * 56 * GFrame is a virtual counterpart of cv::MediaFrame. 57 * 58 * @sa cv::MediaFrame, cv::GFrameDesc, BGR(), Y(), UV(), infer<>(). 59 */ 60 class GAPI_EXPORTS_W_SIMPLE GFrame 61 { 62 public: 63 /** 64 * @brief Constructs an empty GFrame 65 * 66 * Normally, empty G-API data objects denote a starting point of 67 * the graph. When an empty GFrame is assigned to a result of some 68 * operation, it obtains a functional link to this operation (and 69 * is not empty anymore). 70 */ 71 GAPI_WRAP GFrame(); // Empty constructor 72 73 /// @private 74 GFrame(const GNode &n, std::size_t out); // Operation result constructor 75 /// @private 76 GOrigin& priv(); // Internal use only 77 /// @private 78 const GOrigin& priv() const; // Internal use only 79 80 private: 81 std::shared_ptr<GOrigin> m_priv; 82 }; 83 /** @} */ 84 85 enum class MediaFormat: int 86 { 87 BGR = 0, 88 NV12, 89 }; 90 91 /** 92 * \addtogroup gapi_meta_args 93 * @{ 94 */ 95 struct GAPI_EXPORTS GFrameDesc 96 { 97 MediaFormat fmt; 98 cv::Size size; 99 100 bool operator== (const GFrameDesc &) const; 101 }; 102 static inline GFrameDesc empty_gframe_desc() { return GFrameDesc{}; } 103 /** @} */ 104 105 class MediaFrame; 106 GAPI_EXPORTS GFrameDesc descr_of(const MediaFrame &frame); 107 108 GAPI_EXPORTS std::ostream& operator<<(std::ostream& os, const cv::GFrameDesc &desc); 109 110 } // namespace cv 111 112 #endif // OPENCV_GAPI_GFRAME_HPP