scalar.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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) 2018 Intel Corporation
  6. #ifndef OPENCV_GAPI_GAPI_OWN_SCALAR_HPP
  7. #define OPENCV_GAPI_GAPI_OWN_SCALAR_HPP
  8. #include <opencv2/gapi/own/exports.hpp>
  9. namespace cv
  10. {
  11. namespace gapi
  12. {
  13. namespace own
  14. {
  15. class GAPI_EXPORTS Scalar
  16. {
  17. public:
  18. Scalar() = default;
  19. explicit Scalar(double v0) { val[0] = v0; };
  20. Scalar(double v0, double v1, double v2 = 0, double v3 = 0)
  21. : val{v0, v1, v2, v3}
  22. {
  23. }
  24. const double& operator[](int i) const { return val[i]; }
  25. double& operator[](int i) { return val[i]; }
  26. static Scalar all(double v0) { return Scalar(v0, v0, v0, v0); }
  27. double val[4] = {0};
  28. };
  29. inline bool operator==(const Scalar& lhs, const Scalar& rhs)
  30. {
  31. return std::equal(std::begin(lhs.val), std::end(lhs.val), std::begin(rhs.val));
  32. }
  33. } // namespace own
  34. } // namespace gapi
  35. } // namespace cv
  36. #endif // OPENCV_GAPI_GAPI_OWN_SCALAR_HPP