From a6c870a28b0acab5df9d51e0224d85a3c4bd7324 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Tue, 6 Apr 2010 21:38:17 +0200 Subject: Added VideoProvider wrapper class around ARvideo. --- application.cpp | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) (limited to 'application.cpp') diff --git a/application.cpp b/application.cpp index a1b9d22..3ff3ab3 100644 --- a/application.cpp +++ b/application.cpp @@ -1,7 +1,6 @@ #include "application.h" #include -#include #include #include @@ -11,26 +10,15 @@ Application::Application() { ARParam wparam; - - // Open video device. - if(arVideoOpen(NULL) < 0) { - throw(std::runtime_error("arVideoOpen() failed.")); - } - - // Find the size of the window. - int xsize, ysize; - if(arVideoInqSize(&xsize, &ysize) < 0) { - throw(std::runtime_error("arVideoInqSize() failed.")); - } - - std::cout << "Image size (x, y) = (" << xsize << ", " << ysize << ")" << std::endl; - + + vp = new VideoProvider(); + // Set the initial camera parameters. if(arParamLoad("camera_para.dat", 1, &wparam) < 0) { throw(std::runtime_error("arParamLoad() failed.")); } - arParamChangeSize(&wparam, xsize, ysize, &cparam); + arParamChangeSize(&wparam, vp->xsize, vp->ysize, &cparam); arInitCparam(&cparam); std::cout << "*** Camera Parameters ***" << std::endl; arParamDisp(&cparam); @@ -64,7 +52,7 @@ Application::Application() { SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); // Get our surface - surface = SDL_SetVideoMode(xsize, ysize, 32, flags); + surface = SDL_SetVideoMode(vp->xsize, vp->ysize, 32, flags); if(!surface) { throw(std::runtime_error("Video mode set failed")); } @@ -85,13 +73,13 @@ Application::Application() { } Application::~Application() { - arVideoCapStop(); - arVideoClose(); + delete vp; arglCleanup(argl_ctx); } void Application::run() { - arVideoCapStart(); + vp->start(); + while(1) { SDL_Event event; SDL_PollEvent(&event); @@ -109,9 +97,9 @@ void Application::run() { } void Application::main_loop(void) { - ARUint8 *dataPtr; + uint8_t *dataPtr; - if((dataPtr = (ARUint8 *)arVideoGetImage()) == NULL) { + if((dataPtr = vp->get()) == NULL) { arUtilSleep(10); return; } @@ -143,7 +131,7 @@ void Application::main_loop(void) { glDisable( GL_DEPTH_TEST ); - arVideoCapNext(); + vp->next(); SDL_GL_SwapBuffers(); } -- cgit v1.2.3