vi : (x_i
,y_i,z_i
)---model vertex position
g(u): which maps 2D points u to 3D world points using camera information.
depth image—width
: w, height :h ,camera
focal length :f
u:( p,q ) - 2D depth image coordinate( the image location of the closet point to vi)
The point term consists of three residual terms : ||xi-gx|| ,||yi-gy|| ,||zi - gz||
gx,gy and gz are the x,y,z components of g(u) .
Code:
The depth value could not be expressed by a explicit formula ,so i want to calculate the Jacobian martix by analytic method.But i am confused about this.
I set 3 residuals,2 parameter blocks
parameter block1: xyz
parameter block2:pq
class PointFunctor:public ceres::SizedCostFunction<3,3,2>{//xyz,pq
public:
virtual ~PointFunctor(){}
virtual bool Evaluate(const double * const *parameters, double *residuals, double **jacobians) const{
//camera parameters
int depth_image_width = 320;
int depth_image_height = 240;
double focal_len = 578.5;
//3D model vertex position
double x_model = parameters[0][0];
double y_model = parameters[0][1];
double z_model = parameters[0][2];
//u position in the depth imag
double p = parameters[0][3];
double q = parameters[0][4];
double depth_value = bilinearInterpolation(p,q);//the depth value need to be interpolated
//map 2D depth point u(p,q) to 3D world points using camera parameters.
double x_depth = (p - depth_image_width/2) * depth_value / focal_len;
double y_depth = (depth_image_height/2 -q) * depth_value / focal_len;
double z_depth = depth_value;
residuals[0] = x_model - x_depth;
residuals[1] = y_model - y_depth;
residuals[2] = z_model - z_depth;
//which form should i adopt.?? or other form?
//1.
if( !jacobians ){
return true;
}
double *jacobian = jacobians[0];//??
if( !jacobian ){
return true;
}
jacobian[0]= function expression;
jacobian[1]= function expression;
jacobian[2]= function expression;
jacobian[3]= function expression;
jacobian[4]= function expression;
//2.?
jacobians[0][0] = function expression;
jacobians[0][1] = function expression;
jacobians[0][2] = function expression;
jacobians[0][3] = function expression;
jacobians[0][4] = function expression;
jacobians[1][0] = function expression;
jacobians[1][1] = function expression;
jacobians[1][2] = function expression;
jacobians[1][3] = function expression;
jacobians[1][4] = function expression;
jacobians[2][0] = function expression;
jacobians[2][1] = function expression;
jacobians[2][2] = function expression;
jacobians[2][3] = function expression;
jacobians[2][4] = function expression;
return true;
}
};Should i code like this?
//i=0,1,2,3,4
jacobians[0][i] =some expression;
jacobians[1][i]=some expression;
jacobians[2][i] =some expression;
jacobians[0] =some expression;
jacobians[1]=some expression;
jacobians[2] =some expression;
jacobians[3] =some expression;
jacobians[4] =some expression; or else?
Thanks,
walden
--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/7c47d5ce-faec-49b5-b128-64d2df2907b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/f848f0ac-21df-47b2-a81b-dfb553c72a9f%40googlegroups.com.