Beispiel #1
0
void changeSize(int w, int h){

	/* Prevent a divide by zero, when window is too short
	 (you cant make a window of zero width). */
	if(h == 0)
		h = 1;

	float ratio = 1.0* w / h;

	/* Reset the coordinate system before modifying*/
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	
	/* Set the viewport to be the entire window*/
	    glViewport(0, 0, w, h);

	/* Set the correct perspective.*/
	gluPerspective(45,ratio,1,1000);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	gluLookAt(x,y,g, 		// punkt z ktorego sie patrzy
		  0.0,0.0,0.0,		// punkt (dowolny) lezacy na linie wzroku
		  0.0f,0.0f,1.0f);	// wektor ktory wskazuje gore
	setlight();

}
Beispiel #2
0
int main(int argc, char **argv) {

#ifdef WIN32
	SetPriorityClass( GetCurrentProcess(), REALTIME_PRIORITY_CLASS ); //! set priority to windows
#endif
	
	if (argc<2)
	{
		cout << "Usage : roadtrac [image file] [titlefile] [annotationfile]" << endl;
		cout << "exp : roadtrac template.jpg [label.txt] [annotations.txt]" << endl;
		exit(0);
	} else
	{
		char paperlist[100];
		sprintf_s(paperlist,100, "paperlist.%s.txt", argv[1]);
		ifstream paperfile(paperlist);
		if (!paperfile) //if doesnt exist
		{
			IplImage *templ = cvLoadImage(argv[1]);
			reg.ExtractRegions(templ);	
			m_tracker.CreateBlobSeq(&reg);
			m_tracker.SaveBlobSeq(paperlist);
	
			reg.Clear();
			m_tracker.Clear();
		}

		m_tracker.LoadBlobSeq(paperlist);

		if (argv[2])
			m_tracker.LoadBlobName(argv[2]);
		if (argv[3])
			m_tracker.LoadBlobLabels(argv[3]);
	}

	cap = cvCaptureFromCAM(CAMERAID);
	cvSetCaptureProperty(cap,CV_CAP_PROP_FRAME_WIDTH, IMG_WIDTH);
	cvSetCaptureProperty(cap,CV_CAP_PROP_FRAME_HEIGHT, IMG_HEIGHT);
	if (!cap)
		return 0;

	glutInit(&argc, argv);

	glutInitDisplayMode(GLUT_DOUBLE| GLUT_RGBA | GLUT_DEPTH | GLUT_MULTISAMPLE);

	glutInitWindowPosition(100, 100);
	glutInitWindowSize(IMG_WIDTH, IMG_HEIGHT);
	if (argv[1])
		wid = glutCreateWindow(argv[1]);
	else
		wid = glutCreateWindow("RoadTrac");

	texture = new GLuint[1];
	glGenTextures(1, texture);

	glBindTexture(GL_TEXTURE_2D, texture[0]);
	
	glPixelStorei(GL_UNPACK_ALIGNMENT, 4);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, FRAMESIZE, FRAMESIZE, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, 0);

	glutReshapeFunc(resize);
	glutDisplayFunc(display);
		
	m_text.t3dInit(DATA_CHARSET);
	glutIdleFunc(idle);
	glutKeyboardFunc(keyboard);

	setprojection();
			
	if (LIGHT) setlight();
	
	glutMainLoop();

	close();

	return 0;
}