Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Qt3D - Video Texture
IntenseDejavu last edited by
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; }