camera_driver.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <libuvc/libuvc.h>
4 
5 #include <ros/ros.h>
8 #include <dynamic_reconfigure/server.h>
10 #include <boost/thread/mutex.hpp>
11 
12 #include <libuvc_camera/UVCCameraConfig.h>
13 
14 namespace libuvc_camera {
15 
16 class CameraDriver {
17 public:
19  ~CameraDriver();
20 
21  bool Start();
22  void Stop();
23 
24 private:
25  enum State {
26  kInitial = 0,
27  kStopped = 1,
28  kRunning = 2,
29  };
30 
31  // Flags controlling whether the sensor needs to be stopped (or reopened) when changing settings
32  static const int kReconfigureClose = 3; // Need to close and reopen sensor to change this setting
33  static const int kReconfigureStop = 1; // Need to stop the stream before changing this setting
34  static const int kReconfigureRunning = 0; // We can change this setting without stopping the stream
35 
36  void OpenCamera(UVCCameraConfig &new_config);
37  void CloseCamera();
38 
39  // Accept a reconfigure request from a client
40  void ReconfigureCallback(UVCCameraConfig &config, uint32_t level);
41  enum uvc_frame_format GetVideoMode(std::string vmode);
42  // Accept changes in values of automatically updated controls
43  void AutoControlsCallback(enum uvc_status_class status_class,
44  int event,
45  int selector,
46  enum uvc_status_attribute status_attribute,
47  void *data, size_t data_len);
48  static void AutoControlsCallbackAdapter(enum uvc_status_class status_class,
49  int event,
50  int selector,
51  enum uvc_status_attribute status_attribute,
52  void *data, size_t data_len,
53  void *ptr);
54  // Accept a new image frame from the camera
55  void ImageCallback(uvc_frame_t *frame);
56  static void ImageCallbackAdapter(uvc_frame_t *frame, void *ptr);
57 
59 
61  boost::recursive_mutex mutex_;
62 
63  uvc_context_t *ctx_;
64  uvc_device_t *dev_;
65  uvc_device_handle_t *devh_;
66  uvc_frame_t *rgb_frame_;
67 
70 
71  dynamic_reconfigure::Server<UVCCameraConfig> config_server_;
72  UVCCameraConfig config_;
74 
76 };
77 
78 };
boost::recursive_mutex mutex_
Definition: camera_driver.h:61
static void ImageCallbackAdapter(uvc_frame_t *frame, void *ptr)
enum uvc_frame_format GetVideoMode(std::string vmode)
static const int kReconfigureRunning
Definition: camera_driver.h:34
static void AutoControlsCallbackAdapter(enum uvc_status_class status_class, int event, int selector, enum uvc_status_attribute status_attribute, void *data, size_t data_len, void *ptr)
static const int kReconfigureStop
Definition: camera_driver.h:33
image_transport::ImageTransport it_
Definition: camera_driver.h:68
dynamic_reconfigure::Server< UVCCameraConfig > config_server_
Definition: camera_driver.h:71
void ReconfigureCallback(UVCCameraConfig &config, uint32_t level)
void ImageCallback(uvc_frame_t *frame)
void OpenCamera(UVCCameraConfig &new_config)
image_transport::CameraPublisher cam_pub_
Definition: camera_driver.h:69
camera_info_manager::CameraInfoManager cinfo_manager_
Definition: camera_driver.h:75
void AutoControlsCallback(enum uvc_status_class status_class, int event, int selector, enum uvc_status_attribute status_attribute, void *data, size_t data_len)
static const int kReconfigureClose
Definition: camera_driver.h:32
CameraDriver(ros::NodeHandle nh, ros::NodeHandle priv_nh)
uvc_device_handle_t * devh_
Definition: camera_driver.h:65


libuvc_camera
Author(s):
autogenerated on Mon Jul 8 2019 03:45:03