int main(int argc, char** argv){

  bool loadedScene = false;
  for(int i=1; i<argc; i++){
    string header; string data;
    istringstream liness(argv[i]);
    getline(liness, header, '='); getline(liness, data, '=');
    if(strcmp(header.c_str(), "mesh")==0){
      //renderScene = new scene(data);
      mesh = new obj();
      objLoader* loader = new objLoader(data, mesh);
      mesh->buildVBOs();
      delete loader;
      loadedScene = true;
    }
  }

  if(!loadedScene){
    cout << "Usage: mesh=[obj file]" << endl;
    return 0;
  }

  frame = 0;
  seconds = time (NULL);
  fpstracker = 0;

  // Launch CUDA/GL
  if (init(argc, argv)) {
    // GLFW main loop
    mainLoop();
  }

  system("pause");
  return 0;
}
示例#2
0
//************************************
// 函数名称: ReadTxt
// 函数说明:  读取读入中科院说明文本内容txt
// 作    者: Juliwei
// 完成日期: 2014/08/05
// 返 回 值: void
// 参    数:const string & filename	txt的路径
// 参    数:vector<string> & vpaths文件名
// 参    数:vector<Vec4i> & vpoints左右眼睛坐标点
// 参    数:char separator分隔符
//************************************
void ReadTxt(const string filename, vector<string>& vpaths,vector<Vec4f>& vpoints, char separator)
{
	ifstream file(filename.c_str(), ifstream::in);
	if (!file) 
	{
		string error_message = "No valid input file was given, please check the given filename.";
		CV_Error(CV_StsBadArg, error_message);
	}
	string line, path, pt0, pt1, pt2, pt3;
	while (getline(file, line)) 
	{
		stringstream liness(line);
		getline(liness, path, separator);
		getline(liness, pt0, separator);
		getline(liness, pt1, separator);
		getline(liness, pt2, separator);
		getline(liness, pt3, separator);
		if(!path.empty() && !pt0.empty()&& !pt1.empty()&& !pt2.empty()&& !pt3.empty()) 
		{
			Vec4f vtemp;
			vtemp[0] = atof(pt0.c_str());
			vtemp[1] = atof(pt1.c_str());
			vtemp[2] = atof(pt2.c_str());
			vtemp[3] = atof(pt3.c_str());
			vpaths.push_back(path);
			vpoints.push_back(vtemp);
		}
	}
}
示例#3
0
void CHistory::LoadHistoryFromLocal(const char* path)
{
	std::ifstream file;
	file.open(path,std::ios::in);
	if(file == NULL)
		return;
	string line, id, buffer,time;
	while (getline(file, line)) 
	{
		std::stringstream liness(line);
		getline(liness, id,'\t');
		getline(liness, buffer,'\t');
		getline(liness, time);
		int iLength = MultiByteToWideChar(CP_ACP, 0, buffer.c_str(), strlen(buffer.c_str())+1, NULL, 0);  
		TCHAR* Tbuffer = new TCHAR[iLength];
		MultiByteToWideChar(CP_ACP, 0, buffer.c_str(), strlen(buffer.c_str())+1,Tbuffer,iLength);   

		iLength = MultiByteToWideChar(CP_ACP, 0, time.c_str(), strlen(time.c_str())+1, NULL, 0); 
		TCHAR* time_buffer = new TCHAR[iLength];
		MultiByteToWideChar(CP_ACP, 0, time.c_str(), strlen(time.c_str())+1,time_buffer,iLength);  

		AddHistory(atoi(id.c_str()),Tbuffer,time_buffer,0);
		delete []Tbuffer;
		delete []time_buffer;
		Tbuffer = NULL;
		time_buffer = NULL;
	}
	file.close();
}
示例#4
0
// Show all registered users (from connections file)
void ServerManager::readFromFile(User *clientName)
{
	string line;
	fstream loginFile;
	string userFromFile;
	loginFile.open(_loginFile,ios::in|ios::out|ios::binary);
	if (loginFile.is_open())
	{
		while ( !loginFile.eof() )
		{
			getline (loginFile,line);
			istringstream liness( line );
			getline( liness, userFromFile, '-' );
			if (clientName != NULL)
			{
			  clientName->writeMsg(userFromFile); // Send to client who requested
			}
			else
			{
			  printToSreen(userFromFile); // Print on server
			}

		}
	loginFile.close();
	}
	else
	{
		 printToSreen("Error - could not open the file");
	}

}
long EmergenceLog::getUID(string logLine) {
    string uid;
    istringstream liness(logLine);
    getline(liness, uid, ',');
    // **** NEED ERROR HANDLING ****
    return atol(uid.c_str());
}
void Image::read_csv(const string &filename, Image *train, Image *test)
{
    char separator = ';';
    std::ifstream file(filename.c_str(), ifstream::in);
    if (!file) {
        string error_message = "Split:No valid input file was given, please check the given filename.";
        CV_Error(CV_StsBadArg, error_message);
    }
    train->nfile = 0;
    test->nfile = 0;
    string line, path, classlabel;
    Mat src;
    int count = 0;
    int splitcount = 0;
    int splitratio = 4;
    while (getline(file, line))
    {
        stringstream liness(line);
        getline(liness, path, separator);
        getline(liness, classlabel);
        if(!path.empty() && !classlabel.empty())
        {
            src = imread(path,0);
            if (src.channels() != 1)
                cv::cvtColor(src, src, CV_BGR2GRAY);
            
            if (count == 0)
            {
                count++;
                train->size = cv::Size(src.rows,src.cols);
                test->size = train->size;
            }
            
            if (splitcount < splitratio)
            {
                train->images.push_back(src);
                train->labels.push_back(this->intLabel(classlabel));
                //cout<<classlabel<<" "<<this->intLabel(classlabel)<<endl;
                train->nfile++;
                train->filepath.push_back(path);
                //cout<<path<<endl;
                splitcount++;
            }
            else
            {
                test->images.push_back(src);
                test->labels.push_back(this->intLabel(classlabel));
                //cout<<classlabel<<" "<<this->intLabel(classlabel)<<endl;
                test->nfile++;
                test->filepath.push_back(path);
                //cout<<path<<endl;
                splitcount = 0;
                
            }
            
        }
    }
    
}
示例#7
0
int main(int argc, char** argv){

	#ifdef __APPLE__
	// Needed in OSX to force use of OpenGL3.2 
	glfwWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
	glfwWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
	glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
	#endif 

	// Set up pathtracer stuff
	bool loadedScene = true;
	finishedRender = false;

	targetFrame = 0;
	singleFrameMode = false;

	// Load scene file
	for(int i=1; i<argc; i++){
		string header; string data;
		istringstream liness(argv[i]);
		getline(liness, header, '=');
		getline(liness, data, '=');

		if(strcmp(header.c_str(), "scene")==0){
			renderScene = new scene(data);
			loadedScene = true;
		}else if(strcmp(header.c_str(), "frame")==0){
			targetFrame = atoi(data.c_str());
			singleFrameMode = true;
		}
	}

	if(!loadedScene){
		cout << "Error: scene file needed!" << endl;
		system("PAUSE");
		return 0;
	}

	// Set up camera stuff from loaded pathtracer settings
	iterations = 0;
	renderCam = &renderScene->renderCam;
	width = renderCam->resolution[0];
	height = renderCam->resolution[1];

	if(targetFrame >= renderCam->frames){
		cout << "Warning: Specified target frame is out of range , defaulting to frame 0." << endl;
		targetFrame = 0;
	}

	// Initialize CUDA and GL components
	if (init(argc, argv)) {
		// GLFW main loop
		mainLoop();
	}

	system("PAUSE");
	return 0;
}
string EmergenceLog::fileDateTimeString(string line)
{   string uid, event, date, time, oftime;
    istringstream liness(line);
    getline(liness, uid, ',');
    getline(liness, event, ',');
    getline(liness, date, ',');
    getline(liness, time, ',');
    getline(liness, oftime, ',');
    return date + "," + time + "," + oftime;
}
示例#9
0
static void read_csv(std::string filename, std::vector<cv::Mat>& images, std::vector<int>& labels){
  std::ifstream file(filename, std::ifstream::in);
  std::string line, path, class_label;

  while(getline(file, line)){
    std::stringstream liness(line);
    getline(liness, path, ';');
    getline(liness, class_label);
    if(!path.empty() && !class_label.empty()){
      images.push_back(cv::imread(path, 0));
      labels.push_back(atoi(class_label.c_str()));
    }
  }
}
示例#10
0
std::vector<std::string> tokenizeLine(std::string input){
    
    std::stringstream liness(input);
    std::string segment;
    
    std::vector<std::string> segment_list;
    while (getline(liness, segment,' ')) {
        if(segment!=""){
            segment_list.push_back(segment);
        }
    }
    
    return segment_list;
    
}
	//Leer imágenes desde el csv y convertir a escala de grises
	void FaceCSVReader::loadCroppedGrayImagesFromCSV(const std::string& filename, std::vector<cv::Mat>& images,
		std::vector<int>& labels, char separator)
	{
		//Abrir fichero
		std::ifstream file(filename.c_str(), std::ifstream::in);
		if (!file) {
			std::string error_message = "Archivo " + filename + " no pudo ser abierto";
			CV_Error(CV_StsBadArg, error_message);
		}
		//Fichero corregido
		//std::ofstream outputFile((filename + "corregido").c_str());
		//Detector de caras
		HaarLikeFaceDetector faceDetector;

		//Mensaje de cargado
		std::cout << "Cargando imagenes y recortando caras desde " << filename << std::endl;
		std::string line, path, classlabel;
		//Cargar imágenes y etiquetas línea a línea
		while (getline(file, line)) {
			std::stringstream liness(line);
			getline(liness, path, separator);
			getline(liness, classlabel);
			if (!path.empty() && !classlabel.empty()) {
				//Cargar imagen
				cv::Mat img = cv::imread(path, CV_LOAD_IMAGE_GRAYSCALE);
				//Comprobar que se haya cargado bien
				if (img.empty())
				{
					std::cerr << "Error al cargar " << line << std::endl;
				}
				else
				{
					//outputFile << line << "\n";
					cv::Mat face;
					//Extraer cara principal
					faceDetector.extractMainFace(img, face, 32, 32, 64, 64);
					//Añadir imagen con la cara detectada
					images.push_back(face);
					labels.push_back(atoi(classlabel.c_str()));
				}
			}
		}

		//Mensaje de cargado
		std::cout << "Carga completada y conversión a escala de grises" << std::endl;
		//Cerrar fichero
		//outputFile.close();
	}
