Exemplo n.º 1
0
bool MFReconstruct::runReconstruction()
{
    bool runSucess = false;

    ///加载相机标定参数及所采集图像
    for(int i = 0; i < 2; i++){
        camsPixels[i] = new cv::vector<double>[cameraHeight * cameraWidth];//将每个相机图像中的每个像素在投影区域中的横坐标记录

        runSucess = loadCamImgs(scanFolder[i], imgPrefix[i], imgSuffix);

        ///对指针存储器camsPixels赋值,camsPixels[i]的地址就是camPixel的地址
        camPixels = camsPixels[i];

        ///截至这一步,实例camera的position、width、height属性已被赋值,camera对应cameras[i]
        if(!runSucess)//如果加载图片失败,中断
            break;
        else{
            computeShadows();
            decodePatterns();
            unloadCamImgs();
        }
    }

    if(runSucess){
        points3DProjView = new PointCloudImage(cameraWidth, cameraHeight, haveColor); //最后一个bool值代表是否上色,这里改为false
        triangulation(camsPixels[0],camsPixels[1]);
    }
    return runSucess;
}
void Reconstructor::runReconstruction()
{
	for(int i=0; i< numOfCams; i++)
	{
		if(cameras[i].distortion.empty())
		{
			std::cout<<"Camera "<<i<< "is not set.\n";
			exit(-1);
		}

		if(pathSet[i] == false)
		{
			std::cout<<"Image path for camera "<< i <<" is not set.";
			exit(-1);
		}
	}

	GrayCodes grays(proj_w,proj_h);

	numOfColBits = grays.getNumOfColBits();
	numOfRowBits = grays.getNumOfRowBits();
	numberOfImgs = grays.getNumOfImgs();
	

	for(int i=0; i < numOfCams; i++)
	{

		//findProjectorCenter();
		cameras[i].position = cv::Point3f(0,0,0);
		cam2WorldSpace(cameras[i],cameras[i].position);
	
		camera = &cameras[i];
		camsPixels[i] = new cv::vector<cv::Point>[proj_h*proj_w];
		camPixels = camsPixels[i];

		loadCamImgs(camFolder[i],imgPrefix[i],imgSuffix[i]);

		colorImgs.push_back(cv::Mat());
		colorImgs[i] = color;
		computeShadows();
		if(saveShadowMask_)
		{
			std::stringstream path;
			path<<"cam"<<i+1<<"Mask.png";
			saveShadowImg(path.str().c_str());
		}
		
		decodePaterns();

		unloadCamImgs();
	}
	
	//reconstruct 
	points3DProjView = new PointCloudImage( proj_w, proj_h , true );
	
	for(int i = 0; i < numOfCams; i++)
	{
		for(int j=i+1; j< numOfCams; j++)
			triangulation(camsPixels[i],cameras[i],camsPixels[j],cameras[j],i,j);
	}

}