Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Opencv image in qt3d

    General and Desktop
    1
    1
    624
    Loading More Posts
    • 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
      sunil.nair last edited by

      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 Reply Quote 0
      • First post
        Last post