示例#12
0
文件: Test.cpp 项目: bmetge/sokaris
	void Test::read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator) {
		std::ifstream file(filename.c_str(), ifstream::in);
		if (!file) {
			string error_message = "No valid input file was given, please check the given filename.";
			CV_Error(CV_StsBadArg, error_message);
		}
		string line, path, classlabel;
		while (getline(file, line)) {
			stringstream liness(line);
			getline(liness, path, separator);
			getline(liness, classlabel);
			if(!path.empty() && !classlabel.empty()) {
				images.push_back(imread(path, 0));
				labels.push_back(atoi(classlabel.c_str()));
			}
		}
    }
示例#13
0
int main(int argc, char** argv){
  // Set up pathtracer stuff
  bool loadedScene = false;
  finishedRender = false;

  targetFrame = 0;
  singleFrameMode = false;

  // Load scene file
  for(int i=1; i<argc; i++){
    string header; string data;
    istringstream liness(argv[i]);
    getline(liness, header, '='); getline(liness, data, '=');
    if(strcmp(header.c_str(), "scene")==0){
      renderScene = new scene(data);
      loadedScene = true;
    }else if(strcmp(header.c_str(), "frame")==0){
      targetFrame = atoi(data.c_str());
      singleFrameMode = true;
    }
  }

  if(!loadedScene){
    cout << "Error: scene file needed!" << endl;
    return 0;
  }

  // Set up camera stuff from loaded pathtracer settings
  iterations = 0;
  renderCam = &renderScene->renderCam;
  width = renderCam->resolution[0];
  height = renderCam->resolution[1];

  if(targetFrame >= renderCam->frames){
    cout << "Warning: Specified target frame is out of range, defaulting to frame 0." << endl;
    targetFrame = 0;
  }

  // Initialize CUDA and GL components
  if (init(argc, argv)) {
    // GLFW main loop
    mainLoop();
  }

  return 0;
}
示例#14
0
int main( int argc, char **argv )
{
	bool loadedScene = false;
	for(int i=1; i<argc; i++){
	string header; string data;
	istringstream liness(argv[i]);
	getline(liness, header, '='); getline(liness, data, '=');
	if(strcmp(header.c_str(), "mesh")==0){
		//renderScene = new scene(data);
		mesh = new obj();
		objLoader* loader = new objLoader(data, mesh);
		mesh->buildVBOs();
		delete loader;
		loadedScene = true;
	}
	}

	if(!loadedScene){
	cout << "Usage: mesh=[obj file]" << endl;
	return 0;
	}

	frame = 0;
	seconds = time (NULL);
	fpstracker = 0;

	// Hardcoded camera definition.
	camera.position = glm::vec3( 0.0f, 0.0f, 4.0f );
	camera.target = glm::vec3( 0.0f, 0.0f, 0.0f );
	camera.up = glm::vec3( 0.0f, -1.0f, 0.0f );
	camera.fov_y = 25.0f;
	camera.resolution = glm::vec2( width, height );
	camera.near_clip = 0.01f;
	camera.far_clip = 1000.0f;

	// Launch CUDA/GL
	if (init(argc, argv)) {
		// GLFW main loop
		mainLoop();
	}

	return 0;
}
示例#15
0
int EmergenceLog::getFirstHBInfo(long uid, int nLines, long* lineNums, string * lineStrings)
{
    //printf("length()");
    //long len = length();
    //printf("done()");
    long i = 1;
    int count = 0;
    string line, ruid, event, date, time, oftime;
    
    string fileName = getLogDirPath() + _fileName;
    std::ifstream mFile;
    
    mFile.open(fileName.c_str());
    if (mFile.is_open()) {
        while (mFile.good() && (count < nLines))
        {
            getline(mFile, line);
            
            istringstream liness(line);
            getline(liness, ruid, ',');
            
            if (uid == atol(ruid.c_str()))
            {
                getline(liness, event, ',');
                
                if (event.compare("HB") == 0) {
                    printf("HB%i", count);

                    if (lineNums != NULL) {
                        lineNums[count] = i;
                    }
                    if (lineStrings != NULL) {
                        lineStrings[count] = line;
                    } 
                    count++;
                }
            }
            i++;
        }    
        mFile.close();
    }
    return count;
}
void Image::read_csv(const string& filename)
{
    char separator = ';';
    std::ifstream file(filename.c_str(), ifstream::in);
    if (!file) {
        string error_message = "No valid input file was given, please check the given filename.";
        CV_Error(CV_StsBadArg, error_message);
    }
    this->nfile = 0;
    string line, path, classlabel;
    Mat src;
    int count = 0;
    while (getline(file, line))
    {
        stringstream liness(line);
        getline(liness, path, separator);
        getline(liness, classlabel);
        if(!path.empty() && !classlabel.empty())
        {
            src = imread(path,0);
            if (src.channels() != 1)
                cv::cvtColor(src, src, CV_BGR2GRAY);
            //cv::resize(src, src, cv::Size(1280,720);
            //imread(path, 0).convertTo(src, CV_64FC1, 1.0/255, 0);
            if (count == 0)
            {
                count++;
                size = cv::Size(src.rows,src.cols);
            }
            this->images.push_back(src);
            this->labels.push_back(this->intLabel(classlabel));
            //cout<<classlabel<<" "<<this->intLabel(classlabel)<<endl;
            this->nfile++;
            this->filepath.push_back(path);
            //cout<<path<<endl;
        }
    }
    //    std::vector<string>::iterator iter;
    //    for (iter = this->labels.begin();iter!=this->labels.end();iter++)
    //    {
    //        cout<<*iter<<endl;
    //    }
}
示例#17
0
void 
RoboyVision::trainFaceRecognizer()
{

	std::string filename = FACE_RECOGNITION_TRAINING_SET_FILE;
	std::vector<cv::Mat> images;
	std::vector<int> labels;

	// check if the filename is valid
	std::ifstream file(filename.c_str(), std::ifstream::in);
	if (!file) {
		std::string error_message = "No valid input file was given, please check the given filename.";
		CV_Error(CV_StsBadArg, error_message);
	}

	std::string line, path, classlabel;

	// read input file
	while (getline(file, line)) {
		std::stringstream liness(line);
		std::getline(liness, path, ';');
		std::getline(liness, classlabel);

		std::cerr << " path: " << path << ", " << classlabel  << std::endl;

		if(!path.empty() && !classlabel.empty()) {
			//			std::cout << path << std::endl;
			//			imshow("OLE", cv::imread(path, 0));
			images.push_back(cv::imread(path, 0));
			labels.push_back(atoi(classlabel.c_str()));
		}
	}

	//    recognitionModel = cv::createFisherFaceRecognizer();
	//    recognitionModel = cv::createLBPHFaceRecognizer(1, 8, 8, 8, DBL_MAX);

	//recognitionModel = cv::createLBPHFaceRecognizer(1, 8, 8, 8, 50);
	recognitionModel = cv::createEigenFaceRecognizer(80, DBL_MAX);
	recognitionModel->train(images, labels);

}
void read_csv(int nPictureById[MAX_PEOPLE], string people[MAX_PEOPLE], const string& filename, vector<Mat>& images,
		vector<int>& labels, char separator) {
	string s;
	char sTmp[255];

	// Read CSV file
    ifstream file(filename.c_str(), ifstream::in);
    if (!file) {
        string error_message = "\n (Error read CSV file) No valid input csv file was given, please check the given filename.";
        CV_Error(CV_StsBadArg, error_message);
    }

    // Read path and classlabel for each person
    string line, path, classlabel;
    int nLine=0;
    while (getline(file, line)) {
        stringstream liness(line);
        getline(liness, path, separator);
        getline(liness, classlabel);
        if(!path.empty() && !classlabel.empty())
        {
        	// read the file and build the picture collection
            images.push_back(imread(path, 0));
            labels.push_back(atoi(classlabel.c_str()));
            nPictureById[atoi(classlabel.c_str())]++;
        	nLine++;
        }
    }

    // write number of picture by people
#ifdef TRACE
    sprintf(sTmp,"\n (init read CSV file) %d pictures read to train",nLine);
    trace(sTmp);
	for (int j=0;j<MAX_PEOPLE;j++)
	{
		sprintf(sTmp,"\n (init read CSV file) %d pictures of %s (%d) read to train",nPictureById[j],people[j].c_str(),j);
   	 	trace(sTmp);
	}
#endif
}
示例#19
0
void SRClassifier::read_csv(char separator)
{
	std::ifstream file(csv_path.c_str(), std::ifstream::in | std::ifstream::binary);
	if (!file) {
		std::string error_message = "No valid input file was given, please check the given filename.";
		CV_Error(CV_StsBadArg, error_message);
	}
	std::string line, path, class_label;
	std::string folder = csv_path.substr(0, csv_path.find_last_of("/\\"));

	while (getline(file, line)) {
		std::stringstream liness(line);
		path.clear();
		getline(liness, path, separator);
		getline(liness, class_label);
		path = folder + path;
		if (!path.empty() && !class_label.empty()) {
			images.push_back(cv::imread(path, 0));
			labels.push_back(atoi(class_label.c_str()));
		}
	}
}
	//Leer imágenes desde el csv
	void FaceCSVReader::loadActualImagesFromCSV(const std::string& filename, std::vector<cv::Mat>& images,
		std::vector<int>& labels, char separator)
	{
		//Abrir fichero
		std::ifstream file(filename.c_str(), std::ifstream::in);
		if (!file) {
			std::string error_message = "Archivo " + filename + " no pudo ser abierto";
			CV_Error(CV_StsBadArg, error_message);
		}

		//Mensaje de cargado
		std::cout << "Cargando imagenes desde " << filename << std::endl;
		std::string line, path, classlabel;
		//Cargar imágenes y etiquetas línea a línea
		while (getline(file, line)) {
			std::stringstream liness(line);
			getline(liness, path, separator);
			getline(liness, classlabel);
			if (!path.empty() && !classlabel.empty()) {
				//Cargar imagen
				cv::Mat img = cv::imread(path);
				//Comprobar que se haya cargado bien
				if (img.empty())
				{
					std::cerr << "Error al cargar " << line << std::endl;
				}
				else
				{
					//outputFile << line << "\n";
					//Añadir imagen
					images.push_back(img);
					labels.push_back(atoi(classlabel.c_str()));
				}
			}
		}

		//Mensaje de cargado
		std::cout << "Carga completada" << std::endl;
	}
