camera_depth_sensor.h
Go to the documentation of this file.
1 // -*- mode: c++ -*-
2 /*********************************************************************
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2015, JSK Lab
6  * All rights reserved.
7  *
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  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/o2r other materials provided
17  * with the distribution.
18  * * Neither the name of the JSK Lab nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *********************************************************************/
35 
36 #ifndef JSK_RECOGNITION_UTILS_CAMERA_DEPTH_SENSOR_H_
37 #define JSK_RECOGNITION_UTILS_CAMERA_DEPTH_SENSOR_H_
38 
40 #include <sensor_msgs/CameraInfo.h>
42 
43 namespace jsk_recognition_utils
44 {
46  {
47  public:
50 
51  virtual void setCameraInfo(const sensor_msgs::CameraInfo& info)
52  {
53  camera_info_ = info;
54  model_.fromCameraInfo(info);
55  }
56 
62  {
63  return model_;
64  }
65 
70  virtual bool isInside(const cv::Point& p) const
71  {
72  return (p.x >= 0 && p.x < camera_info_.width &&
73  p.y >= 0 && p.y < camera_info_.height);
74  }
75 
82  virtual double expectedPointCloudNum(double distance, double area) const
83  {
84  double f = model_.fx();
85  return f*f / (distance*distance) * area;
86  }
87 
92  virtual cv::Mat image(const int type) const
93  {
94  return cv::Mat::zeros(camera_info_.height, camera_info_.width, type);
95  }
96 
101  virtual int width() const
102  {
103  return camera_info_.width;
104  }
105 
110  virtual int height() const
111  {
112  return camera_info_.height;
113  }
114 
119  virtual cv::Point limit2DPoint(const cv::Point& p) const
120  {
121  return cv::Point(std::min(std::max(p.x, 0), width()),
122  std::min(std::max(p.y, 0), height()));
123  }
124 
125  protected:
127  sensor_msgs::CameraInfo camera_info_;
128  private:
129 
130  };
131 }
132 
133 #endif
virtual int width() const
width of camera in pixels.
f
virtual cv::Point limit2DPoint(const cv::Point &p) const
force point to be inside of field of view.
virtual bool isInside(const cv::Point &p) const
return true if point p is inside of field-of-view.
virtual cv::Mat image(const int type) const
return an image from internal camera parameter.
virtual image_geometry::PinholeCameraModel getPinholeCameraModel() const
get instance of image_geometry::PinholeCameraModel.
virtual double expectedPointCloudNum(double distance, double area) const
Return the expected number of points according to distance and area. it is calculated according to: f...
virtual int height() const
height of camera in pixels.
boost::shared_ptr< CameraDepthSensor > Ptr
bool fromCameraInfo(const sensor_msgs::CameraInfo &msg)
image_geometry::PinholeCameraModel model_
Super class for sensor model. It provides pure virtual method for common interfaces.
virtual void setCameraInfo(const sensor_msgs::CameraInfo &info)


jsk_recognition_utils
Author(s):
autogenerated on Fri Dec 6 2019 04:02:51