24 #include <fvcams/control/sony_evid100p.h>
25 #include <fvcams/control/visca.h>
26 #include <fvutils/system/camargp.h>
27 #include <utils/math/angle.h>
36 namespace firevision {
39 const int SonyEviD100PControl::MAX_PAN = 1440;
41 const int SonyEviD100PControl::MIN_PAN = -1439;
43 const int SonyEviD100PControl::MAX_TILT = 360;
45 const int SonyEviD100PControl::MIN_TILT = -359;
48 const float SonyEviD100PControl::MAX_PAN_DEG = 100.f;
50 const float SonyEviD100PControl::MIN_PAN_DEG = -100.f;
52 const float SonyEviD100PControl::MAX_TILT_DEG = 25.f;
54 const float SonyEviD100PControl::MIN_TILT_DEG = -25.f;
57 const float SonyEviD100PControl::MAX_PAN_RAD =
deg2rad(MAX_PAN_DEG);
59 const float SonyEviD100PControl::MIN_PAN_RAD =
deg2rad(MIN_PAN_DEG);
61 const float SonyEviD100PControl::MAX_TILT_RAD =
deg2rad(MAX_TILT_DEG);
63 const float SonyEviD100PControl::MIN_TILT_RAD =
deg2rad(MIN_TILT_DEG);
66 const float SonyEviD100PControl::PAN_STEPS_PER_DEG = MAX_PAN / MAX_PAN_DEG;
68 const float SonyEviD100PControl::TILT_STEPS_PER_DEG = MAX_TILT / MAX_TILT_DEG;
71 const float SonyEviD100PControl::PAN_STEPS_PER_RAD = MAX_PAN / MAX_PAN_RAD;
73 const float SonyEviD100PControl::TILT_STEPS_PER_RAD = MAX_TILT / MAX_TILT_RAD;
76 const unsigned int SonyEviD100PControl::EFFECT_PASTEL = 1;
78 const unsigned int SonyEviD100PControl::EFFECT_NEGATIVE = 2;
80 const unsigned int SonyEviD100PControl::EFFECT_SEPIA = 3;
82 const unsigned int SonyEviD100PControl::EFFECT_BW = 4;
84 const unsigned int SonyEviD100PControl::EFFECT_SOLARIZE = 5;
86 const unsigned int SonyEviD100PControl::EFFECT_MOSAIC = 6;
88 const unsigned int SonyEviD100PControl::EFFECT_SLIM = 7;
90 const unsigned int SonyEviD100PControl::EFFECT_STRETCH = 8;
101 SonyEviD100PControl::SonyEviD100PControl(
const char *tty_port)
103 this->tty_port = strdup(tty_port);
108 _effect = EFFECT_NONE;
120 tty_port = strdup(cap->
cam_id().c_str());
126 _effect = EFFECT_NONE;
132 SonyEviD100PControl::~SonyEviD100PControl()
142 SonyEviD100PControl::open()
148 visca->open(tty_port);
149 visca->set_address(1);
153 e.
append(
"Sony EviD100PControl failed");
163 SonyEviD100PControl::close()
171 SonyEviD100PControl::process_pantilt()
177 SonyEviD100PControl::supports_pan()
183 SonyEviD100PControl::supports_tilt()
189 SonyEviD100PControl::set_pan(
int pan)
192 visca->setPanTilt(pan, tilt_target);
196 SonyEviD100PControl::set_tilt(
int tilt)
199 visca->setPanTilt(pan_target, tilt);
203 SonyEviD100PControl::set_pan_tilt(
int pan,
int tilt)
207 visca->setPanTilt(pan, tilt);
211 SonyEviD100PControl::set_pan_tilt_rad(
float pan,
float tilt)
213 int tpan = 0, ttilt = 0;
215 tpan = (int)rint(pan * PAN_STEPS_PER_RAD);
216 ttilt = (int)rint(tilt * TILT_STEPS_PER_RAD);
218 set_pan_tilt(tpan, ttilt);
222 SonyEviD100PControl::start_get_pan_tilt()
224 visca->startGetPanTilt();
228 SonyEviD100PControl::pan_tilt(
int &pan,
int &tilt)
231 visca->getPanTilt(&tpan, &ttilt);
237 SonyEviD100PControl::pan_tilt_rad(
float &pan,
float &tilt)
239 int tpan = 0, ttilt = 0;
240 visca->getPanTilt(&tpan, &ttilt);
242 pan = tpan / PAN_STEPS_PER_RAD;
243 tilt = ttilt / PAN_STEPS_PER_RAD;
247 SonyEviD100PControl::pan()
249 int pan = 0, tilt = 0;
250 visca->getPanTilt(&pan, &tilt);
255 SonyEviD100PControl::tilt()
257 int pan = 0, tilt = 0;
258 visca->getPanTilt(&pan, &tilt);
263 SonyEviD100PControl::max_pan()
269 SonyEviD100PControl::min_pan()
275 SonyEviD100PControl::max_tilt()
281 SonyEviD100PControl::min_tilt()
287 SonyEviD100PControl::reset_pan_tilt()
289 visca->resetPanTilt();
293 SonyEviD100PControl::set_pan_tilt_limit(
int pan_left,
int pan_right,
int tilt_up,
int tilt_down)
295 visca->setPanTiltLimit(pan_left, pan_right, tilt_up, tilt_down);
299 SonyEviD100PControl::reset_pan_tilt_limit()
301 visca->resetPanTiltLimit();
305 SonyEviD100PControl::reset_zoom()
311 SonyEviD100PControl::set_zoom(
unsigned int zoom)
313 visca->setZoom(zoom);
317 SonyEviD100PControl::zoom()
320 visca->getZoom(&zoom);
325 SonyEviD100PControl::zoom_min()
331 SonyEviD100PControl::zoom_max()
337 SonyEviD100PControl::set_zoom_speed_tele(
unsigned int speed)
339 visca->setZoomSpeedTele(speed);
343 SonyEviD100PControl::set_zoom_speed_wide(
unsigned int speed)
345 visca->setZoomSpeedWide(speed);
349 SonyEviD100PControl::set_zoom_digital_enabled(
bool enabled)
351 visca->setZoomDigitalEnabled(enabled);
355 SonyEviD100PControl::supports_effect(
unsigned int effect_)
357 if (effect_ == EFFECT_NONE) {
363 case EFFECT_NEGATIVE:
366 case EFFECT_SOLARIZE:
369 case EFFECT_STRETCH:
return true;
break;
370 default:
return false;
375 SonyEviD100PControl::set_effect(
unsigned int effect_)
377 this->_effect = effect_;
378 if (effect_ == EFFECT_NONE) {
379 visca->resetEffect();
382 case EFFECT_PASTEL: visca->applyEffectPastel();
break;
383 case EFFECT_NEGATIVE: visca->applyEffectNegArt();
break;
384 case EFFECT_SEPIA: visca->applyEffectSepia();
break;
385 case EFFECT_BW: visca->applyEffectBnW();
break;
386 case EFFECT_SOLARIZE: visca->applyEffectSolarize();
break;
387 case EFFECT_MOSAIC: visca->applyEffectMosaic();
break;
388 case EFFECT_SLIM: visca->applyEffectSlim();
break;
389 case EFFECT_STRETCH: visca->applyEffectStretch();
break;
395 SonyEviD100PControl::effect()
401 SonyEviD100PControl::reset_effect()
403 visca->resetEffect();
410 SonyEviD100PControl::white_balance_mode()
412 return visca->getWhiteBalanceMode();
void append(const char *format,...) noexcept
Append messages to the message list.
std::string cam_id() const
Get camera ID.
Visca control protocol implementation over a serial line.
Fawkes library namespace.
float deg2rad(float deg)
Convert an angle given in degrees to radians.