void Camera::setRoi(const Roi& set_roi)
{
    DEB_MEMBER_FUNCT();
    DEB_PARAM() << DEB_VAR1(set_roi);
    try
    {
        Point topleft, size;
        Roi hw_roi;
        getRoi(hw_roi);
        if (hw_roi == set_roi) return;

        if (set_roi.isActive())
        {
            // --- a real roi available
            hw_roi = set_roi;

            //- set the new roi values
            //- cmd format is : "set_roi,x0,y0,x1,y1"
            std::stringstream strRoi;
            strRoi << "set_roi"
                << ","
                << set_roi.getTopLeft().x
                << ","
                << set_roi.getTopLeft().y
                << ","
                << set_roi.getTopLeft().x + set_roi.getSize().getWidth()
                << ","
                << set_roi.getTopLeft().y + set_roi.getSize().getHeight();
            {
                yat::MutexLock scoped_lock(m_lock_data);
                _sendCmdAndReceiveAnswer(strRoi.str());
            }
        }
    }
    catch (yat::SocketException & ySe)
    {
        std::stringstream ssError;
        for (unsigned i = 0; i < ySe.errors.size(); i++)
        {
            ssError << ySe.errors[i].desc << std::endl;
        }

        THROW_HW_ERROR(Error) << ssError.str();
    }
    catch (...)
    {
        THROW_HW_ERROR(Error) << "setRoi : Unknown Exception";
    }
}
Beispiel #2
0
void RoiCtrlObj::setRoi(const Roi& set_roi)
{
  DEB_MEMBER_FUNCT();
  
  ROIS::const_iterator i;
  if(set_roi.isActive())
    {
      i = _getRoi(set_roi);
      if(i == m_possible_rois.end())
	THROW_HW_ERROR(Error) << "Something weird happen";
    }
  else
    i = --m_possible_rois.end(); // full_frame

 
  if(m_has_hardware_roi)
    m_cam.setRoi(i->first.pattern);
  
  m_current_roi = i->second;
  m_current_max_frequency = i->first.max_frequency;
}