format.hpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #ifndef OPENCV_GAPI_GSTREAMING_FORMAT_HPP
  7. #define OPENCV_GAPI_GSTREAMING_FORMAT_HPP
  8. #include <opencv2/gapi/gkernel.hpp> // GKernelPackage
  9. namespace cv {
  10. namespace gapi {
  11. namespace streaming {
  12. GAPI_EXPORTS cv::GKernelPackage kernels();
  13. G_API_OP(GBGR, <GMat(GFrame)>, "org.opencv.streaming.BGR")
  14. {
  15. static GMatDesc outMeta(const GFrameDesc& in) { return GMatDesc{CV_8U, 3, in.size}; }
  16. };
  17. G_API_OP(GY, <GMat(GFrame)>, "org.opencv.streaming.Y") {
  18. static GMatDesc outMeta(const GFrameDesc& frameDesc) {
  19. return GMatDesc { CV_8U, 1, frameDesc.size , false };
  20. }
  21. };
  22. G_API_OP(GUV, <GMat(GFrame)>, "org.opencv.streaming.UV") {
  23. static GMatDesc outMeta(const GFrameDesc& frameDesc) {
  24. return GMatDesc { CV_8U, 2, cv::Size(frameDesc.size.width / 2, frameDesc.size.height / 2),
  25. false };
  26. }
  27. };
  28. /** @brief Gets bgr plane from input frame
  29. @note Function textual ID is "org.opencv.streaming.BGR"
  30. @param in Input frame
  31. @return Image in BGR format
  32. */
  33. GAPI_EXPORTS cv::GMat BGR(const cv::GFrame& in);
  34. /** @brief Extracts Y plane from media frame.
  35. Output image is 8-bit 1-channel image of @ref CV_8UC1.
  36. @note Function textual ID is "org.opencv.streaming.Y"
  37. @param frame input media frame.
  38. */
  39. GAPI_EXPORTS GMat Y(const cv::GFrame& frame);
  40. /** @brief Extracts UV plane from media frame.
  41. Output image is 8-bit 2-channel image of @ref CV_8UC2.
  42. @note Function textual ID is "org.opencv.streaming.UV"
  43. @param frame input media frame.
  44. */
  45. GAPI_EXPORTS GMat UV(const cv::GFrame& frame);
  46. } // namespace streaming
  47. //! @addtogroup gapi_transform
  48. //! @{
  49. /** @brief Makes a copy of the input image. Note that this copy may be not real
  50. (no actual data copied). Use this function to maintain graph contracts,
  51. e.g when graph's input needs to be passed directly to output, like in Streaming mode.
  52. @note Function textual ID is "org.opencv.streaming.copy"
  53. @param in Input image
  54. @return Copy of the input
  55. */
  56. GAPI_EXPORTS_W GMat copy(const GMat& in);
  57. /** @brief Makes a copy of the input frame. Note that this copy may be not real
  58. (no actual data copied). Use this function to maintain graph contracts,
  59. e.g when graph's input needs to be passed directly to output, like in Streaming mode.
  60. @note Function textual ID is "org.opencv.streaming.copy"
  61. @param in Input frame
  62. @return Copy of the input
  63. */
  64. GAPI_EXPORTS GFrame copy(const GFrame& in);
  65. //! @} gapi_transform
  66. } // namespace gapi
  67. } // namespace cv
  68. #endif // OPENCV_GAPI_GSTREAMING_FORMAT_HPP