Projektarbeit Line Following Robot bei Prof. Chowanetz im WS22/23
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.

raspicam_cv.h 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /**********************************************************
  2. Software developed by AVA ( Ava Group of the University of Cordoba, ava at uco dot es)
  3. Main author Rafael Munoz Salinas (rmsalinas at uco dot es)
  4. This software is released under BSD license as expressed below
  5. -------------------------------------------------------------------
  6. Copyright (c) 2013, AVA ( Ava Group University of Cordoba, ava at uco dot es)
  7. All rights reserved.
  8. Redistribution and use in source and binary forms, with or without
  9. modification, are permitted provided that the following conditions
  10. are met:
  11. 1. Redistributions of source code must retain the above copyright
  12. notice, this list of conditions and the following disclaimer.
  13. 2. Redistributions in binary form must reproduce the above copyright
  14. notice, this list of conditions and the following disclaimer in the
  15. documentation and/or other materials provided with the distribution.
  16. 3. All advertising materials mentioning features or use of this software
  17. must display the following acknowledgement:
  18. This product includes software developed by the Ava group of the University of Cordoba.
  19. 4. Neither the name of the University nor the names of its contributors
  20. may be used to endorse or promote products derived from this software
  21. without specific prior written permission.
  22. THIS SOFTWARE IS PROVIDED BY AVA ''AS IS'' AND ANY
  23. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. DISCLAIMED. IN NO EVENT SHALL AVA BE LIABLE FOR ANY
  26. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  27. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  28. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  29. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ****************************************************************/
  33. #ifndef RaspiCam_CV_H
  34. #define RaspiCam_CV_H
  35. #include <opencv2/core/core.hpp>
  36. #include <opencv2/highgui/highgui.hpp>
  37. namespace raspicam {
  38. namespace _private{
  39. class Private_Impl;
  40. }
  41. /**Class for using Raspberry camera as in opencv
  42. */
  43. class RaspiCam_Cv {
  44. _private::Private_Impl *_impl;
  45. public:
  46. /**Constructor
  47. */
  48. RaspiCam_Cv();
  49. /**Destructor
  50. */
  51. ~RaspiCam_Cv();
  52. /** Open capturing device for video capturing
  53. */
  54. bool open ( void );
  55. /**
  56. * Returns true if video capturing has been initialized already.
  57. */
  58. bool isOpened() const;
  59. /**
  60. *Closes video file or capturing device.
  61. */
  62. void release();
  63. /*
  64. * the function 'userCallback' will be called every time new data arrived from camera,
  65. * with 'data' as argument.
  66. */
  67. void setUserCallback(void (*userCallback)(void*) , void* data=0);
  68. /**
  69. * Grabs the next frame from video file or capturing device.
  70. */
  71. bool grab();
  72. /**
  73. *Decodes and returns the grabbed video frame.
  74. */
  75. void retrieve ( cv::Mat& image );
  76. /**Returns the specified VideoCapture property
  77. */
  78. double get ( int propId );
  79. /**Sets a property in the VideoCapture.
  80. *
  81. *
  82. * Implemented properties:
  83. * cv::CAP_PROP_FRAME_WIDTH,cv::CAP_PROP_FRAME_HEIGHT,
  84. * cv::CAP_PROP_FORMAT: CV_8UC1 or CV_8UC3
  85. * cv::CAP_PROP_BRIGHTNESS: [0,100]
  86. * cv::CAP_PROP_CONTRAST: [0,100]
  87. * cv::CAP_PROP_SATURATION: [0,100]
  88. * cv::CAP_PROP_GAIN: (iso): [0,100]
  89. * cv::CAP_PROP_EXPOSURE: -1 auto. [1,100] shutter speed from 0 to 33ms
  90. * cv::CAP_PROP_WHITE_BALANCE_RED_V : [1,100] -1 auto whitebalance
  91. * cv::CAP_PROP_WHITE_BALANCE_BLUE_U : [1,100] -1 auto whitebalance
  92. * cv::CAP_PROP_MODE : [1,7] 0 auto mode
  93. *
  94. */
  95. bool set ( int propId, double value );
  96. /** Sets the rotation
  97. 0: none
  98. 1: 90 degrees clockwise
  99. 2: 180 degrees
  100. 3: 270 degrees clockwise
  101. */
  102. void setRotation ( int nRotation );
  103. /** Sets the image effect. See RASPICAM_IMAGE_EFFECT enum. 19 values as of current implementation.
  104. */
  105. void setImageEffect ( int nEffect );
  106. /** Enable or disable video stabilization
  107. */
  108. void setVideoStabilization ( bool enable );
  109. /** Enable or disable horizontal flip
  110. */
  111. void setHorizontalFlip ( bool enable );
  112. /** Enable or disable vertical flip
  113. */
  114. void setVerticalFlip ( bool enable );
  115. /** Set exposure compensation. -10,10
  116. */
  117. void setExposureCompensation( int value );
  118. /** Sets auto white balance. See RASPICAM_AWB enum. 9 values as of current implementation.
  119. */
  120. void setAWB ( int nEnumValue );
  121. /** Sets metering type. See RASPICAM_METERING enum. 4 values as of current implementation.
  122. */
  123. void setMetering ( int nEnumValue );
  124. /** Returns the camera identifier. We assume the camera id is the one of the raspberry obtained using raspberry serial number obtained in /proc/cpuinfo
  125. */
  126. std::string getId()const;
  127. private:
  128. cv::Mat image;
  129. int imgFormat;//required image format //
  130. };
  131. }
  132. #endif