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);
}
Ejemplo n.º 2
0
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";
    }
}
Ejemplo n.º 3
0
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());
}
Ejemplo n.º 4
0
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());
}
void RoiCtrlObj::getRoi(Roi& hw_roi)
{
	DEB_MEMBER_FUNCT();
	m_cam.getRoi(hw_roi);

	Size det_frame_size;
	Roi espia_roi;
	m_acq.getSGRoi(det_frame_size, espia_roi);
	if (!espia_roi.isEmpty()) {
		if (det_frame_size != hw_roi.getSize())
			THROW_HW_ERROR(Error) << "Camera/Espia roi mismatch: "
					      << DEB_VAR2(det_frame_size, 
							  hw_roi);
		Roi final_hw_roi = hw_roi.subRoiRel2Abs(espia_roi);
		hw_roi = final_hw_roi;
	}

	DEB_RETURN() << DEB_VAR1(hw_roi);
}
Ejemplo n.º 6
0
/***************************************************************//**
 * @brief Checks the consistency of FrameDim, Bin and RoI
 *
 * First checks if Binning is valid
 * Then checks if FrameDim is inside of the MaxImageSize
 * Finally checks if the RoI is consistent with the binned frame dim
 *******************************************************************/
void FrameBuilder::checkValid( const FrameDim &frame_dim, const Bin &bin, 
                               const Roi &roi ) throw(Exception)
{
	Size max_size;
	getMaxImageSize( max_size );

	Bin valid_bin = bin;
	checkBin(valid_bin);
	if (valid_bin != bin)
		throw LIMA_HW_EXC(InvalidValue, "Invalid bin");

	if( (frame_dim.getSize().getWidth()  > max_size.getWidth()) ||
	    (frame_dim.getSize().getHeight() > max_size.getHeight()) )
		throw LIMA_HW_EXC(InvalidValue, "Frame size too big");

	FrameDim bin_dim = frame_dim / bin;

	if( roi.getSize() != 0 ) {
		bin_dim.checkValidRoi(roi);
	}
}
Ejemplo n.º 7
0
  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));
  }