snark
gige.h
1 // This file is part of snark, a generic and flexible library
2 // for robotics research.
3 //
4 // Copyright (C) 2011 The University of Sydney
5 //
6 // snark is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 3 of the License, or (at your option) any later version.
10 //
11 // snark is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14 // for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with snark. If not, see <http://www.gnu.org/licenses/>.
18 
19 #ifndef SNARK_SENSORS_GIGE_H_
20 #define SNARK_SENSORS_GIGE_H_
21 
22 #include <PvApi.h>
23 #include <boost/date_time/posix_time/posix_time.hpp>
24 #include <boost/function.hpp>
25 
26 #include <opencv2/core/core.hpp>
27 
28 
29 namespace snark{ namespace camera{
30 
32 class gige
33 {
34  public:
36  typedef std::map< std::string, std::string > attributes_type;
37 
39  gige( unsigned int id = 0, const attributes_type& attributes = attributes_type() );
40 
42  ~gige();
43 
46 
48  std::pair< boost::posix_time::ptime, cv::Mat > read();
49 
51  unsigned int id() const;
52 
54  unsigned long total_bytes_per_frame() const;
55 
57  void close();
58 
60  static std::vector< tPvCameraInfo > list_cameras();
61 
63  class callback
64  {
65  public:
67  callback( gige& gige, boost::function< void ( std::pair< boost::posix_time::ptime, cv::Mat > ) > on_frame );
68 
70  ~callback();
71 
73  class impl;
74 
76  bool good() const;
77 
78  private:
79  friend class gige;
80  impl* pimpl_;
81  };
82 
83  private:
84  friend class callback::impl;
85  class impl;
86  impl* pimpl_;
87 };
88 
89 } } // namespace snark{ namespace camera{
90 
91 #endif // SNARK_SENSORS_GIGE_H_