26 #ifndef INCLUDED_base_camera_server_h_GUID_AE8BD56F_793F_4693_9B94_4E4CC953511C 27 #define INCLUDED_base_camera_server_h_GUID_AE8BD56F_793F_4693_9B94_4E4CC953511C 30 #include <vrpn_Shared.h> 58 virtual void read_range(
int &minx,
int &maxx,
int &miny,
65 virtual unsigned get_num_rows(
void)
const {
66 int _minx, _maxx, _miny, _maxy;
67 read_range(_minx, _maxx, _miny, _maxy);
68 return _maxy - _miny + 1;
70 virtual unsigned get_num_columns(
void)
const {
71 int _minx, _maxx, _miny, _maxy;
72 read_range(_minx, _maxx, _miny, _maxy);
73 return _maxx - _minx + 1;
78 virtual bool read_pixel(
int x,
int y,
double &result,
79 unsigned rgb = 0)
const = 0;
82 virtual bool read_pixel(
int x,
int y, vrpn_uint8 &result,
83 unsigned rgb = 0)
const {
86 result =
static_cast<vrpn_uint8
>(double_pix);
89 virtual bool read_pixel(
int x,
int y, vrpn_uint16 &result,
90 unsigned rgb = 0)
const {
93 result =
static_cast<vrpn_uint16
>(double_pix);
108 inline bool read_pixel_bilerp(
double x,
double y,
double &result,
109 unsigned rgb = 0)
const {
116 double xlow = floor(x);
117 int ixlow = (int)xlow;
122 double ylow = floor(y);
123 int iylow = (int)ylow;
124 int ixhigh = ixlow + 1;
125 int iyhigh = iylow + 1;
126 double xhighfrac = x - xlow;
127 double yhighfrac = y - ylow;
128 double xlowfrac = 1.0 - xhighfrac;
129 double ylowfrac = 1.0 - yhighfrac;
130 double ll, lh, hl, hh;
147 result = ll * xlowfrac * ylowfrac + lh * xlowfrac * yhighfrac +
148 hl * xhighfrac * ylowfrac + hh * xhighfrac * yhighfrac;
157 inline double read_pixel_bilerp_nocheck(
double x,
double y,
158 unsigned rgb = 0)
const {
164 double xlow = floor(x);
165 int ixlow = (int)xlow;
170 double ylow = floor(y);
171 int iylow = (int)ylow;
172 int ixhigh = ixlow + 1;
173 int iyhigh = iylow + 1;
174 double xhighfrac = x - xlow;
175 double yhighfrac = y - ylow;
176 double xlowfrac = 1.0 - xhighfrac;
177 double ylowfrac = 1.0 - yhighfrac;
206 unsigned get_num_rows(
void)
const {
return _num_rows / _binning; };
207 unsigned get_num_columns(
void)
const {
return _num_columns / _binning; };
216 virtual bool read_image_to_memory(
unsigned minX = 255,
unsigned maxX = 0,
217 unsigned minY = 255,
unsigned maxY = 0,
218 double exposure_time = 250.0) = 0;
221 virtual bool get_pixel_from_memory(
unsigned X,
unsigned Y, vrpn_uint8 &val,
222 int RGB = 0)
const = 0;
223 virtual bool get_pixel_from_memory(
unsigned X,
unsigned Y, vrpn_uint16 &val,
224 int RGB = 0)
const = 0;
228 virtual bool read_pixel(
int x,
int y, vrpn_uint8 &result,
229 unsigned rgb = 0)
const {
230 return get_pixel_from_memory(x, y, result, rgb);
232 virtual bool read_pixel(
int x,
int y, vrpn_uint16 &result,
233 unsigned rgb = 0)
const {
234 return get_pixel_from_memory(x, y, result, rgb);
240 unsigned rgb = 0)
const {
243 if (get_pixel_from_memory(x, y, val, rgb)) {
254 get_pixel_from_memory(x, y, val, rgb);
259 virtual void read_range(
int &minx,
int &maxx,
int &miny,
int &maxy)
const {
268 unsigned _num_rows, _num_columns;
275 virtual bool open_and_find_parameters(
void) {
return false; };
284 #endif // INCLUDED_base_camera_server_h_GUID_AE8BD56F_793F_4693_9B94_4E4CC953511C virtual bool read_pixel(int x, int y, double &result, unsigned rgb=0) const
Read a pixel from the image into a double; return true if the pixel.
Definition: base_camera_server.h:239
virtual double read_pixel_nocheck(int x, int y, unsigned rgb=0) const
Read a pixel from the image into a double; Don't check boundaries.
Definition: base_camera_server.h:252
Definition: base_camera_server.h:52
virtual void read_range(int &minx, int &maxx, int &miny, int &maxy) const
Instantiation needed for image_wrapper.
Definition: base_camera_server.h:259
virtual unsigned get_num_colors() const =0
Return the number of colors that the image has.
virtual double read_pixel_nocheck(int x, int y, unsigned rgb=0) const =0
Read a pixel from the image into a double; Don't check boundaries.
virtual bool read_pixel(int x, int y, double &result, unsigned rgb=0) const =0
Read a pixel from the image into a double; return true if the pixel.
Definition: base_camera_server.h:196
bool working(void) const
Is the camera working properly?
Definition: base_camera_server.h:201