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_still_test.cpp 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. #include <iostream>
  34. #include <fstream>
  35. #include <cstdlib>
  36. #include "raspicam_still_cv.h"
  37. using namespace std;
  38. raspicam::RaspiCam_Still_Cv Camera;
  39. //Returns the value of a param. If not present, returns the defvalue
  40. float getParamVal ( string id,int argc,char **argv,float defvalue ) {
  41. for ( int i=0; i<argc; i++ )
  42. if ( id== argv[i] )
  43. return atof ( argv[i+1] );
  44. return defvalue;
  45. }
  46. //prints program command line usage
  47. void usage() {
  48. cout<<"-w val : sets image width (2592 default)"<<endl;
  49. cout<<"-h val : sets image height (1944 default)"<<endl;
  50. // cout<<"-iso val: set iso [100,800] (400 default)"<<endl;
  51. }
  52. int main ( int argc, char *argv[] ) {
  53. usage();
  54. int width = getParamVal ( "-w",argc,argv,2592 );//define width
  55. int height =getParamVal ( "-h",argc,argv,1944 );//define height
  56. cout << "Initializing ..."<<width<<"x"<<height<<endl;
  57. Camera.set ( cv::CAP_PROP_FRAME_WIDTH, width );
  58. Camera.set ( cv::CAP_PROP_FRAME_HEIGHT, height );
  59. Camera.open();
  60. cv::Mat image;
  61. cout<<"capturing"<<endl;
  62. if ( !Camera.grab ( ) ) {
  63. cerr<<"Error in grab"<<endl;
  64. return -1;
  65. }
  66. Camera.retrieve ( image );
  67. cout<<"saving picture.jpg"<<endl;
  68. cv::imwrite ( "picture.jpg",image );
  69. return 0;
  70. }