Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. What class or types can be used to do a real time image plot?
Forum Updated to NodeBB v4.3 + New Features

What class or types can be used to do a real time image plot?

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 3 Posters 2.3k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mrjjM mrjj

    Hi
    The seismic wave animation might be an issue with the QtCharts/other plotting classes.
    Do you plan to have much larger image ?
    I was wondering if direct QImage manipulation would be fast enough and leaning towards a custom QPainter implementation.
    http://doc.qt.io/qt-5/topics-graphics.html
    For a full blown high speed solution, OpenGLWidget comes to mind.

    How does the c code plot currently ? Direct screen buffer ?

    F Offline
    F Offline
    Flavio Mesquita
    wrote on last edited by Flavio Mesquita
    #3

    @mrjj Hi, at the moment it doesn´t plot, it just creates a .bin file every 500 iterations and we have to use some other software to load and show the static image, I saw something similar done with python that plots in realtime, the guy put the plot inside the loop, and everytime the code makes a iteration it refreshes the plot.
    But my code will have to be implemented with C++ because we need performance, even planning on using OpenACC directives. I believe we cannot implement OpenACC with Qt, so I may use an interface made with Qt for setting the parameters, call the program, pick the input file etc. I have the idea of creating the .bin files with less iterations, maybe 100, then create a Qt program that could read these files from the folder and plot it as they are created. Not sure if it is the best solution.

    mrjjM 1 Reply Last reply
    0
    • F Flavio Mesquita

      @mrjj Hi, at the moment it doesn´t plot, it just creates a .bin file every 500 iterations and we have to use some other software to load and show the static image, I saw something similar done with python that plots in realtime, the guy put the plot inside the loop, and everytime the code makes a iteration it refreshes the plot.
      But my code will have to be implemented with C++ because we need performance, even planning on using OpenACC directives. I believe we cannot implement OpenACC with Qt, so I may use an interface made with Qt for setting the parameters, call the program, pick the input file etc. I have the idea of creating the .bin files with less iterations, maybe 100, then create a Qt program that could read these files from the folder and plot it as they are created. Not sure if it is the best solution.

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #4

      @Flavio-Mesquita said in What class or types can be used to do a real time image plot?:

      OpenACC

      Well i think you can use it with Qt but it dubious you get accelerated gpu drawing out of the box if even possible.
      If the .bin files are some sort of image format ( like raw) , it might be possible to
      load with QImage and draw it.
      When you say , "need performance" is that on the data reading part or on the plotting part ?
      Unless saving to ramdisk, the slowest link will be the IO for the bin files.

      so goal is not live plotting but saving to bin files for later viewing?

      F 1 Reply Last reply
      0
      • mrjjM mrjj

        @Flavio-Mesquita said in What class or types can be used to do a real time image plot?:

        OpenACC

        Well i think you can use it with Qt but it dubious you get accelerated gpu drawing out of the box if even possible.
        If the .bin files are some sort of image format ( like raw) , it might be possible to
        load with QImage and draw it.
        When you say , "need performance" is that on the data reading part or on the plotting part ?
        Unless saving to ramdisk, the slowest link will be the IO for the bin files.

        so goal is not live plotting but saving to bin files for later viewing?

        F Offline
        F Offline
        Flavio Mesquita
        wrote on last edited by Flavio Mesquita
        #5

        @mrjj By performance I mean on the processing part, the Reverse Time Migration is quite heavy computationaly. If I use a simple input file, that is the subsurface velocity model, it is quick, lets say matter of few minutes, but if it is complicated it can take hours. Maybe live plotting is not necessary, if I have an application that keeps checking if there is a new raw .bin file on the folder and plot it, would solve the problem. So, u think QImage and Qpainter could do the job? The .bin files are not big, it ranges from 1 to 20 Mb.

        mrjjM 1 Reply Last reply
        0
        • F Flavio Mesquita

          @mrjj By performance I mean on the processing part, the Reverse Time Migration is quite heavy computationaly. If I use a simple input file, that is the subsurface velocity model, it is quick, lets say matter of few minutes, but if it is complicated it can take hours. Maybe live plotting is not necessary, if I have an application that keeps checking if there is a new raw .bin file on the folder and plot it, would solve the problem. So, u think QImage and Qpainter could do the job? The .bin files are not big, it ranges from 1 to 20 Mb.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #6

          @Flavio-Mesquita
          Ok, so the c++ speed gain would come from using threads?
          If the data input for QImage is only 20mb-ish i think it can handle it pretty well
          but it depends on your expected fps and the output size and how much pre-processing of the bin data is
          need before QImage will load it.
          It had pretty good speed with 640x480 images.

          F 1 Reply Last reply
          0
          • mrjjM mrjj

            @Flavio-Mesquita
            Ok, so the c++ speed gain would come from using threads?
            If the data input for QImage is only 20mb-ish i think it can handle it pretty well
            but it depends on your expected fps and the output size and how much pre-processing of the bin data is
            need before QImage will load it.
            It had pretty good speed with 640x480 images.

            F Offline
            F Offline
            Flavio Mesquita
            wrote on last edited by
            #7

            @mrjj said in What class or types can be used to do a real time image plot?:

            It had pretty good speed with 640x480 images.

            This size is perfect for me, do u have any examples of Qimage usage? Any book, tutorial, anything?

            mrjjM 1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #8

              Hi,

              Depending on what you need, did you consider using maybe CUDA with OpenGL to generate the images you want to show ?

              In any case, there are lots of examples using QImage in the Qt documentation. Depending on your needs the Mandelbrot example might be of interest.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              F 1 Reply Last reply
              2
              • F Flavio Mesquita

                @mrjj said in What class or types can be used to do a real time image plot?:

                It had pretty good speed with 640x480 images.

                This size is perfect for me, do u have any examples of Qimage usage? Any book, tutorial, anything?

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #9

                @Flavio-Mesquita
                The docs are pretty good.
                Basically it allows direct access and depending on the format of bin files you need something like

                QImage* img = new QImage(640, 480, QImage::Format_RGB16);
                for (int y = 0; y < img->height(); y++)
                {
                    memcpy(img->scanLine(y), BinData[y], img->bytesPerLine());
                }
                ...
                

                This is just pseudo code. Read about scanLine and friends in Docs
                QImage::Format_RGB16 is just one of several so there might be other that
                are closer to the .bin format layout.

                Its a often asked question on StackOverflow and also here
                https://forum.qt.io/topic/70653/how-to-display-8-bit-grayscale-raw-image-to-a-qlabel-and-display-it-in-x11-board

                but since i have zero idea of what your .bin contains its harder to suggest something direct.
                You most likely need to process the .bin to actually display it correctly.

                F 1 Reply Last reply
                0
                • SGaistS SGaist

                  Hi,

                  Depending on what you need, did you consider using maybe CUDA with OpenGL to generate the images you want to show ?

                  In any case, there are lots of examples using QImage in the Qt documentation. Depending on your needs the Mandelbrot example might be of interest.

                  F Offline
                  F Offline
                  Flavio Mesquita
                  wrote on last edited by
                  #10

                  @SGaist Hi, we considered using CUDA, but it is more complicated than OpenACC. We will give a try with it anyway to compare, I know it has better performance than OpenAcc, just don´t know how much better.

                  1 Reply Last reply
                  0
                  • mrjjM mrjj

                    @Flavio-Mesquita
                    The docs are pretty good.
                    Basically it allows direct access and depending on the format of bin files you need something like

                    QImage* img = new QImage(640, 480, QImage::Format_RGB16);
                    for (int y = 0; y < img->height(); y++)
                    {
                        memcpy(img->scanLine(y), BinData[y], img->bytesPerLine());
                    }
                    ...
                    

                    This is just pseudo code. Read about scanLine and friends in Docs
                    QImage::Format_RGB16 is just one of several so there might be other that
                    are closer to the .bin format layout.

                    Its a often asked question on StackOverflow and also here
                    https://forum.qt.io/topic/70653/how-to-display-8-bit-grayscale-raw-image-to-a-qlabel-and-display-it-in-x11-board

                    but since i have zero idea of what your .bin contains its harder to suggest something direct.
                    You most likely need to process the .bin to actually display it correctly.

                    F Offline
                    F Offline
                    Flavio Mesquita
                    wrote on last edited by
                    #11

                    @mrjj Thanks, I´ll take a look at these examples and references, I´ll be coming with more questions soon. First thing is to put the code to run properly with C++. The interface I already have. Now it is just a matter of adapt the RTM code., when everything is set and running I´ll start the work on the plotting part.
                    Cheers

                    mrjjM 1 Reply Last reply
                    1
                    • F Flavio Mesquita

                      @mrjj Thanks, I´ll take a look at these examples and references, I´ll be coming with more questions soon. First thing is to put the code to run properly with C++. The interface I already have. Now it is just a matter of adapt the RTM code., when everything is set and running I´ll start the work on the plotting part.
                      Cheers

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #12

                      @Flavio-Mesquita
                      Good plan.
                      also IF raw painting is too slow, its not too late there to go openGL or
                      anything accelerated

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved