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"; } }
void RoiCtrlObj::checkEspiaRoi(const Roi& set_roi, Roi& hw_roi, Size& det_frame_size, Roi& espia_roi) { DEB_MEMBER_FUNCT(); DEB_PARAM() << DEB_VAR2(set_roi, hw_roi); det_frame_size = hw_roi.getSize(); bool sg_roi = (!set_roi.isEmpty() && (hw_roi != set_roi)); if (sg_roi) { espia_roi = hw_roi.subRoiAbs2Rel(set_roi); int width = set_roi.getSize().getWidth(); bool horz_match = ((espia_roi.getTopLeft().x == 0) && (espia_roi.getSize().getWidth() == width)); sg_roi = (horz_match && ((width % 4) == 0)); } if (sg_roi) { DEB_TRACE() << "Horz. aligned roi qualifies for Espia SG!"; hw_roi = set_roi; } else espia_roi.reset(); DEB_RETURN() << DEB_VAR3(hw_roi, det_frame_size, espia_roi); }
Roi Roi::subRoiAbs2Rel(const Roi& abs_sub_roi) const { if (!containsRoi(abs_sub_roi)) throw LIMA_COM_EXC(InvalidValue, "Given roi is not sub roi"); const Point& tl = getTopLeft(); return Roi(abs_sub_roi.getTopLeft() - tl, abs_sub_roi.getSize()); }
Roi Roi::subRoiRel2Abs(const Roi& rel_sub_roi) const { Roi aux(0, getSize()); if (!aux.containsRoi(rel_sub_roi)) throw LIMA_COM_EXC(InvalidValue, "Given roi is not sub roi"); const Point& tl = getTopLeft(); return Roi(rel_sub_roi.getTopLeft() + tl, rel_sub_roi.getSize()); }
virtual void store(Setting& image_setting) { CtImage::ImageOpMode imageOpMode; m_image.getMode(imageOpMode); image_setting.set("imageOpMode",convert_2_string(imageOpMode)); // --- Roi Roi roi; m_image.getRoi(roi); Setting roi_setting = image_setting.addChild("roi"); const Point& topleft = roi.getTopLeft(); roi_setting.set("x",topleft.x); roi_setting.set("y",topleft.y); const Size& roiSize = roi.getSize(); roi_setting.set("width",roiSize.getWidth()); roi_setting.set("height",roiSize.getHeight()); // --- Bin Bin bin; m_image.getBin(bin); Setting bin_setting = image_setting.addChild("bin"); bin_setting.set("x",bin.getX()); bin_setting.set("y",bin.getY()); // --- Flip Flip flip; m_image.getFlip(flip); Setting flip_setting = image_setting.addChild("flip"); flip_setting.set("x",flip.x); flip_setting.set("y",flip.y); // --- Rotation RotationMode rMode; m_image.getRotation(rMode); image_setting.set("rotation",convert_2_string(rMode)); }