test1.cpp
Go to the documentation of this file.
1  /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  ***************************************************************************************************/
27 
50 //c++
51 #include <stdio.h>
52 #include <iostream>
53 
54 //Visp
55 #include <visp/vpPixelMeterConversion.h>
56 #include <visp/vp1394CMUGrabber.h>
57 #include <visp/vp1394TwoGrabber.h>
58 #include <visp/vpDisplayGDI.h>
59 #include <visp/vpDisplayX.h>
60 #include <visp/vpDot2.h>
61 #include <visp/vpPose.h>
62 #include <visp/vpConfig.h>
63 #include <visp/vpImage.h>
64 #include <visp/vpRGBa.h>
65 
66 //convert images //cesar
67 #include <visp/vpImageIo.h>
68 #include <visp/vpImageConvert.h>
69 
70 //my files
72 
73 
74 void wait_lum_set(vpImage<unsigned char> &I_grey,
75 #if defined(VISP_HAVE_DC1394_2)
76  vp1394TwoGrabber &g//THIS, is the one that is called!!!
77 #elif defined(VISP_HAVE_CMU1394)
78  vp1394CMUGrabber g
79 
80 #endif
81 )
82 {
83  std::cout << "**PLEASE SET THE CAMERA LUMINIOSITY!! ***" << std::endl;
84  std::cout << "press 'Esc' to exit" << std::endl;
85  while (true)
86  {
87  //if (cv::waitKey(20) == 27)
88  if(vpDisplay::getClick(I_grey))
89  {
90  break;
91  }
92  g.acquire(I_grey);//g.acquire(I);
93  vpDisplay::display(I_grey);//vpDisplay::display(I);
94  vpDisplay::flush(I_grey);
95  }
96  std::cout << "Luminiosity setted!" << std::endl;
97 }
98 
99 int main()
100 {
101 #if (defined(VISP_HAVE_DC1394_2) || defined(VISP_HAVE_CMU1394))
102  try {
103  vpImage<unsigned char> I; // Create a gray level image container
104 
105 #if defined(VISP_HAVE_DC1394_2)
106  vp1394TwoGrabber g(false);
107 #elif defined(VISP_HAVE_CMU1394)
108  vp1394CMUGrabber g;
109 #endif
110  g.open(I);
111  g.acquire(I);
112 
113 #if defined(VISP_HAVE_X11)
114  vpDisplayX d(I, 0, 0, "Camera view");
115 #elif defined(VISP_HAVE_GDI)
116  vpDisplayGDI d(I, 0, 0, "Camera view");
117 #else
118  std::cout << "No image viewer is available..." << std::endl;
119 #endif
120  vpDisplay::display(I);
121  vpDisplay::flush(I);
122 std::cout << "teste1" << std::endl;
123  vpDot2 blob;
124  blob.setGraphics(true);
125  blob.setGraphicsThickness(2);
126  //blob.initTracking(I);
127  cv::Point src_centre; bool init = true; cv:Mat I_mat;
128  std::cout << "teste2" << std::endl;
129 
130  wait_lum_set(I,g);//set luminiosity
131 
132  while (true)
133  {
134  try
135  {
136  while (init)
137  {
138  std::cout << "teste3" << std::endl;
139  vpImageConvert::convert(I,I_mat);
140  vpTime::wait(10);
141  std::cout << "teste4" << std::endl;
142  findArrow::find_arrow(I_mat,src_centre);
143  if (findArrow::found_new_point == true)
144  {
145  std::cout << "teste5" << std::endl;
146  //blob.initTracking(I,vpImagePoint(240, 320));//cesar
147  blob.initTracking(I,vpImagePoint(src_centre.y, src_centre.x));//cesar
148  init = false;
149  }
150  //update image
151  g.acquire(I);
152  vpDisplay::display(I);
153  vpDisplay::flush(I);
154  }
155  std::cout << "teste6" << std::endl;
156  while(1)
157  {
158  std::cout << "teste7" << std::endl;
159  std::cout << "getCog" << blob.getCog() << std::endl;
160 
161  g.acquire(I); // Acquire an image
162  vpDisplay::display(I);
163  blob.track(I);
164  vpDisplay::flush(I);
165  if (vpDisplay::getClick(I, false))
166  break;
167  }
168  }
169  catch(vpException e)
170  {
171  std::cout << "Catch an exception: " << e << std::endl;
172  init=true;
173  }
174  }
175  }
176  catch(vpException e) {
177  std::cout << "Catch an exception: " << e << std::endl;
178  }
179 #endif
180 }
static int find_arrow(cv::Mat frame, cv::Point &center_point)
Definition: findArrow.cpp:473
void wait_lum_set(vpImage< unsigned char > &I_grey,)
Definition: test1.cpp:74
static bool found_new_point
Definition: findArrow.h:83
int main()
Definition: test1.cpp:99


arrow_detection
Author(s): César Sousa
autogenerated on Mon Mar 2 2015 01:31:21