No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

camera.h 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Copyright (C) 2018 dimercur
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef __CAMERA_H__
  18. #define __CAMERA_H__
  19. #include <opencv2/highgui/highgui.hpp>
  20. #include <opencv2/imgproc/imgproc.hpp>
  21. #ifndef __FOR_PC__
  22. #include "raspicam/raspicam_cv.h"
  23. #endif /* __FOR_PC__ */
  24. #include "img.h"
  25. /**
  26. * Enumerate for picture size
  27. */
  28. enum captureSize {xs, sm, md, lg};
  29. /**
  30. * Class for camera (image grab)
  31. *
  32. * @brief Class for camera (image grab)
  33. */
  34. class Camera {
  35. public:
  36. /**
  37. * Create an object for accessing camera
  38. * @param size Size of picture to grab (@see captureSize)
  39. * @param fps speed of sampling
  40. */
  41. Camera(int size, int fps);
  42. /**
  43. * Open camera
  44. * @return True if camera is open, false otherwise
  45. */
  46. bool Open();
  47. /**
  48. * Close and release camera
  49. */
  50. void Close();
  51. /**
  52. * Get width of sampled image
  53. * @return Width of sampled picture
  54. */
  55. int GetWidth() const;
  56. /**
  57. * Get height of sampled image
  58. * @return height of sampled picture
  59. */
  60. int GetHeight() const;
  61. /**
  62. * Get opening status for camera
  63. * @return true if camera is open, false otherwise
  64. */
  65. bool IsOpen();
  66. /**
  67. * Define size for sampled picture
  68. * @param size Size of picture (@see captureSize)
  69. */
  70. void SetSize(int size);
  71. /**
  72. * Grab next image from camera
  73. * @return Image taken from camera
  74. */
  75. Img Grab();
  76. private:
  77. #ifdef __FOR_PC__
  78. /**
  79. * Camera descriptor
  80. */
  81. cv::VideoCapture cap;
  82. #else
  83. raspicam::RaspiCam_Cv cap;
  84. #endif /* __FOR_PC__ */
  85. /**
  86. * Size for image (default= small)
  87. */
  88. int size = sm;
  89. /**
  90. * Width of image
  91. */
  92. int width;
  93. /**
  94. * Height of image
  95. */
  96. int height;
  97. };
  98. #endif //__CAMERA_H__