// the principal program sequence void VisionEngine::start() { if (!interface_) interface_ = new ConsoleInterface(app_name_.c_str()); if (!interface_->openDisplay(this)) { delete interface_; interface_ = new ConsoleInterface(app_name_.c_str()); interface_->openDisplay(this); } if(camera_==NULL ) { interface_->displayError("No camera found!"); return; } if( camera_->startCamera() ) { initFrameProcessors(); startThread(); mainLoop(); stopThread(); } else interface_->displayError("Could not start camera!"); teardownCamera(); freeBuffers(); }
// the principal program sequence void PortVideoSDL::run() { if( !setupCamera() ) { if( !setupWindow() ) return; showError("No camera found!"); teardownWindow(); return; } if( !setupWindow() ) return; allocateBuffers(); initFrameProcessors(); bool success = camera_->startCamera(); if( success ){ SDL_FillRect(window_,0,0); SDL_Flip(window_); // add the help message from all FrameProcessors for (frame = processorList.begin(); frame!=processorList.end(); frame++) { std::vector<std::string> processor_text = (*frame)->getOptions(); if (processor_text.size()>0) help_text.push_back(""); for(std::vector<std::string>::iterator processor_line = processor_text.begin(); processor_line!=processor_text.end(); processor_line++) { help_text.push_back(*processor_line); } } //print the help message for(std::vector<std::string>::iterator help_line = help_text.begin(); help_line!=help_text.end(); help_line++) { std::cout << *help_line << std::endl; } std::cout << std::endl; running_=true; cameraThread = SDL_CreateThread(getFrameFromCamera,this); controlThread= SDL_CreateThread(getControlMessage,this); mainLoop(); SDL_KillThread(cameraThread); SDL_KillThread(controlThread); teardownCamera(); } else { showError("Could not start camera!"); } teardownWindow(); freeBuffers(); }