#include "Utils.h"
/** The default constructor of the CSV reader Class */
-CsvReader::CsvReader(const std::string &path, const char &separator){
+CsvReader::CsvReader(const string &path, const char &separator){
_file.open(path.c_str(), ifstream::in);
_separator = separator;
}
/* Read a plane text file with .ply format */
-void CsvReader::readPLY(std::vector<cv::Point3f> &list_vertex, std::vector<std::vector<int> > &list_triangles)
+void CsvReader::readPLY(vector<Point3f> &list_vertex, vector<vector<int> > &list_triangles)
{
std::string line, tmp_str, n;
int num_vertex = 0, num_triangles = 0;
// read faces and add into 'list_triangles'
else if(end_vertex && count < num_triangles)
{
- std::string num_pts_per_face, id0, id1, id2;
+ string num_pts_per_face, id0, id1, id2;
getline(liness, num_pts_per_face, _separator);
getline(liness, id0, _separator);
getline(liness, id1, _separator);
#include <iostream>
#include <fstream>
-
#include <opencv2/core/core.hpp>
using namespace std;
* @param separator - The separator character between words per line
* @return
*/
- CsvReader(const std::string &path, const char &separator = ' ');
+ CsvReader(const string &path, const char &separator = ' ');
/**
* Read a plane text file with .ply format
* @param list_triangle - The container of the triangles list of the mesh
* @return
*/
- void readPLY(std::vector<cv::Point3f> &list_vertex, std::vector<std::vector<int> > &list_triangles);
+ void readPLY(vector<Point3f> &list_vertex, vector<vector<int> > &list_triangles);
private:
/** The current stream file for the reader */
#include "CsvWriter.h"
#include "Utils.h"
-CsvWriter::CsvWriter(const std::string &path, const std::string &separator){
- _file.open(path.c_str(), std::ofstream::out);
+CsvWriter::CsvWriter(const string &path, const string &separator){
+ _file.open(path.c_str(), ofstream::out);
_isFirstTerm = true;
_separator = separator;
}
_file.close();
}
-void CsvWriter::writeXYZ(const std::vector<cv::Point3f> &list_points3d)
+void CsvWriter::writeXYZ(const vector<Point3f> &list_points3d)
{
- std::string x, y, z;
+ string x, y, z;
for(unsigned int i = 0; i < list_points3d.size(); ++i)
{
x = FloatToString(list_points3d[i].x);
}
-void CsvWriter::writeUVXYZ(const std::vector<cv::Point3f> &list_points3d, const std::vector<cv::Point2f> &list_points2d, const cv::Mat &descriptors)
+void CsvWriter::writeUVXYZ(const vector<Point3f> &list_points3d, const vector<Point2f> &list_points2d, const Mat &descriptors)
{
- std::string u, v, x, y, z, descriptor_str;
+ string u, v, x, y, z, descriptor_str;
for(unsigned int i = 0; i < list_points3d.size(); ++i)
{
u = FloatToString(list_points2d[i].x);
for(int j = 0; j < 32; ++j)
{
- descriptor_str = FloatToString((float)descriptors.at<float>(i,j));
+ descriptor_str = FloatToString(descriptors.at<float>(i,j));
_file << _separator << descriptor_str;
}
_file << std::endl;
#ifndef CSVWRITER_H
#define CSVWRITER_H
-#include <fstream>
#include <iostream>
-
+#include <fstream>
#include <opencv2/core/core.hpp>
+using namespace std;
+using namespace cv;
+
class CsvWriter {
public:
- CsvWriter(const std::string &path, const std::string &separator = " ");
+ CsvWriter(const string &path, const string &separator = " ");
~CsvWriter();
- void writeXYZ(const std::vector<cv::Point3f> &list_points3d);
- void writeUVXYZ(const std::vector<cv::Point3f> &list_points3d, const std::vector<cv::Point2f> &list_points2d, const cv::Mat &descriptors);
+ void writeXYZ(const vector<Point3f> &list_points3d);
+ void writeUVXYZ(const vector<Point3f> &list_points3d, const vector<Point2f> &list_points2d, const Mat &descriptors);
private:
- std::ofstream _file;
- std::string _separator;
+ ofstream _file;
+ string _separator;
bool _isFirstTerm;
};