Esempio n. 1
0
		FileLogger()
		{
			kString name = GetEnv()->GetEnvValue(Environment::ENV_KEY_LOG_DIR) + KT("/") + GetEnv()->GetEnvValue(Environment::ENV_KEY_APP_NAME) + KT(".log");
			m_LogFile.Open(name.c_str(), IOWrite);
			m_Thread = new Os::Thread([this]()->void {
				while (true)
				{
					if (m_Logs.empty())
					{
						unique_lock<std::mutex> uSignal(m_Signal);
						m_CV.wait(uSignal);
					}
					else
					{
						lock_guard<mutex> scopeLock(m_LogMutex);
						while (!m_Logs.empty())
						{
							std::string log = m_Logs.front();
							m_LogFile.Write(log.data(), log.size());
							m_Logs.pop();
						}
					}
				}
			}, "FileLogger");
			m_Thread->Start();
		}
//--------------------------------------------decomposeProhMats-------------------------------------------//
// through the projection matrix we can get nearly all the information of the cameras
// the position of the camera
// the direction of the camera
// the focal of the camera
// the axises of the camera
void Camera::decomposeProjMats()
{

    // 1.0 get direction
    this->dir_.at<float>(0) = this->project_.at<float>(2,0);
    this->dir_.at<float>(1) = this->project_.at<float>(2,1);
    this->dir_.at<float>(2) = this->project_.at<float>(2,2);
    this->dir_ = this->dir_/ norm(this->dir_);

    // 2.0 get position
    cv::Mat KR(3,3,CV_32FC1);
    cv::Mat KT(3,1,CV_32FC1);
    for(int i=0; i<3; i++)
    {
        for(int j=0; j<3; j++)
        {
            KR.at<float>(i,j) = this->project_.at<float>(i,j);
        }
    }
    for(int i=0; i<3; i++)
        KT.at<float>(i,0) = this->project_.at<float>(i,3);

    this->pos_ = -KR.inv()* KT;

    // 3.0 compute the focal
    cv::Mat R0(3,1, CV_32FC1);
    cv::Mat R1(3, 1, CV_32FC1);
    cv::Mat R2(3, 1, CV_32FC1);

    for(int i=0; i<3; i++)
    {
        R0.at<float>(i) = KR.at<float>(0, i);
        R1.at<float>(i) = KR.at<float>(1, i);
        R2.at<float>(i) = KR.at<float>(2, i);
    }

    this->focal_ = 0.5*abs(norm(R0.cross(R2)))+ 0.5*abs(norm(R1.cross(R2)));


    // 4.0 axises of the camera
    this->zaxis_ = this->dir_;
    this->yaxis_ = this->zaxis_.cross(R0);
    this->yaxis_ = this->yaxis_/norm(this->yaxis_);

    this->xaxis_ = this->yaxis_.cross(this->zaxis_);
    this->xaxis_ = this->xaxis_/norm(this->xaxis_);

    KR.release();
    KT.release();
    R0.release();
    R1.release();
    R2.release();
}
Esempio n. 3
0
File: kt.cpp Progetto: IMCG/icoding
int main()  
{  
    int a[] = {3, 5, 7, 4, 1, 2, 9, 6, 8};  
    printf("%d\n", 1 + KT(a, sizeof(a) / sizeof(*a))); ///1+98884  
}