checker_model.hpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. * MIT License
  6. *
  7. * Copyright (c) 2018 Pedro Diamel Marrero Fernández
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documentation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in all
  17. * copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  25. * SOFTWARE.
  26. */
  27. #ifndef __OPENCV_MCC_CHECKER_MODEL_HPP__
  28. #define __OPENCV_MCC_CHECKER_MODEL_HPP__
  29. #include <opencv2/core.hpp>
  30. #include <opencv2/imgproc.hpp>
  31. namespace cv
  32. {
  33. namespace mcc
  34. {
  35. //! @addtogroup mcc
  36. //! @{
  37. /** TYPECHART
  38. *
  39. * \brief enum to hold the type of the checker
  40. *
  41. */
  42. enum TYPECHART
  43. {
  44. MCC24 = 0, ///< Standard Macbeth Chart with 24 squares
  45. SG140, ///< DigitalSG with 140 squares
  46. VINYL18, ///< DKK color chart with 12 squares and 6 rectangle
  47. };
  48. /** CChecker
  49. *
  50. * \brief checker object
  51. *
  52. * This class contains the information about the detected checkers,i.e, their
  53. * type, the corners of the chart, the color profile, the cost, centers chart,
  54. * etc.
  55. *
  56. */
  57. class CV_EXPORTS_W CChecker
  58. {
  59. public:
  60. CChecker() {}
  61. virtual ~CChecker() {}
  62. /** \brief Create a new CChecker object.
  63. * \return A pointer to the implementation of the CChecker
  64. */
  65. CV_WRAP static Ptr<CChecker> create();
  66. public:
  67. // CV_PROP_RW TYPECHART target; ///< type of checkercolor
  68. // CV_PROP_RW std::vector<cv::Point2f> box; ///< positions of the corners
  69. // CV_PROP_RW cv::Mat charts_rgb; ///< charts profile in rgb color space
  70. // CV_PROP_RW cv::Mat charts_ycbcr; ///< charts profile in YCbCr color space
  71. // CV_PROP_RW float cost; ///< cost to aproximate
  72. // CV_PROP_RW cv::Point2f center; ///< center of the chart.
  73. CV_WRAP virtual void setTarget(TYPECHART _target) = 0;
  74. CV_WRAP virtual void setBox(std::vector<Point2f> _box) = 0;
  75. CV_WRAP virtual void setChartsRGB(Mat _chartsRGB) = 0;
  76. CV_WRAP virtual void setChartsYCbCr(Mat _chartsYCbCr) = 0;
  77. CV_WRAP virtual void setCost(float _cost) = 0;
  78. CV_WRAP virtual void setCenter(Point2f _center) = 0;
  79. CV_WRAP virtual TYPECHART getTarget() = 0;
  80. CV_WRAP virtual std::vector<Point2f> getBox() = 0;
  81. CV_WRAP virtual Mat getChartsRGB() = 0;
  82. CV_WRAP virtual Mat getChartsYCbCr() = 0;
  83. CV_WRAP virtual float getCost() = 0;
  84. CV_WRAP virtual Point2f getCenter() = 0;
  85. };
  86. /** \brief checker draw
  87. *
  88. * This class contains the functions for drawing a detected chart. This class
  89. * expects a pointer to the checker which will be drawn by this object in the
  90. * constructor and then later on whenever the draw function is called the
  91. * checker will be drawn. Remember that it is not possible to change the
  92. * checkers which will be draw by a given object, as it is decided in the
  93. * constructor itself. If you want to draw some other object you can create a
  94. * new CCheckerDraw instance.
  95. *
  96. * The reason for this type of design is that in some videos we can assume that
  97. * the checker is always in the same position, even if the image changes, so
  98. * the drawing will always take place at the same position.
  99. */
  100. class CV_EXPORTS_W CCheckerDraw
  101. {
  102. public:
  103. virtual ~CCheckerDraw() {}
  104. /** \brief Draws the checker to the given image.
  105. * \param img image in color space BGR
  106. * \return void
  107. */
  108. CV_WRAP virtual void draw(InputOutputArray img) = 0;
  109. /** \brief Create a new CCheckerDraw object.
  110. * \param pChecker The checker which will be drawn by this object.
  111. * \param color The color by with which the squares of the checker
  112. * will be drawn
  113. * \param thickness The thickness with which the sqaures will be
  114. * drawn
  115. * \return A pointer to the implementation of the CCheckerDraw
  116. */
  117. CV_WRAP static Ptr<CCheckerDraw> create(Ptr<CChecker> pChecker,
  118. cv::Scalar color = CV_RGB(0, 250, 0),
  119. int thickness = 2);
  120. };
  121. //! @} mcc
  122. } // namespace mcc
  123. } // namespace cv
  124. #endif