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. Qt3D - Video Texture
QtWS25 Last Chance

Qt3D - Video Texture

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 440 Views
  • 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.
  • I Offline
    I Offline
    IntenseDejavu
    wrote on last edited by
    #1

    Hello everybody!
    I'm creating a 3D scene in C++ via 3D render module.
    I'm not using any qml file, just C++.

    I sucessfuly got a 3d scene with my custom object in it. Everything was going fine but now i think i hit the wall...

    I need to set an image texture on my object.... the problem is that it should update quickly ( video texture )....
    I got the image there but i can only load it at costruct time since it needs a QUrl.... but my intention is to use a Opencv frame ( cv::Mat) is there any workaround on it? (I think writtig a png and load for each frame will grill the computer!)
    I searched alot on Qt Material classes and none of them AFAIK supports it.... I sucessfully got the Mat to QImage....but there's no way to use QImage aswell.... Abstract texture was good but only accepts QUrl.

    Any workarounds or feedback would be appreciated thanks!

    I will leave some snippets of my code

    Where I need to load the frame texture from opencv...

        // screen
        m_screenEntity = new Qt3DCore::QEntity(m_rootEntity);
        // screen shape data
        screenMesh = new Qt3DExtras::QPlaneMesh(m_screenEntity);
        screenMesh->setWidth(0.6);
        screenMesh->setHeight(0.23);
    
        // screen mesh transform
        screenTransform = new Qt3DCore::QTransform(m_screenEntity);
        screenTransform->setScale(1.3f);
        screenTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(1.0f, 0.0f, 0.0f), 90.0f));
        screenTransform->setTranslation(QVector3D(posx, posy, posz+ screenoffset));
    
        //screen material
        screenMaterial = new Qt3DExtras::QPhongMaterial(m_screenEntity);
        screenMaterial->setDiffuse(QColor(QRgb(0xa69929)));
    

    The frame processing

            Mat frame;
            // Capture frame-by-frame
            this->cap >> frame;
    
            // If the frame is empty, break immediately
            if (frame.empty())
                break;
    
            // Display the resulting frame --> should update object texture instead
            imshow("Frame", frame); 
    
            // Press  ESC on keyboard to exit
            char c = (char)waitKey(25);
            if (c == 27)
                break;
        }
    

    thanks,
    André

    D 1 Reply Last reply
    0
    • I IntenseDejavu

      Hello everybody!
      I'm creating a 3D scene in C++ via 3D render module.
      I'm not using any qml file, just C++.

      I sucessfuly got a 3d scene with my custom object in it. Everything was going fine but now i think i hit the wall...

      I need to set an image texture on my object.... the problem is that it should update quickly ( video texture )....
      I got the image there but i can only load it at costruct time since it needs a QUrl.... but my intention is to use a Opencv frame ( cv::Mat) is there any workaround on it? (I think writtig a png and load for each frame will grill the computer!)
      I searched alot on Qt Material classes and none of them AFAIK supports it.... I sucessfully got the Mat to QImage....but there's no way to use QImage aswell.... Abstract texture was good but only accepts QUrl.

      Any workarounds or feedback would be appreciated thanks!

      I will leave some snippets of my code

      Where I need to load the frame texture from opencv...

          // screen
          m_screenEntity = new Qt3DCore::QEntity(m_rootEntity);
          // screen shape data
          screenMesh = new Qt3DExtras::QPlaneMesh(m_screenEntity);
          screenMesh->setWidth(0.6);
          screenMesh->setHeight(0.23);
      
          // screen mesh transform
          screenTransform = new Qt3DCore::QTransform(m_screenEntity);
          screenTransform->setScale(1.3f);
          screenTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(1.0f, 0.0f, 0.0f), 90.0f));
          screenTransform->setTranslation(QVector3D(posx, posy, posz+ screenoffset));
      
          //screen material
          screenMaterial = new Qt3DExtras::QPhongMaterial(m_screenEntity);
          screenMaterial->setDiffuse(QColor(QRgb(0xa69929)));
      

      The frame processing

              Mat frame;
              // Capture frame-by-frame
              this->cap >> frame;
      
              // If the frame is empty, break immediately
              if (frame.empty())
                  break;
      
              // Display the resulting frame --> should update object texture instead
              imshow("Frame", frame); 
      
              // Press  ESC on keyboard to exit
              char c = (char)waitKey(25);
              if (c == 27)
                  break;
          }
      

      thanks,
      André

      D Offline
      D Offline
      drawmer
      wrote on last edited by
      #2

      @IntenseDejavu Any solution for this? I'm in the same problem. But every "solution" I find isn't suported in QT 5.15. Or need a QUrl. But I also need to simulate a video with Cv:Mat

      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