NViewDataSet NRealisticCamerasCardioid(size_t nviews, size_t npoints, const nViewDatasetConfigurator config) { //-- Setup a camera circle rig. NViewDataSet d; d._n = nviews; d._K.resize(nviews); d._R.resize(nviews); d._t.resize(nviews); d.C.resize(nviews); d._x.resize(nviews); d._x_ids.resize(nviews); d.X.resize(3, npoints); d.X.setRandom(); d.X *= 0.6; Vecu all_point_ids(npoints); for (size_t j = 0; j < npoints; ++j) all_point_ids[j] = j; for (size_t i = 0; i < nviews; ++i) { Vec3 camera_center, t, jitter, lookdir; const double theta = i * 2 * M_PI / nviews; //-- Cardioid camera_center << 2*sin(theta)-(sin(2*theta)), 0.0, 2*cos(theta)-(cos(2*theta)); // Y axis UP camera_center *= config._dist; d.C[i] = camera_center; jitter.setRandom(); jitter *= config._jitter_amount / camera_center.norm(); lookdir = -camera_center + jitter; d._K[i] << config._fx, 0, config._cx, 0, config._fy, config._cy, 0, 0, 1; d._R[i] = LookAt(lookdir); // Y axis UP d._t[i] = -d._R[i] * camera_center; // [t]=[-RC] Cf HZ. d._x[i] = Project(d.P(i), d.X); d._x_ids[i] = all_point_ids; } return d; }
NViewDataSet NRealisticCamerasCardioid(size_t nviews, size_t npoints, const NViewDatasetConfigurator config) { // 设置相机参数 NViewDataSet d; d.actual_camera_num_ = nviews; d.camera_matrix_.resize(nviews); d.rotation_matrix_.resize(nviews); d.translation_vector_.resize(nviews); d.camera_center_.resize(nviews); d.projected_points_.resize(nviews); d.projected_point_ids_.resize(nviews); d.point_3d_.resize(3, npoints); d.point_3d_.setRandom(); d.point_3d_ *= 0.6; Vecu all_point_ids(npoints); for (size_t j = 0; j < npoints; ++j) all_point_ids[j] = j; for (size_t i = 0; i < nviews; ++i) { Vec3 camera_center, t, jitter, lookdir; const double theta = i * 2 * M_PI / nviews; // 心形方程式,确定中点 camera_center << 2 * sin(theta) - (sin(2 * theta)), 0.0, 2 * cos(theta) - (cos(2 * theta)); // Y axis UP camera_center *= config._dist; d.camera_center_[i] = camera_center; jitter.setRandom(); jitter *= config._jitter_amount / camera_center.norm(); lookdir = -camera_center + jitter; d.camera_matrix_[i] << config._fx, 0, config._cx, 0, config._fy, config._cy, 0, 0, 1; d.rotation_matrix_[i] = LookAt(lookdir); // Y axis UP d.translation_vector_[i] = -d.rotation_matrix_[i] * camera_center; // [t]=[-RC] Cf HZ. d.projected_points_[i] = Project(d.P(i), d.point_3d_); d.projected_point_ids_[i] = all_point_ids; } return d; }