/* ---------------------- */ sf::Image *ImageManager::GetImage(const std::string &ImageLink) { sf::Image *ImgTemp; //Si l'image demandée n'existe pas déjà, on la créée if(!SearchImage(ImageLink, ImgTemp)) { ImgTemp = CreateImage(ImageLink); } return ImgTemp; }
/** * @author JIA Pei, YAO Wei * @version 2010-05-20 * @brief Additive ASM ND Profiles Fitting, for dynamic image sequence * @param iImg Input - image to be fitted * @param ioShape Input and output - the shape * @param oImg Output - the fitted image * @param dim Input - profile dimension, 1, 2, 4 or 8 * @param epoch Input - the iteration epoch * @param pyramidlevel Input - pyramid level, 1, 2, 3 or 4 at most * @note Refer to "AAM Revisited, page 34, figure 13", particularly, those steps. */ float VO_FittingASMNDProfiles::VO_ASMNDProfileFitting( const cv::Mat& iImg, VO_Shape& ioShape, cv::Mat& oImg, unsigned int epoch, unsigned int pyramidlevel, unsigned int dim) { this->m_VOFittingShape.clone(ioShape); double t = (double)cv::getTickCount(); this->m_iNbOfPyramidLevels = pyramidlevel; this->SetProcessingImage(iImg, this->m_VOASMNDProfile); this->m_iIteration = 0; // Get m_MatModelAlignedShapeParam and m_fScale, m_vRotateAngles, m_MatCenterOfGravity this->m_VOASMNDProfile->VO_CalcAllParams4AnyShapeWithConstrain( this->m_VOFittingShape, this->m_MatModelAlignedShapeParam, this->m_fScale, this->m_vRotateAngles, this->m_MatCenterOfGravity); this->m_VOFittingShape.ConstrainShapeInImage(this->m_ImageProcessing); // Explained by YAO Wei, 2008-2-9. // Scale this->m_VOFittingShape, so face width is a constant StdFaceWidth. //this->m_fScale2 = this->m_VOASMNDProfile->m_VOReferenceShape.GetWidth() / this->m_VOFittingShape.GetWidth(); this->m_fScale2 = this->m_VOASMNDProfile->m_VOReferenceShape.GetCentralizedShapeSize() / this->m_VOFittingShape.GetCentralizedShapeSize(); this->m_VOFittingShape *= this->m_fScale2; int w = (int)(iImg.cols*this->m_fScale2); int h = (int)(iImg.rows*this->m_fScale2); cv::Mat SearchImage = cv::Mat(cv::Size( w, h ), this->m_ImageProcessing.type(), this->m_ImageProcessing.channels() ); float PyrScale = pow(2.0f, (float) (this->m_iNbOfPyramidLevels-1.0f) ); this->m_VOFittingShape /= PyrScale; const int nQualifyingDisplacements = (int)(this->m_VOASMNDProfile->m_iNbOfPoints * VO_Fitting2DSM::pClose); // for each level in the image pyramid for (int iLev = this->m_iNbOfPyramidLevels-1; iLev >= 0; iLev--) { // Set image roi, instead of cvCreateImage a new image to speed up cv::Mat siROI = SearchImage(cv::Rect(0, 0, (int)(w/PyrScale), (int)(h/PyrScale) ) ); cv::resize(this->m_ImageProcessing, siROI, siROI.size()); this->m_VOEstimatedShape = this->m_VOFittingShape; this->PyramidFit( this->m_VOEstimatedShape, SearchImage, iLev, VO_Fitting2DSM::pClose, epoch, dim); this->m_VOFittingShape = this->m_VOEstimatedShape; if (iLev != 0) { PyrScale /= 2.0f; this->m_VOFittingShape *= 2.0f; } } // Explained by YAO Wei, 2008-02-09. // this->m_fScale2 back to original size this->m_VOFittingShape /= this->m_fScale2; ioShape.clone(this->m_VOFittingShape); VO_Fitting2DSM::VO_DrawMesh(ioShape, this->m_VOASMNDProfile, oImg); t = ((double)cv::getTickCount() - t )/ (cv::getTickFrequency()*1000.); printf("MRASM fitting time cost: %.2f millisec\n", t); this->m_fFittingTime = t; return t; }