Qt World Summit: Register Today!

Path finding on Image from Race Track

  • hello everyone,

    I have a problem, I want to represent certain values ​​on the track.
    That means I should represent all values ​​of motorcyclist on the track.
    (Please see the picture) Does anyone might have an idea.
    I would be very grateful

    The track is approximately 5.6 Km
    The track has a starting point and end point
    For example, the first driver in 5 minutes has reached the half way.
    How can I mark on the image half distance
    I have tried by the color (QRgb colors, color = image.pixel (x, y) then if (qGreen == 0)) so that I can distinguish the track from the image.

    Thanks.!http://1.bp.blogspot.com/-j6UeoG2uHBk/UNeYQ79MsCI/AAAAAAAAPZ4/vki2UxLzpm8/s1600/Ruhrschleife2013.jpg (Rennstrecke)!

  • Hi samlion007. Could you explain a little bit better what do you want to do?

    If you want to paint indicators over the track, you may want to use QGraphicsView in order to display a picture (that would be your track) and then draw stuff on it, like racers, checkpoints and the goal.

  • Hi BlastDV, thanks for your quick Answer,

    the Drawing should be automatically .

    here you are the Example:
    First Driver :
    he drives more then 10 Min. on this track and he has per second difference Velocity and difference gas consumption
    For example :
    from 1 sec. to 120 secs. has Velocity 20 km/h
    from 121 sec. to 3 Min. has Velocity 50 km/h
    from 3 Min to 10 min. has Velocity 80 km/h
    from 1 sec. to 120 secs. used Gas 30%
    from 121 sec. to 3 Min. used Gas 44%
    from 3 Min to 10 min. used Gas 70%

    I have 2d. Array with more then 500 Data
    so i have to put this Data on the trac instead of Motors.
    That mean the Image should show this data each meter .

    I have to write on the Trac G for Gas and S for Speed .


    Please see this Photos!!http://s7.directupload.net/images/140715/96gtwwwg.jpg( Data-Analyser)!!http://s7.directupload.net/images/140715/utpcixrf.jpg(Trac Race)!

  • I'm not sure if I understand this well but.. Do you want to represent the best path to race trough the track? With gas-speed relation?

    I understand what you say about having diferent measures depending on the time. But what do you exactly want to draw? A path? marks?

    Or do you want to draw marks according to the 2d array? If so, what is your question? Is it about processing the data? Or is it about drawing it?

  • Hi BlastDv,

    sorry for my bad explanation.
    I want , that the Program draw the marks (G or S ) according to the 2d Array automatically on the trac.

    The Program reads each measures from 2d Array and put or draws the marks on the trac (not out of the Trac).

    Another example:
    the driver reaches 2 kilometer in 3 minutes (the whole route is 5.5 km).
    I want that the program marks measure of gas and speed on the track from 1 meter to 2 Km.

    thanks alot for your quick answer.

  • I see, now I understand a little bit better.

    If you want to draw marks over the track, try using QGraphicsView class, which can be perfectly used to draw a static picture (the track) and then put some other stuff on it, like your marks.

    If you don't know this class, I can tell you by experience that it is not that hard to use. It works with the concept of "scenes", so you'll have to create a scene first where to put the elements on. Think about this as a theater where you have to set a scene first (QGraphicsScene) and then show it in a theater (QGraphicsView).

    To define elements on the QGraphicsScene, you'll have to use primitives according to what you want to draw (in this case, that would be "letters", I think). You may want to check the "QGraphicsView":http://qt-project.org/doc/qt-4.8/qgraphicsview.html and the "QGraphicsScene":http://qt-project.org/doc/qt-4.8/qgraphicsscene.html references.

  • HI,
    you are right, but i still have many Problems,
    First : how i can make the Picture as Background?
    Second , i can not use the same Scene for Image and for drawing , is that right ? because when i use QGraphicsScene to put an Image and use it agine for drawing , the Image is removed .
    About drawing on the Qgraphicsview ,can you tell me please exactly your Idee , how i can do that?

    do you mean that i have to create many RectF on the Trac?
    I try to do the Pictures as Background it does not work :
    Please see this :

    @QPixmap myPix;

       scene = new QGraphicsScene(this);

    // This add only the Image to the Graphicsview ,
    // but when i use the scene againe ,the positon of the Image is not as before
    // ui->graphicsView->setScene(scene);

       //I try to make the Image as Background it dose not work
      // do you mean i have to creat many REct like this and then add them to Graphicsview?
     scene->setSceneRect(-50,-50, 0, 0);



  • You are not supossed to put your picture directly to the QGraphicsView but to the QGraphicsScene you are willing to use.

    The QGraphicsScene::addPixMap() method will help you with that.

    I did something like what you want once and I'm almost sure I never had to use setCachemode() or similars.

    Please take your time to read the two references I gave you in the last post. Everything is in there, including what setSceneRect() is for.

  • hi,

    Iam trying now to creat many Rect on QGraphicsScene and then i will draw into the Rects so that drawing will be not outside of the trac , is this what you mean?

    ok, i will try today to read the tow references.


Log in to reply