Esempio n. 1
1
void Calibration::xyWorldPoints()
{
	int cols = find_chessboard.grid.width;
	int npts = find_chessboard.grid.area();
	vector<Point3f> world_loc;
    for(int i = 0; i < npts; ++i) {
        float x = (float) (i % cols);
        float y = (float) (-i / cols);
        world_loc.push_back(Point3f(x, y, 0));
    }

	views.world.assign(views.n, world_loc);
}
Esempio n. 2
0
bool Calibration::loadWorldPoints(string filename)
{
	vector<Point3f> world;
	stringstream ss;
	string line, sx, sy;
	float x, y;
	ifstream file;

	file.open(filename.c_str());
	if(!file.is_open()) return false;

	while(!file.eof()) {
		std::getline(file, line);
		size_t pos = line.find(' ');
		if(pos == string::npos) return false;

		sx = line.substr(0, pos);
		sy = line.substr(pos + 1, line.size() - pos - 1);

		// read in x value
		ss.str(sx);
		ss.seekg(0);
		ss >> x;
		if(ss.fail()) return false;

		// read in y value
		ss.str(sy);
		ss.seekg(0);
		ss >> y;
		if(ss.fail()) return false;

		world.push_back(Point3f(x, y , 0));
	}
	file.close();

	views.world.assign(views.n, world);
	return world.size() == find_chessboard.grid.area();
}