naoqidriver
camera.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2015 Aldebaran
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef CAMERA_RECORDER_HPP
19 #define CAMERA_RECORDER_HPP
20 
21 /*
22 * BOOST includes
23 */
24 #include <boost/circular_buffer.hpp>
25 
26 /*
27 * LOCAL includes
28 */
30 #include "../helpers/recorder_helpers.hpp"
31 
32 /*
33 * ROS includes
34 */
35 #include <sensor_msgs/CameraInfo.h>
36 #include <sensor_msgs/Image.h>
37 
38 namespace naoqi
39 {
40 namespace recorder
41 {
42 
44 {
45 
46 public:
47  CameraRecorder(const std::string& topic, float buffer_frequency );
48 
49  void write( const sensor_msgs::ImagePtr& img, const sensor_msgs::CameraInfo& camera_info );
50 
51  void reset(boost::shared_ptr<naoqi::recorder::GlobalRecorder> gr, float conv_frequency );
52 
53  void bufferize( const sensor_msgs::ImagePtr& img, const sensor_msgs::CameraInfo& camera_info );
54 
55  void writeDump(const ros::Time& time);
56 
57  void setBufferDuration(float duration);
58 
59  inline std::string topic() const
60  {
61  return topic_img_;
62  }
63 
64  inline bool isInitialized() const
65  {
66  return is_initialized_;
67  }
68 
69  inline void subscribe( bool state)
70  {
71  is_subscribed_ = state;
72  }
73 
74  inline bool isSubscribed() const
75  {
76  return is_subscribed_;
77  }
78 
79 protected:
82 
83  boost::circular_buffer< std::pair<sensor_msgs::ImagePtr, sensor_msgs::CameraInfo> > buffer_;
84  size_t buffer_size_;
86 
87  boost::mutex mutex_;
88 
89  boost::shared_ptr<naoqi::recorder::GlobalRecorder> gr_;
90  std::string topic_info_;
91  std::string topic_img_;
92 
95  int counter_;
97 
98 }; // class
99 
100 } //publisher
101 } // naoqi
102 
103 #endif
float buffer_frequency_
Definition: camera.hpp:93
CameraRecorder(const std::string &topic, float buffer_frequency)
Definition: camera.cpp:28
void setBufferDuration(float duration)
Definition: camera.cpp:90
boost::mutex mutex_
Definition: camera.hpp:87
void writeDump(const ros::Time &time)
Definition: camera.cpp:53
float conv_frequency_
Definition: camera.hpp:94
void bufferize(const sensor_msgs::ImagePtr &img, const sensor_msgs::CameraInfo &camera_info)
Definition: camera.cpp:76
void subscribe(bool state)
Definition: camera.hpp:69
Definition: audio.cpp:29
std::string topic_info_
Definition: camera.hpp:90
bool is_initialized_
Definition: camera.hpp:80
bool isSubscribed() const
Definition: camera.hpp:74
void write(const sensor_msgs::ImagePtr &img, const sensor_msgs::CameraInfo &camera_info)
Definition: camera.cpp:37
int max_counter_
Definition: camera.hpp:96
boost::shared_ptr< naoqi::recorder::GlobalRecorder > gr_
Definition: camera.hpp:89
bool is_subscribed_
Definition: camera.hpp:81
size_t buffer_size_
Definition: camera.hpp:84
std::string topic() const
Definition: camera.hpp:59
void reset(boost::shared_ptr< naoqi::recorder::GlobalRecorder > gr, float conv_frequency)
Definition: camera.cpp:66
int counter_
Definition: camera.hpp:95
boost::circular_buffer< std::pair< sensor_msgs::ImagePtr, sensor_msgs::CameraInfo > > buffer_
Definition: camera.hpp:83
bool isInitialized() const
Definition: camera.hpp:64
std::string topic_img_
Definition: camera.hpp:91
Definition: camera.hpp:43
float buffer_duration_
Definition: camera.hpp:85