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. Opencv image in qt3d
Qt 6.11 is out! See what's new in the release blog

Opencv image in qt3d

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 765 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.
  • S Offline
    S Offline
    sunil.nair
    wrote on last edited by
    #1

    Hello, i am successfully able to integrate QT with opencv using this tutorial:

    http://stackoverflow.com/questions/15881913/how-to-link-opencv-in-qtcreator-and-use-qt-library

    However, i am trying to write the code not in the main.cpp file but in a different cubevie.cpp file that comes as a tutorial with qt3d.

    @/*
    ****************************************************************************/
    #include <QApplication>
    #include "cubeview.h"
    #include "qglbuilder.h"
    #include "qglcube.h"
    #include "haptics.h"
    #include <iostream>
    #include <QThread>
    #include <QTimer>
    #include <QDebug>
    #include "qglpainter.h"
    #include "qgraphicstranslation3d.h"
    #include "opencv2/core/core.hpp"
    #include "opencv2/highgui/highgui.hpp"
    //#include "opencv/cv.h"

    //! [1] constructor, initialize the cube, cursor and camera
    CubeView::CubeView(QWidget *parent)
    {
    //opencv code
    cv::Mat image;
    image= cv::imread(":/blackcircle.jpg");
    cv::namedWindow("hello");
    cv::imshow("hello", image)

    //! [1]
    QGLBuilder builder1;
    builder1 << QGL::Faceted;
    builder1 << QGLCube(2);
    cube = builder1.finalizedSceneNode();
    
    //camera setup
    camera()->setFieldOfView(35);
    camera()->setNearPlane(1);
    camera()->setFarPlane(15);
    

    //! [2] set texture for cube and cursor
    logo.setImage(QImage(QLatin1String(":/blackcircle.jpg")));

    }

    CubeView::~CubeView()
    {
    logo.cleanupResources();
    delete cube;
    }
    //! [3]
    void CubeView::paintGL(QGLPainter *painter)
    {
    painter->setStandardEffect(QGL::LitDecalTexture2D);
    logo.bind();
    cube->draw(painter);

    }

    @

    *But this gives me the following error.
    QWidget: Cannot create a QWidget without QApplication
    Invalid parameter passed to C runtime function.

    Is it because, already a window is open and I cannot open another window to see my image?*

    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