8 point_file.open(filename);
10 point_file <<
"ply" << endl;
11 point_file <<
"format ascii 1.0" << endl;
12 point_file <<
"element vertex "<< std::to_string(size)<< endl;
13 point_file <<
"property float x\nproperty float y\nproperty float z" << endl;
14 point_file <<
"property uchar red\nproperty uchar green\nproperty uchar blue" << endl;
16 point_file <<
"end_header" << endl;
18 for(
int i=0;i<rcb.size();i++){
19 for(
int j=0;j<rcb[i].size();j++){
21 point_file << rcb[i][j][k] <<
" ";
23 point_file << i*255/rcb.size() <<
" " << i*255/rcb.size() <<
" " << i*255/rcb.size() << endl;
35 point_file.open(filename);
37 point_file <<
"ply" << std::endl;
38 point_file <<
"format ascii 1.0" << std::endl;
39 point_file <<
"element vertex "<< std::to_string(size +image_pose_buffer.size()) << std::endl;
40 point_file <<
"property float x\nproperty float y\nproperty float z" << std::endl;
41 point_file <<
"property uchar red\nproperty uchar green\nproperty uchar blue" << std::endl;
44 point_file <<
"end_header" << std::endl;
46 for(
int i=0;i<rcb.size();i++){
47 for(
int j=0;j<rcb[i].size();j++){
49 point_file << rcb[i][j][k] <<
" ";
51 point_file << i*255/rcb.size() <<
" " << i*255/rcb.size() <<
" " << i*255/rcb.size() << std::endl;
58 for(
int i=0;i<image_pose_buffer.size();i++){
61 dst = image_pose_buffer[i].pose.translation();
62 point_file << dst[0] <<
" " << dst[1] <<
" " << dst[2] <<
" 255 0 0"<< endl;
64 point_file << dst[0] <<
" " << dst[1] <<
" " << dst[2] <<
" 0 255 0"<< endl;
72 if(b_rects.size() > 0) {
74 point_file.open(filename);
76 point_file <<
"ply" << std::endl;
77 point_file <<
"format ascii 1.0" << std::endl;
78 point_file <<
"element vertex "<<to_string(size)<< std::endl;
79 point_file <<
"property float x\nproperty float y\nproperty float z" << std::endl;
80 point_file <<
"property uchar red\nproperty uchar green\nproperty uchar blue" << std::endl;
82 point_file <<
"element face " << to_string(size/4) << std::endl;
83 point_file <<
"property list uchar int vertex_index" << std::endl;
85 point_file <<
"end_header" << std::endl;
87 for(
int i=0;i<b_rects.size();i++){
88 for(
int j=0;j<b_rects[i].size();j++){
90 point_file << b_rects[i][j].x <<
" " << b_rects[i][j].y <<
" " << b_rects[i][j].z <<
" " ;
92 point_file << i*255/b_rects.size() <<
" " << i*255/b_rects.size() <<
" " << i*255/b_rects.size() << std::endl;
96 for(
int i=0;i<size;i+=4){
97 point_file <<
"4 " << i <<
" " << i+1 <<
" " << i+2 <<
" " << i+3 << std::endl;
100 std::cout <<
"saved BoundingBoxes to " << filename << std::endl;
104 std::cout <<
"Couldn't save. Bounding Rects = 0" << std::endl;
bool saveBoundingRectangles(const char *filename, std::vector< std::vector< cv::Point3f > > b_rects, int size)
bool savePoints(const char *filename, std::vector< std::vector< lvr::ColorVertex< float, unsigned char > > > rcb, int size)
bool savePointsWithCameras(const char *filename, std::vector< std::vector< lvr::ColorVertex< float, unsigned char > > > rcb, int size, std::vector< kfusion::ImgPose > image_pose_buffer)