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. Display openCL's cl buffer as QImage
Qt 6.11 is out! See what's new in the release blog

Display openCL's cl buffer as QImage

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.1k Views 1 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi All,

    I want to display an openCL image in a Qt label or graphicswindow doing minimal number of conversions in between (to achieve highest frame rate in display).
    I have a 1-channel image stored in float cl::buffer.
    What would be the best way to convert it into QImage?
    Maybe there's another way, not using QImage? OpenGL?
    Very new to Qt so any help is appreciated!

    Thanks!

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

      Hi and welcome to devnet,

      Since you are already working on the GPU, you should take a look a the OpenGL-OpenCL interop docs and use a QOpenGLWidget (or if on Qt 4, QGLWidget) for the display part. This should give you a better throughput than going back and forth from GPU to CPU to create a QImage (or QPixmap) for your QLabel.

      However, I can't point you to an example, I haven't done work yet with OpenCL, only CUDA <-> QGLWidget.

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

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Hi,

        Thanks.
        Decided to try QGLWidget.
        Having trouble linking...
        I'm using Qt5 and VS2013.
        I added Qt5OpenGL.lib and Qt5OpenGLExtensions.lib (just in case) to linker->input->Additional Dependencies
        The 'lib' folder is also pointed to.
        Includes are recognized. Build fails when linking:

        @
        1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QGLWidget::QGLWidget(class QWidget *,class QGLWidget const *,class QFlags<enum Qt::WindowType>)" (_imp??0QGLWidget@@QAE@PAVQWidget@@PBV0@V?$QFlags@W4WindowType@Qt@@@@@Z) referenced in function "public: __thiscall MeGLwindow::MeGLwindow(void)" (??0MeGLwindow@@QAE@XZ)
        1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QGLWidget::~QGLWidget(void)" (_imp??1QGLWidget@@UAE@XZ) referenced in function "public: virtual __thiscall MeGLwindow::~MeGLwindow(void)" (??1MeGLwindow@@UAE@XZ)
        1>main.obj : error LNK2001: unresolved external symbol "protected: virtual bool __thiscall QGLWidget::event(class QEvent *)" (?event@QGLWidget@@MAE_NPAVQEvent@@@Z)
        1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QGLWidget::glDraw(void)" (?glDraw@QGLWidget@@MAEXXZ)
        1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QGLWidget::glInit(void)" (?glInit@QGLWidget@@MAEXXZ)
        1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QGLWidget::initializeGL(void)" (?initializeGL@QGLWidget@@MAEXXZ)
        1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QGLWidget::initializeOverlayGL(void)" (?initializeOverlayGL@QGLWidget@@MAEXXZ)
        1>main.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall QGLWidget::metaObject(void)const " (?metaObject@QGLWidget@@UBEPBUQMetaObject@@XZ)
        1>main.obj : error LNK2001: unresolved external symbol "public: virtual class QPaintEngine * __thiscall QGLWidget::paintEngine(void)const " (?paintEngine@QGLWidget@@UBEPAVQPaintEngine@@XZ)
        1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QGLWidget::paintEvent(class QPaintEvent *)" (?paintEvent@QGLWidget@@MAEXPAVQPaintEvent@@@Z)
        1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QGLWidget::paintGL(void)" (?paintGL@QGLWidget@@MAEXXZ)
        1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QGLWidget::paintOverlayGL(void)" (?paintOverlayGL@QGLWidget@@MAEXXZ)
        1>main.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall QGLWidget::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QGLWidget@@UAEHW4Call@QMetaObject@@HPAPAX@Z)
        1>main.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall QGLWidget::qt_metacast(char const *)" (?qt_metacast@QGLWidget@@UAEPAXPBD@Z)
        1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QGLWidget::resizeEvent(class QResizeEvent *)" (?resizeEvent@QGLWidget@@MAEXPAVQResizeEvent@@@Z)
        1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QGLWidget::resizeGL(int,int)" (?resizeGL@QGLWidget@@MAEXHH@Z)
        1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QGLWidget::resizeOverlayGL(int,int)" (?resizeOverlayGL@QGLWidget@@MAEXHH@Z)
        1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QGLWidget::updateGL(void)" (?updateGL@QGLWidget@@UAEXXZ)
        1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QGLWidget::updateOverlayGL(void)" (?updateOverlayGL@QGLWidget@@UAEXXZ)
        @

        Any ideas?

        Thanks

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Linking issue resolved by adding:

          @
          #pragma comment(lib, "Qt5OpenGL.lib")
          @

          to all included headers

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

            Are you using the VC2013 Express edition ?

            If not, there's the Qt VS-Addin that you could use to setup Qt Project, otherwise you could also use Qt Creator.

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

            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