Пример #1
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    cv::Mat inputImage = cv::imread("./icon.png");

    if(!inputImage.empty()){
        cv::imshow("Display Image", inputImage);
        waitKey(1);
    }

    QGraphicsScene scene;
    scene.setSceneRect(0, 0, 500, 500);
    scene.setItemIndexMethod(QGraphicsScene::NoIndex);

    Car *car = new Car();
    scene.addItem(car);
    car->turnLeft();
    car->accelerate();

    QGraphicsView view(&scene);
    view.setRenderHint(QPainter::Antialiasing);
    view.setBackgroundBrush(Qt::darkGray);
    view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "CV Controlled Car"));
    view.resize(1000, 1000);
    view.show();

    return app.exec();
}
Пример #2
0
bool demo::keyPressed(const OIS::KeyEvent &keyEventRef) {
  OgreFramework::getSingletonPtr()->keyPressed(keyEventRef);
  
  extern Car car;
	
  
  switch(keyEventRef.key){
    
  case OIS::KC_ESCAPE :
    OgreFramework::getSingletonPtr()->quit();
    return true;

  case OIS::KC_UP :
    car.accelerate();
    break;

  case OIS::KC_DOWN :
    car.slowDown();
    break;

  case OIS::KC_RIGHT :
    car.turnRight();
    break;

  case OIS::KC_LEFT :
    car.turnLeft();
    break;

  case OIS::KC_END :
    car.setSteer(0.0);
    car.setSpeed(0.0);
    break;

  case OIS::KC_SPACE :
    car.setBrake(true);
    break;

  case OIS::KC_B :
    static std::string ba("");
    ba+="a";
    createBox(ba,-15.0, 10.0, 0.0);
    break;

  case OIS::KC_N :
    static std::string bo("");
    bo+="o";
    createBall(bo,-25.0, 10.0, 0.0);
    break;

  case OIS::KC_K :
    car.lowRideBack();
    break;

  case OIS::KC_I :
    car.lowRideFront();
    break;
  
    /*  case OIS::KC_U :
    car.dropDoors();
    break;*/

  }


  return true;
}