Beispiel #1
0
WarpCost::WarpCost(const Warper& warper,
                   const cv::Mat& J,
                   const cv::Mat& I,
                   const cv::Mat& dIdx,
                   const cv::Mat& dIdy,
                   const cv::Mat& mask,
                   int interpolation,
                   bool check_condition,
                   double max_condition)
    : warper_(&warper),
      J_(&J),
      I_(&I),
      dIdx_(&dIdx),
      dIdy_(&dIdy),
      mask_(&mask),
      interpolation_(interpolation),
      check_condition_(check_condition),
      max_condition_(max_condition) {
  // Check that we have a square patch.
  CHECK(J.rows == J.cols);
  // Check that mask is correct size.
  CHECK(mask.size() == J.size());

  // Set the number of inputs (configure as a single block).
  mutable_parameter_block_sizes()->push_back(warper_->numParams());

  // Set the number of outputs.
  set_num_residuals(J.total());
}
MarginalizationFactor::MarginalizationFactor(MarginalizationInfo* _marginalization_info):marginalization_info(_marginalization_info)
{
    int cnt = 0;
    for (auto it : marginalization_info->keep_block_size)
    {
        mutable_parameter_block_sizes()->push_back(it);
        cnt += it;
    }
    //printf("residual size: %d, %d\n", cnt, n);
    set_num_residuals(marginalization_info->n);
};
Beispiel #3
0
DiskAndDeltaCost::DiskAndDeltaCost(float* u, float* v,
                                   float* V_real, 
                                   float* V_imag,
                                   float* weights, 
                                   int* flags,
                                   const int nchan, 
                                   const int nstokes,
								   const int nrow)
                                  : _nchan(nchan), _nstokes(nstokes), _nrow(nrow)
{
	for(int i = 0; i < 5; i++) {
		mutable_parameter_block_sizes()->push_back(1);
	}

	set_num_residuals(2*_nchan*_nstokes*_nrow);

	_u = new double[_nchan*_nstokes*_nrow];
	_v = new double[_nchan*_nstokes*_nrow];
	_V_real  = new double[_nchan*_nstokes*_nrow];
	_V_imag  = new double[_nchan*_nstokes*_nrow];
	_flags   = new   bool[_nchan*_nstokes*_nrow];
	sqrt_weights = new double[_nstokes*_nrow];

	size_t index;
	for(int uvrow = 0; uvrow < _nrow; uvrow++)
	{
		for(int chan = 0; chan < _nchan; chan++)
		{
			for(int pol = 0; pol < _nstokes; pol++)
			{
				index = _nstokes*_nchan*uvrow+chan+pol*_nchan;
				_u[index]      = (double)u     [index];
				_v[index]      = (double)v     [index];
				_V_real[index] = (double)V_real[index];
				_V_imag[index] = (double)V_imag[index];
				if(flags != NULL)
					_flags[index]  = flags [index];

				if(chan == 0) 
				{
					sqrt_weights[_nstokes*uvrow+pol] =
						sqrt((double)weights[_nstokes*_nchan*uvrow+pol]);
				}
			}
		}
	}
}