Beispiel #1
0
    void WriteFile(const std::string& filename) {
        std::ofstream of(filename.c_str());

        of<< "ply"
          << '\n' << "format ascii 1.0"
          << '\n' << "element vertex " << num_cameras_ + num_points_
          << '\n' << "property float x"
          << '\n' << "property float y"
          << '\n' << "property float z"
          << '\n' << "property uchar red"
          << '\n' << "property uchar green"
          << '\n' << "property uchar blue"
          << '\n' << "end_header" << std::endl;

        // Export extrinsic data (i.e. camera centers) as green points.
        double angle_axis[3];
        double center[3];
        for(int i = 0; i < num_cameras_; ++i){
            const double* camera = mutable_cameras() + 9 * i;
            ceres::AngleAxisRotatePoint(camera, angle_axis, center);
            of << center[0] << ' ' << center[1] << ' ' << center[2]
               << "0 255 0" << '\n';
        }

        // Export the structure (i.e. 3D Points) as white points.
        const double* points = parameters_ + 9 * num_cameras_;
        for(int i = 0; i < num_points_; ++i){
            const double* point = points + i * 3;
            for(int j = 0; j < 3; ++j){
                of << point[j] << ' ';
            }
            of << "255 255 255\n";
        }
        of.close();
    }
 /// Return a pointer to the camera that observe the Inth observation
 double* mutable_camera_for_observation(size_t i) {
   return mutable_cameras() + camera_index_[i] * NCamParam;
 }
Beispiel #3
0
 double* mutable_camera_for_observation(int i) {
     return mutable_cameras() + camera_index_[i] * 9;
 }