24 #include <fvcams/control/sony_evid100p.h> 25 #include <fvcams/control/visca.h> 26 #include <fvutils/system/camargp.h> 28 #include <utils/math/angle.h> 43 const int SonyEviD100PControl::MAX_PAN = 1440;
45 const int SonyEviD100PControl::MIN_PAN = -1439;
47 const int SonyEviD100PControl::MAX_TILT = 360;
49 const int SonyEviD100PControl::MIN_TILT = - 359;
52 const float SonyEviD100PControl::MAX_PAN_DEG = 100.f;
54 const float SonyEviD100PControl::MIN_PAN_DEG = -100.f;
56 const float SonyEviD100PControl::MAX_TILT_DEG = 25.f;
58 const float SonyEviD100PControl::MIN_TILT_DEG = - 25.f;
61 const float SonyEviD100PControl::MAX_PAN_RAD =
deg2rad(MAX_PAN_DEG);
63 const float SonyEviD100PControl::MIN_PAN_RAD =
deg2rad(MIN_PAN_DEG);
65 const float SonyEviD100PControl::MAX_TILT_RAD =
deg2rad(MAX_TILT_DEG);
67 const float SonyEviD100PControl::MIN_TILT_RAD =
deg2rad(MIN_TILT_DEG);
70 const float SonyEviD100PControl::PAN_STEPS_PER_DEG = MAX_PAN / MAX_PAN_DEG;
72 const float SonyEviD100PControl::TILT_STEPS_PER_DEG = MAX_TILT / MAX_TILT_DEG;
75 const float SonyEviD100PControl::PAN_STEPS_PER_RAD = MAX_PAN / MAX_PAN_RAD;
77 const float SonyEviD100PControl::TILT_STEPS_PER_RAD = MAX_TILT / MAX_TILT_RAD;
80 const unsigned int SonyEviD100PControl::EFFECT_PASTEL = 1;
82 const unsigned int SonyEviD100PControl::EFFECT_NEGATIVE = 2;
84 const unsigned int SonyEviD100PControl::EFFECT_SEPIA = 3;
86 const unsigned int SonyEviD100PControl::EFFECT_BW = 4;
88 const unsigned int SonyEviD100PControl::EFFECT_SOLARIZE = 5;
90 const unsigned int SonyEviD100PControl::EFFECT_MOSAIC = 6;
92 const unsigned int SonyEviD100PControl::EFFECT_SLIM = 7;
94 const unsigned int SonyEviD100PControl::EFFECT_STRETCH = 8;
107 SonyEviD100PControl::SonyEviD100PControl(
const char *tty_port)
109 this->tty_port = strdup(tty_port);
114 _effect = EFFECT_NONE;
127 tty_port = strdup(cap->
cam_id().c_str());
133 _effect = EFFECT_NONE;
140 SonyEviD100PControl::~SonyEviD100PControl()
152 SonyEviD100PControl::open()
157 visca->open(tty_port);
158 visca->set_address(1);
162 e.
append(
"Sony EviD100PControl failed");
173 SonyEviD100PControl::close()
175 if ( ! opened )
return;
181 SonyEviD100PControl::process_pantilt()
188 SonyEviD100PControl::supports_pan()
195 SonyEviD100PControl::supports_tilt()
202 SonyEviD100PControl::set_pan(
int pan)
205 visca->setPanTilt(pan, tilt_target);
210 SonyEviD100PControl::set_tilt(
int tilt)
213 visca->setPanTilt(pan_target, tilt);
218 SonyEviD100PControl::set_pan_tilt(
int pan,
int tilt)
222 visca->setPanTilt(pan, tilt);
227 SonyEviD100PControl::set_pan_tilt_rad(
float pan,
float tilt)
229 int tpan = 0, ttilt = 0;
231 tpan = (int)rint( pan * PAN_STEPS_PER_RAD );
232 ttilt = (int)rint( tilt * TILT_STEPS_PER_RAD );
234 set_pan_tilt(tpan, ttilt);
239 SonyEviD100PControl::start_get_pan_tilt()
241 visca->startGetPanTilt();
246 SonyEviD100PControl::pan_tilt(
int &pan,
int &tilt)
249 visca->getPanTilt(&tpan, &ttilt);
256 SonyEviD100PControl::pan_tilt_rad(
float &pan,
float &tilt)
258 int tpan = 0, ttilt = 0;
259 visca->getPanTilt(&tpan, &ttilt);
261 pan = tpan / PAN_STEPS_PER_RAD;
262 tilt = ttilt / PAN_STEPS_PER_RAD;
267 SonyEviD100PControl::pan()
269 int pan = 0, tilt = 0;
270 visca->getPanTilt(&pan, &tilt);
276 SonyEviD100PControl::tilt()
278 int pan = 0, tilt = 0;
279 visca->getPanTilt(&pan, &tilt);
285 SonyEviD100PControl::max_pan()
292 SonyEviD100PControl::min_pan()
299 SonyEviD100PControl::max_tilt()
306 SonyEviD100PControl::min_tilt()
313 SonyEviD100PControl::reset_pan_tilt()
315 visca->resetPanTilt();
320 SonyEviD100PControl::set_pan_tilt_limit(
int pan_left,
int pan_right,
321 int tilt_up,
int tilt_down)
323 visca->setPanTiltLimit(pan_left, pan_right, tilt_up, tilt_down);
328 SonyEviD100PControl::reset_pan_tilt_limit()
330 visca->resetPanTiltLimit();
335 SonyEviD100PControl::reset_zoom()
342 SonyEviD100PControl::set_zoom(
unsigned int zoom)
344 visca->setZoom(zoom);
349 SonyEviD100PControl::zoom()
352 visca->getZoom(&zoom);
358 SonyEviD100PControl::zoom_min()
365 SonyEviD100PControl::zoom_max()
372 SonyEviD100PControl::set_zoom_speed_tele(
unsigned int speed)
374 visca->setZoomSpeedTele(speed);
379 SonyEviD100PControl::set_zoom_speed_wide(
unsigned int speed)
381 visca->setZoomSpeedWide(speed);
386 SonyEviD100PControl::set_zoom_digital_enabled(
bool enabled)
388 visca->setZoomDigitalEnabled(enabled);
393 SonyEviD100PControl::supports_effect(
unsigned int __effect)
395 if ( __effect == EFFECT_NONE ) {
401 case EFFECT_NEGATIVE:
404 case EFFECT_SOLARIZE:
417 SonyEviD100PControl::set_effect(
unsigned int __effect)
419 this->_effect = __effect;
420 if ( __effect == EFFECT_NONE ) {
421 visca->resetEffect();
425 visca->applyEffectPastel();
427 case EFFECT_NEGATIVE:
428 visca->applyEffectNegArt();
431 visca->applyEffectSepia();
434 visca->applyEffectBnW();
436 case EFFECT_SOLARIZE:
437 visca->applyEffectSolarize();
440 visca->applyEffectMosaic();
443 visca->applyEffectSlim();
446 visca->applyEffectStretch();
456 SonyEviD100PControl::effect()
463 SonyEviD100PControl::reset_effect()
465 visca->resetEffect();
473 SonyEviD100PControl::white_balance_mode()
475 return visca->getWhiteBalanceMode();
Fawkes library namespace.
std::string cam_id() const
Get camera ID.
Visca control protocol implementation over a serial line.
float deg2rad(float deg)
Convert an angle given in degrees to radians.
void append(const char *format,...)
Append messages to the message list.