예제 #1
0
Eigen::Vector3f PhotoCamera::unproject(const Eigen::Vector2f &pixel)
{
    Eigen::Vector3f pixelH;
    pixelH << pixel(0), pixel(1), 1;
    Eigen::MatrixXf pseudoInverse = getPseudoInverse();
    Eigen::Vector4f XH = pseudoInverse*pixelH;
    Eigen::Vector3f p = XH.hnormalized();
    Eigen::Vector3f ray = p - cameraCenter.hnormalized();
    ray /= ray.norm();

    return ray;
}
예제 #2
0
void CLinearRegression::calculateRegressionMatrix(CDataSet *dataSet, CDataSet1D *outputValues, DataSubset *subset)
{
	if (subset)
	{
		assert((signed int) subset->size() == X->nrows());
		DataSubset::iterator it = subset->begin();
		for (int i = 0; it != subset->end(); it ++, i++)
		{
			yVector->element(i) = (*outputValues)[*it];

			getXVector((*dataSet)[*it], xVector);

			for (int j = 0; j < xVector->size(); j ++)
			{
				X->element(i, j) = xVector->element(j);	
			}
		}
	}
	else
	{
		assert(dataSet->size() == (unsigned int) X->nrows());
		
		for (unsigned int i = 0; i < dataSet->size();  i++)
		{
			yVector->element(i) = (*outputValues)[i];

			getXVector((*dataSet)[i], xVector);

			for (int j = 0; j < xVector->size(); j ++)
			{
				X->element(i, j) = xVector->element(j);	
			}
		}
	
	}

	//printf("X: %d %d  X_pinv: %d %d\n", X->nrows(), X->ncols(), X_pinv->nrows(), X_pinv->ncols());
	getPseudoInverse(X, X_pinv, lambda);

	*w = (*X_pinv) * (*yVector);
}