Display openCL's cl buffer as QImage



  • 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!


  • Lifetime Qt Champion

    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.



  • 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



  • Linking issue resolved by adding:

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

    to all included headers


  • Lifetime Qt Champion

    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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.