示例#21
0
void Control::read_csv(const std::string& filename,
		       std::vector<Channel>& images,
		       char separator)
{
    std::ifstream file(filename.c_str(), std::ifstream::in);
    if (!file) {
	std::string error_message = "No valid input file was given";
        CV_Error(CV_StsBadArg, error_message);
    }
    std::string line, path, classlabel;
    while (getline(file, line)) {
	std::stringstream liness(line);
        getline(liness, path, separator);
        getline(liness, classlabel);
        if(!path.empty() && !classlabel.empty()) {
	    int type = atoi(classlabel.c_str());
	    Channel image(cv::imread(path, 0));
	    image.setType(type-1);
	    image.setName(path);
	    images.push_back(image);
        }
    }
}
示例#22
0
int main(int argc, char** argv){

  #ifdef __APPLE__
	  // Needed in OSX to force use of OpenGL3.2 
	  glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
	  glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
	  glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
	  glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  #endif

  // Set up pathtracer stuff
  bool loadedScene = false;
  finishedRender = false;

  targetFrame = 0;
  singleFrameMode = false;

  // Load scene file
  for(int i=1; i<argc; i++){
    string header; string data;
    istringstream liness(argv[i]);
    getline(liness, header, '='); getline(liness, data, '=');
    if(strcmp(header.c_str(), "scene")==0){
      renderScene = new scene(data);
      loadedScene = true;
    }else if(strcmp(header.c_str(), "frame")==0){
      targetFrame = atoi(data.c_str());
      singleFrameMode = true;
    }
  }

  if(!loadedScene){
    cout << "Error: scene file needed!" << endl;
    return 0;
  }

  // Set up camera stuff from loaded pathtracer settings
  iterations = 0;
  renderCam = &renderScene->renderCam;
  parameterSet = &renderScene->parameterSet;
  width = renderCam->resolution[0];
  height = renderCam->resolution[1];
  textures=new m_BMP[renderScene->bmps.size()];
  int i,j,k;
  
  for(i=0;i<renderScene->bmps.size();i++)
  {
	//int w=renderScene->bmps[i]->Width;
	//int h=renderScene->bmps[i]->Height;
	BMP now;
	now.ReadFromFile(renderScene->bmps[i].c_str());
	int h=now.TellHeight();int w=now.TellWidth();
	textures[i].resolution=glm::vec2(w,h);
	textures[i].colors=new glm::vec3[w*h];
	for(j=0;j<w;j++)for(k=0;k<h;k++)
	{
		RGBApixel current=now.GetPixel(j,k);
		textures[i].colors[j*h+k]=glm::vec3(current.Red,current.Green,current.Blue)*(1.0f/255.0f);
	}
  }

  if(targetFrame>=renderCam->frames){
    cout << "Warning: Specified target frame is out of range, defaulting to frame 0." << endl;
    targetFrame = 0;
  }

  // Launch CUDA/GL

  #ifdef __APPLE__
	init();
  #else
	init(argc, argv);
  #endif

  initCuda();

  initVAO();
  initTextures();

  GLuint passthroughProgram;
  passthroughProgram = initShader("shaders/passthroughVS.glsl", "shaders/passthroughFS.glsl");

  glUseProgram(passthroughProgram);
  glActiveTexture(GL_TEXTURE0);
  starttime=clock();
  #ifdef __APPLE__
	  // send into GLFW main loop
	  while(1){
		display();
		if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS || !glfwGetWindowParam( GLFW_OPENED )){
				exit(0);
		}
	  }

	  glfwTerminate();
  #else
	  glutDisplayFunc(display);
	  glutKeyboardFunc(keyboard);

	  glutMainLoop();
  #endif
  return 0;
}
示例#23
0
int main(int argc, char** argv){

  #ifdef __APPLE__
	  // Needed in OSX to force use of OpenGL3.2 
	  glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
	  glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
	  glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
	  glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  #endif

  // Set up pathtracer stuff
  bool loadedScene = false;
  finishedRender = false;

  targetFrame = 0;
  singleFrameMode = false;


  // Load scene file
  for(int i=1; i<argc; i++){
    string header; string data;
    istringstream liness(argv[i]);
    getline(liness, header, '='); getline(liness, data, '=');
    if(strcmp(header.c_str(), "scene")==0){
      renderScene = new scene(data);
      loadedScene = true;
    }else if(strcmp(header.c_str(), "frame")==0){
      targetFrame = atoi(data.c_str());
      singleFrameMode = true;
    }
	else if(strcmp(header.c_str(), "mblur")==0){
      mblur = atoi(data.c_str());
    }
	else if(strcmp(header.c_str(), "dof")==0){
      dof = atoi(data.c_str());
    }
	else if(strcmp(header.c_str(), "textureMode")==0){
      textureMode = atoi(data.c_str());
    }
  }

  if(!loadedScene){
    cout << "Error: scene file needed!" << endl;
    return 0;
  }

  // Set up camera stuff from loaded pathtracer settings
  iterations = 0;
  renderCam = &renderScene->renderCam;
  width = renderCam->resolution[0];
  height = renderCam->resolution[1];

  if(targetFrame>=renderCam->frames){
    cout << "Warning: Specified target frame is out of range, defaulting to frame 0." << endl;
    targetFrame = 0;
  }

  // Launch CUDA/GL

  #ifdef __APPLE__
	init();
  #else
	init(argc, argv);
  #endif

  initCuda();

  initVAO();
  initTextures();

  GLuint passthroughProgram;
  passthroughProgram = initShader("shaders/passthroughVS.glsl", "shaders/passthroughFS.glsl");

  glUseProgram(passthroughProgram);
  glActiveTexture(GL_TEXTURE0);

  #ifdef __APPLE__
	  // send into GLFW main loop
	  while(1){
		display();
		if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS || !glfwGetWindowParam( GLFW_OPENED )){
				exit(0);
		}
	  }

	  glfwTerminate();
  #else
	  glutDisplayFunc(display);
	  glutKeyboardFunc(keyboard);
	  glutMouseFunc(mouse);
	  glutMainLoop();
  #endif
  return 0;
}
示例#24
0
int scene::loadObject(string objectid){
    int id = atoi(objectid.c_str());
    if(id!=objects.size()){
        cout << "ERROR: OBJECT ID does not match expected number of objects" << endl;
        return -1;
    }else{
        cout << "Loading Object " << id << "..." << endl;
        geom newObject;
        string line;
        
        //load object type 
        utilityCore::safeGetline(fp_in,line);
        if (!line.empty() && fp_in.good()){
            if(strcmp(line.c_str(), "sphere")==0){
                cout << "Creating new sphere..." << endl;
				newObject.type = SPHERE;
            }else if(strcmp(line.c_str(), "cube")==0){
                cout << "Creating new cube..." << endl;
				newObject.type = CUBE;
            }else{
				string objline = line;
                string name;
                string extension;
                istringstream liness(objline);
                getline(liness, name, '.');
                getline(liness, extension, '.');
                if(strcmp(extension.c_str(), "obj")==0){
                    cout << "Creating new mesh..." << endl;
                    cout << "Reading mesh from " << line << "... " << endl;
		    		newObject.type = MESH;
                }else{
                    cout << "ERROR: " << line << " is not a valid object type!" << endl;
                    return -1;
                }
            }
        }
       
	//link material
    utilityCore::safeGetline(fp_in,line);
	if(!line.empty() && fp_in.good()){
	    vector<string> tokens = utilityCore::tokenizeString(line);
	    newObject.materialid = atoi(tokens[1].c_str());
	    cout << "Connecting Object " << objectid << " to Material " << newObject.materialid << "..." << endl;
        }
        
	//load frames
    int frameCount = 0;
    utilityCore::safeGetline(fp_in,line);
	vector<glm::vec3> translations;
	vector<glm::vec3> scales;
	vector<glm::vec3> rotations;
    while (!line.empty() && fp_in.good()){
	    
	    //check frame number
	    vector<string> tokens = utilityCore::tokenizeString(line);
        if(strcmp(tokens[0].c_str(), "frame")!=0 || atoi(tokens[1].c_str())!=frameCount){
            cout << "ERROR: Incorrect frame count!" << endl;
            return -1;
        }
	    
	    //load tranformations
	    for(int i=0; i<3; i++){
            glm::vec3 translation; glm::vec3 rotation; glm::vec3 scale;
            utilityCore::safeGetline(fp_in,line);
            tokens = utilityCore::tokenizeString(line);
            if(strcmp(tokens[0].c_str(), "TRANS")==0){
                translations.push_back(glm::vec3(atof(tokens[1].c_str()), atof(tokens[2].c_str()), atof(tokens[3].c_str())));
            }else if(strcmp(tokens[0].c_str(), "ROTAT")==0){
                rotations.push_back(glm::vec3(atof(tokens[1].c_str()), atof(tokens[2].c_str()), atof(tokens[3].c_str())));
            }else if(strcmp(tokens[0].c_str(), "SCALE")==0){
                scales.push_back(glm::vec3(atof(tokens[1].c_str()), atof(tokens[2].c_str()), atof(tokens[3].c_str())));
            }
	    }
	    
	    frameCount++;
        utilityCore::safeGetline(fp_in,line);
	}
	
	//move frames into CUDA readable arrays
	newObject.translations = new glm::vec3[frameCount];
	newObject.rotations = new glm::vec3[frameCount];
	newObject.scales = new glm::vec3[frameCount];
	newObject.transforms = new cudaMat4[frameCount];
	newObject.inverseTransforms = new cudaMat4[frameCount];
	for(int i=0; i<frameCount; i++){
		newObject.translations[i] = translations[i];
		newObject.rotations[i] = rotations[i];
		newObject.scales[i] = scales[i];
		glm::mat4 transform = utilityCore::buildTransformationMatrix(translations[i], rotations[i], scales[i]);
		newObject.transforms[i] = utilityCore::glmMat4ToCudaMat4(transform);
		newObject.inverseTransforms[i] = utilityCore::glmMat4ToCudaMat4(glm::inverse(transform));
	}
	
        objects.push_back(newObject);
	
	cout << "Loaded " << frameCount << " frames for Object " << objectid << "!" << endl;
        return 1;
    }
}
示例#25
0
int scene::loadObject(string objectid){
    int id = atoi(objectid.c_str());
    if(id!=objects.size())
	{
        cout << "ERROR: OBJECT ID does not match expected number of objects" << endl;
        return -1;
    }
	else
	{
        cout << "Loading Object " << id << "..." << endl;
        geom newObject;
        string line;
        
        //load object type 
        utilityCore::safeGetline(fp_in,line);
        if (!line.empty() && fp_in.good())
		{
            if(strcmp(line.c_str(), "sphere")==0){
                cout << "Creating new sphere..." << endl;
				newObject.type = SPHERE;
            }else if(strcmp(line.c_str(), "cube")==0){
                cout << "Creating new cube..." << endl;
				newObject.type = CUBE;
            }else{
				string objline = line;
                string name;
                string extension;
                istringstream liness(objline);
                getline(liness, name, '.');
                getline(liness, extension, '.');
                if(strcmp(extension.c_str(), "obj")==0){
                    cout << "Creating new mesh..." << endl;
                    cout << "Reading mesh from " << line << "... " << endl;
		    		newObject.type = MESH;
                }else{
                    cout << "ERROR: " << line << " is not a valid object type!" << endl;
                    return -1;
                }
            }
        }
       
		//load obj file
		if(newObject.type == MESH)
		{
			newObject.boundingBoxMax = glm::vec3(FLT_MIN);
			newObject.boundingBoxMin = glm::vec3(FLT_MAX);
			vector<glm::vec3> positions;
			vector<glm::vec3> faces;

			glm::vec3 tpos, tIndex;

			std::ifstream obj_file_stream(line);
			if(!obj_file_stream.is_open())
			{
				fprintf(stderr, "Error reading file: %s\n", line);
				return -1;
			}

			char currentLine[500];
			char *pch;

			// vertex list and face(indices) list can be stored directly from file reading
			while(obj_file_stream.getline(currentLine, 500))
			{
				char current_token = currentLine[0];
				//skip comments
				if( current_token == '#') continue;		

				//parse objects
				else if( current_token == 'v') //process vertex
				{
					pch = strtok (currentLine," v");
					tpos.x = (float)atof (pch); 
					newObject.boundingBoxMax.x = std::max(newObject.boundingBoxMax.x, tpos.x);
					newObject.boundingBoxMin.x = std::min(newObject.boundingBoxMin.x, tpos.x);
					for(int i = 1; i < 3; i++)
					{			
						pch = strtok (NULL," v");
						switch(i)
						{
						case 1: 
							tpos.y = atof (pch);
							newObject.boundingBoxMax.y = std::max(newObject.boundingBoxMax.y, tpos.y);
							newObject.boundingBoxMin.y = std::min(newObject.boundingBoxMin.y, tpos.y);
							break;
						case 2: 
							tpos.z = atof (pch);
							newObject.boundingBoxMax.z = std::max(newObject.boundingBoxMax.z, tpos.z);
							newObject.boundingBoxMin.z = std::min(newObject.boundingBoxMin.z, tpos.z);
							break;
						default: std::cout<<"Error in extracting OBJ"<<std::endl;
						}
					}
					positions.push_back(tpos);
				}
				else if( current_token == 'f') //process face
				{
					pch = strtok (currentLine," f");
					tIndex.x = (float)atoi (pch) - 1; // if contains non-digit characters like "/", it will be ignored
					for(int i = 1; i < 3; i++)
					{			
						pch = strtok (NULL," f");
						tIndex[i] = (float)atoi (pch) - 1; 						
					}
					faces.push_back(tIndex);
				}
				else continue;
			}
			obj_file_stream.close();

			//move data into CUDA readable arrays
			newObject.vertexCount = positions.size();			
			newObject.vertexList = new glm::vec3[newObject.vertexCount];
			for(int i = 0; i < newObject.vertexCount; ++i){
				newObject.vertexList[i] = positions[i];
			}

			newObject.faceCount = faces.size();
			newObject.faceList = new glm::vec3[newObject.faceCount];
			for(int i = 0; i < newObject.faceCount; ++i){
				newObject.faceList[i] = faces[i];
			}

		}
		//link material
		utilityCore::safeGetline(fp_in,line);
		if(!line.empty() && fp_in.good())
		{
			vector<string> tokens = utilityCore::tokenizeString(line);
			newObject.materialid = atoi(tokens[1].c_str());
			cout << "Connecting Object " << objectid << " to Material " << newObject.materialid << "..." << endl;
		}
        
		//load frames
		int frameCount = 0;
		utilityCore::safeGetline(fp_in,line);
		vector<glm::vec3> translations;
		vector<glm::vec3> scales;
		vector<glm::vec3> rotations;
		while (!line.empty() && fp_in.good())
		{
	    
			//check frame number
			vector<string> tokens = utilityCore::tokenizeString(line);
			if(strcmp(tokens[0].c_str(), "frame")!=0 || atoi(tokens[1].c_str())!=frameCount)
			{
				cout << "ERROR: Incorrect frame count!" << endl;
				return -1;
			}
	    
			//load tranformations
			for(int i=0; i<3; i++)
			{
				glm::vec3 translation; glm::vec3 rotation; glm::vec3 scale;
				utilityCore::safeGetline(fp_in,line);
				tokens = utilityCore::tokenizeString(line);
				if(strcmp(tokens[0].c_str(), "TRANS")==0)
				{
					translations.push_back(glm::vec3(atof(tokens[1].c_str()), atof(tokens[2].c_str()), atof(tokens[3].c_str())));
				}
				else if(strcmp(tokens[0].c_str(), "ROTAT")==0)
				{
					rotations.push_back(glm::vec3(atof(tokens[1].c_str()), atof(tokens[2].c_str()), atof(tokens[3].c_str())));
				}
				else if(strcmp(tokens[0].c_str(), "SCALE")==0)
				{
					scales.push_back(glm::vec3(atof(tokens[1].c_str()), atof(tokens[2].c_str()), atof(tokens[3].c_str())));
				}
			}
	    
			frameCount++;
			utilityCore::safeGetline(fp_in,line);
		}
	
		//move frames into CUDA readable arrays
		newObject.translations = new glm::vec3[frameCount];
		newObject.rotations = new glm::vec3[frameCount];
		newObject.scales = new glm::vec3[frameCount];
		newObject.transforms = new cudaMat4[frameCount];
		newObject.inverseTransforms = new cudaMat4[frameCount];
		for(int i=0; i<frameCount; i++)
		{
			newObject.translations[i] = translations[i];
			newObject.rotations[i] = rotations[i];
			newObject.scales[i] = scales[i];
			glm::mat4 transform = utilityCore::buildTransformationMatrix(translations[i], rotations[i], scales[i]);
			newObject.transforms[i] = utilityCore::glmMat4ToCudaMat4(transform);
			newObject.inverseTransforms[i] = utilityCore::glmMat4ToCudaMat4(glm::inverse(transform));
		}
	
			objects.push_back(newObject);
	
		cout << "Loaded " << frameCount << " frames for Object " << objectid << "!" << endl;
		return 1;
    }
}
示例#26
0
int main(int argc, char** argv){

  bool loadedScene = false;
  for(int i=1; i<argc; i++){
    string header; string data;
    istringstream liness(argv[i]);
    getline(liness, header, '='); getline(liness, data, '=');
    if(strcmp(header.c_str(), "mesh")==0){
      //renderScene = new scene(data);
      mesh = new obj();
      objLoader* loader = new objLoader(data, mesh);
      mesh->buildVBOs();
      delete loader;
      loadedScene = true;
    }
  }

  if(!loadedScene){
    cout << "Usage: mesh=[obj file]" << endl;
    return 0;
  }

  // Initialization of camera parameters
  cam.position = glm::vec3(0.0f, 1.0f, 1.0f);
  cam.up       = glm::vec3(0.0f, 1.0f, 0.0f);
  cam.view     = glm::normalize(-cam.position);
  cam.right    = glm::normalize(glm::cross(cam.view, cam.up));
  cam.fovy     = 45.0f;

  // Initialize transformation
  model      = new glm::mat4(utilityCore::buildTransformationMatrix(glm::vec3(0.0f, -0.2f, 0.0f), glm::vec3(0.0f), glm::vec3(0.7f)));
  view       = new glm::mat4(glm::lookAt(cam.position, glm::vec3(0.0f), cam.up));
  projection = new glm::mat4(glm::perspective(cam.fovy, (float)width / height, zNear, zFar));
  transformModel2Projection  = new cudaMat4(utilityCore::glmMat4ToCudaMat4(*projection * *view * *model));

  // Initialize viewport in the model space
  viewPort   = glm::normalize(utilityCore::multiplyMat(utilityCore::glmMat4ToCudaMat4(*projection * *view), glm::vec4(cam.view, 1.0f)));

  frame = 0;
  seconds = time (NULL);
  fpstracker = 0;

  // Launch CUDA/GL
  #ifdef __APPLE__
  // Needed in OSX to force use of OpenGL3.2 
  glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
  glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
  glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
  glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  init();
  #else
  init(argc, argv);
  #endif
  
  initCuda();

  initVAO();
  initTextures();

  GLuint passthroughProgram;
  passthroughProgram = initShader("shaders/passthroughVS.glsl", "shaders/passthroughFS.glsl");

  glUseProgram(passthroughProgram);
  glActiveTexture(GL_TEXTURE0);

  #ifdef __APPLE__
    // send into GLFW main loop
    while(1){
      display();
      if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS || !glfwGetWindowParam( GLFW_OPENED )){
          kernelCleanup();
          cudaDeviceReset(); 
          exit(0);
      }
    }

    glfwTerminate();
  #else
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutSpecialFunc(specialFunction);
    glutMouseFunc(mouseClick);
    glutMotionFunc(mouseMotion);

    glutMainLoop();
  #endif
  kernelCleanup();
  delete model;
  delete view;
  delete projection;
  delete transformModel2Projection;
  return 0;
}
示例#27
0
int main(int argc, char** argv){

  bool loadedScene = false;
  for(int i=1; i<argc; i++){
    string header; string data;
    istringstream liness(argv[i]);
    getline(liness, header, '='); getline(liness, data, '=');
    if(strcmp(header.c_str(), "mesh")==0){
      //renderScene = new scene(data);
      mesh = new obj();
      objLoader* loader = new objLoader(data, mesh);
      mesh->buildVBOs();
      delete loader;
      loadedScene = true;
    }
  }

  if(!loadedScene){
    cout << "Usage: mesh=[obj file]" << endl;
    return 0;
  }

  frame = 0;
  seconds = time (NULL);
  fpstracker = 0;

  // Launch CUDA/GL
  #ifdef __APPLE__
  // Needed in OSX to force use of OpenGL3.2 
  glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
  glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
  glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
  glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  init();
  #else
  init(argc, argv);
  #endif

  // Initialize camera position
  cam = glm::translate( cam, glm::vec3( 0.0, 0.0, 2.0f ) );

  initCuda();

  initVAO();
  initTextures();

  GLuint passthroughProgram;
  passthroughProgram = initShader("shaders/passthroughVS.glsl", "shaders/passthroughFS.glsl");

  glUseProgram(passthroughProgram);
  glActiveTexture(GL_TEXTURE0);

  #ifdef __APPLE__
    // send into GLFW main loop
    while(1){
      display();
      if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS || !glfwGetWindowParam( GLFW_OPENED )){
          kernelCleanup();
          cudaDeviceReset(); 
          exit(0);
      }
    }

    glfwTerminate();
  #else
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMouseFunc(mouse);
    glutMotionFunc(mouse_motion);

    glutMainLoop();
  #endif
  kernelCleanup();
  return 0;
}
示例#28
0
void MapManager::loadMap(char *file) {
    cout << "Opening map: " << file << endl;
    objective = false;
    ifstream map (file);
    if(map.is_open()) {
        int y = 0;
        while(!map.eof()) {
            string line;
            getline(map, line);
            if(y<ConstManager::getInt("map_size")) {
                // Read in map tile information
                for(int x=0;x<ConstManager::getInt("map_size");x++) {
                    std::vector<int> connections = std::vector<int>();
                    int chosenPiece;
                    if(line[x]=='.') {
                        mts[x][y] = new MapTile();
                    } else if(line[x]=='|') {
                        connections.push_back(1);
                        connections.push_back(3);
                        chosenPiece = pieceChoices->getNextChoice();
                        sort(connections.begin(),connections.end()); // Sort to make sure nto the wrong way around
                        createTile("strai/",connections,x,y,chosenPiece);
                    } else if(line[x]=='-') {
                        connections.push_back(2);
                        connections.push_back(4);
                        chosenPiece = pieceChoices->getNextChoice();
                        createTile("strai/",connections,x,y,chosenPiece);
                    } else if(line[x]=='l') {
                        connections.push_back(1);
                        connections.push_back(2);
                        chosenPiece = pieceChoices->getNextChoice();
                        createTile("junct/",connections,x,y,chosenPiece);
                    } else if(line[x]=='r') {
                        connections.push_back(2);
                        connections.push_back(3);
                        chosenPiece = pieceChoices->getNextChoice();
                        createTile("junct/",connections,x,y,chosenPiece);
                    } else if(line[x]=='<') {
                        connections.push_back(3);
                        connections.push_back(4);
                        chosenPiece = pieceChoices->getNextChoice();
                        createTile("junct/",connections,x,y,chosenPiece);
                    } else if(line[x]=='j') {
                        connections.push_back(1);
                        connections.push_back(4);
                        chosenPiece = pieceChoices->getNextChoice();
                        createTile("junct/",connections,x,y,chosenPiece);
                    } else if(line[x]=='t') {
                        connections.push_back(1);
                        connections.push_back(2);
                        connections.push_back(3);
                        chosenPiece = pieceChoices->getNextChoice();
                        createTile("junct/",connections,x,y,chosenPiece);
                    } else if(line[x]=='=') {
                        connections.push_back(1);
                        connections.push_back(3);
                        connections.push_back(4);
                        chosenPiece = pieceChoices->getNextChoice();
                        createTile("junct/",connections,x,y,chosenPiece);
                    } else if(line[x]=='+') {
                        connections.push_back(1);
                        connections.push_back(2);
                        connections.push_back(3);
                        connections.push_back(4);
                        chosenPiece = pieceChoices->getNextChoice();
                        createTile("junct/",connections,x,y,chosenPiece);
                    } else if(line[x]=='/') {
                        connections.push_back(1);
                        connections.push_back(2);
                        connections.push_back(4);
                        chosenPiece = pieceChoices->getNextChoice();
                        createTile("junct/",connections,x,y,chosenPiece);
                    } else if(line[x]=='\\') {
                        connections.push_back(2);
                        connections.push_back(3);
                        connections.push_back(4);
                        chosenPiece = pieceChoices->getNextChoice();
                        createTile("junct/",connections,x,y,chosenPiece);
                    } else if(line[x]=='1') {
                        connections.push_back(1);
                        chosenPiece = pieceChoices->getNextChoice();
                        createTile("ends/",connections,x,y,chosenPiece);
                    } else if(line[x]=='2') {
                        connections.push_back(2);
                        chosenPiece = pieceChoices->getNextChoice();
                        createTile("ends/",connections,x,y,chosenPiece);
                    } else if(line[x]=='3') {
                        connections.push_back(3);
                        chosenPiece = pieceChoices->getNextChoice();
                        createTile("ends/",connections,x,y,chosenPiece);
                    } else if(line[x]=='4') {
                        connections.push_back(4);
                        chosenPiece = pieceChoices->getNextChoice();
                        createTile("ends/",connections,x,y,chosenPiece);
                    } else if(line[x]=='0') {
                        objx=x;
                        objy=y;
                        connections.push_back(1);
                        connections.push_back(2);
                        connections.push_back(3);
                        connections.push_back(4);
                        chosenPiece = pieceChoices->getNextChoice();
                        createTile("objec/",connections,x,y,chosenPiece);
                    } else if(line[x]=='S') {
                        connections.push_back(2);
                        chosenPiece = pieceChoices->getNextChoice();
                        createTile("start/",connections,x,y,chosenPiece);
                    }
                }

            } else {
                // Read in waypoint information
                if((line[0]=='w')&&(line[1]=='p')) {
                    istringstream liness(line);
                    int x;
                    int y;
                    string temp;
                    string rubbish;

                    liness >> rubbish;
                    liness >> x;
                    liness >> y;
                    liness >> temp;

                    string *name = new string(temp);
                    cout << x << " " << y << " " << name << endl;

                    Waypoint *w = new Waypoint(name,x,y);
                    waypoints.push_back(w);
                    mts[x][y]->assignWaypoint(w);

                    if(*w->getName()=="wp_start") {
                        startx = x;
                        starty = y;
                        mts[x][y]->setStart();
                    }
                    if(*w->getName()=="wp_end") {
                        mts[x][y]->setEnd();
                    }
                }
            }
            y++;
        }