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()
143 SonyEviD100PControl::open()
149 visca->open(tty_port);
150 visca->set_address(1);
154 e.
append(
"Sony EviD100PControl failed");
164 SonyEviD100PControl::close()
172 SonyEviD100PControl::process_pantilt()
178 SonyEviD100PControl::supports_pan()
184 SonyEviD100PControl::supports_tilt()
190 SonyEviD100PControl::set_pan(
int pan)
193 visca->setPanTilt(pan, tilt_target);
197 SonyEviD100PControl::set_tilt(
int tilt)
200 visca->setPanTilt(pan_target, tilt);
204 SonyEviD100PControl::set_pan_tilt(
int pan,
int tilt)
208 visca->setPanTilt(pan, tilt);
212 SonyEviD100PControl::set_pan_tilt_rad(
float pan,
float tilt)
214 int tpan = 0, ttilt = 0;
216 tpan = (int)rint(pan * PAN_STEPS_PER_RAD);
217 ttilt = (int)rint(tilt * TILT_STEPS_PER_RAD);
219 set_pan_tilt(tpan, ttilt);
223 SonyEviD100PControl::start_get_pan_tilt()
225 visca->startGetPanTilt();
229 SonyEviD100PControl::pan_tilt(
int &pan,
int &tilt)
232 visca->getPanTilt(&tpan, &ttilt);
238 SonyEviD100PControl::pan_tilt_rad(
float &pan,
float &tilt)
240 int tpan = 0, ttilt = 0;
241 visca->getPanTilt(&tpan, &ttilt);
243 pan = tpan / PAN_STEPS_PER_RAD;
244 tilt = ttilt / PAN_STEPS_PER_RAD;
248 SonyEviD100PControl::pan()
250 int pan = 0, tilt = 0;
251 visca->getPanTilt(&pan, &tilt);
256 SonyEviD100PControl::tilt()
258 int pan = 0, tilt = 0;
259 visca->getPanTilt(&pan, &tilt);
264 SonyEviD100PControl::max_pan()
270 SonyEviD100PControl::min_pan()
276 SonyEviD100PControl::max_tilt()
282 SonyEviD100PControl::min_tilt()
288 SonyEviD100PControl::reset_pan_tilt()
290 visca->resetPanTilt();
294 SonyEviD100PControl::set_pan_tilt_limit(
int pan_left,
int pan_right,
int tilt_up,
int tilt_down)
296 visca->setPanTiltLimit(pan_left, pan_right, tilt_up, tilt_down);
300 SonyEviD100PControl::reset_pan_tilt_limit()
302 visca->resetPanTiltLimit();
306 SonyEviD100PControl::reset_zoom()
312 SonyEviD100PControl::set_zoom(
unsigned int zoom)
314 visca->setZoom(zoom);
318 SonyEviD100PControl::zoom()
321 visca->getZoom(&zoom);
326 SonyEviD100PControl::zoom_min()
332 SonyEviD100PControl::zoom_max()
338 SonyEviD100PControl::set_zoom_speed_tele(
unsigned int speed)
340 visca->setZoomSpeedTele(speed);
344 SonyEviD100PControl::set_zoom_speed_wide(
unsigned int speed)
346 visca->setZoomSpeedWide(speed);
350 SonyEviD100PControl::set_zoom_digital_enabled(
bool enabled)
352 visca->setZoomDigitalEnabled(enabled);
356 SonyEviD100PControl::supports_effect(
unsigned int effect_)
358 if (effect_ == EFFECT_NONE) {
364 case EFFECT_NEGATIVE:
367 case EFFECT_SOLARIZE:
370 case EFFECT_STRETCH:
return true;
break;
371 default:
return false;
376 SonyEviD100PControl::set_effect(
unsigned int effect_)
378 this->_effect = effect_;
379 if (effect_ == EFFECT_NONE) {
380 visca->resetEffect();
383 case EFFECT_PASTEL: visca->applyEffectPastel();
break;
384 case EFFECT_NEGATIVE: visca->applyEffectNegArt();
break;
385 case EFFECT_SEPIA: visca->applyEffectSepia();
break;
386 case EFFECT_BW: visca->applyEffectBnW();
break;
387 case EFFECT_SOLARIZE: visca->applyEffectSolarize();
break;
388 case EFFECT_MOSAIC: visca->applyEffectMosaic();
break;
389 case EFFECT_SLIM: visca->applyEffectSlim();
break;
390 case EFFECT_STRETCH: visca->applyEffectStretch();
break;
396 SonyEviD100PControl::effect()
402 SonyEviD100PControl::reset_effect()
404 visca->resetEffect();
411 SonyEviD100PControl::white_balance_mode()
413 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.