Solved Create a dynamic QOpenGLTexture from external device data
-
Hi and welcome to devnet,
What type of camera is it ? Where are you getting theses images from ?
-
The camera is Intel RealSense SR300 RGBD.
Here is the library that handles i/o with camera and here is the
API.Basically library provides the end user with synchronous call:
const void* rs_get_frame_data(rs::stream stream, rs::format format, int width, int height ... )
That gives the the user a pointer to data gathered by last frame.
Since camera is RGB+D you have multiple streams of data with different internal pixel formats.You select the stream providing:
rs::stream stream
parameter and pixel format by providingrs::format format
param.
One can also ensure that current thread execution is blocked till the "next frame" is available" by calling:rs_wait_for_frames(...)
How fast internal frame buffer changes is set during initalization of camera device (but its always : 30FPS, 60 FPS or 10FPS)
In my code I use RGB color stream and rgb8 pixel format (3 channels, 8bits per one, no compression).
EDIT:
I've get the streaming *semi-working by completly removing any dependence on QOpenGLTexture and using raw low-lvl OpenGL calls insidepaint()
.
This is a pathetic solution though.What is the elegant, proper way to get it working (one that involwes using Qt for actuall stuff) ?
-
Like I wrote on the other thread, I usually wrote a backend that allows to integrate the sutff in the QtMultimedia pipeline.
In the most simplified way, it comes to create a QVideoBuffer with the proper data to pass to QtMultimedia.
-
Thanks, what do you mean exactly by QtMultimedia - this is a global object from what I know.
Do I need implement any other class than QVideoBuffer?
To what object, of what class I should pass my QVideoBuffer instance after I fill it with data?http://stackoverflow.com/questions/43854589/custom-source-property-for-videooutput-qml
-
I mean the QtMultimedia module and more precisely what's behind the QCamera class
-
Behind (in inheritance chain) QCamera class there's QMediaObject I don't see any properties or methods that deal with actual frame data or allow me to change the data source QCamera is using.
I don't see any QVideoBuffer object associated with QCamera class.The whole frame data flow is really obscure and unclear to me.
The objects named in a way that suggests they provide frame stream (i.e QCamera) don't seem to provide any access to frames at all.OpenGL approach is more straightforward.
I admit only worked with Qt with since four days and I am not very fond of it. -
You should take a look at the QtMultimedia plugins sources.
-
I looked at them and I see a dozen of different classess just for camera.
I've got the feed from camera with 150 lines of code using raw GL and qt scene graph.
Unfortunately I don't have enough time to become Qt developer and read whole QMultimedia codebase to do it the way you suggest.Thanks anyway.
-
While I completely understand your lack of time I'd like to point that you don't need to know the whole QtMultimedia codebase to get the hang of the QCamera backends.
In any case, I'm glad you found a working solution and since you have it running now, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)
Happy coding ! :)
-
@SGaist said in Create a dynamic QOpenGLTexture from external device data:
While I completely understand your lack of time I'd like to point that you don't need to know the whole QtMultimedia codebase to get the hang of the QCamera backends.
This is most likely true, however you're able to say it only beacuse you already know how QMultimedia works and therefore you're able to pick the most efficient learning/reading route for QCamera backed thing.
Without your knowledge the learning experience would be closer to "random-walk over seemingly related files" :)Marked as solved.
-
The first time I wrote a QCamera backend I didn't knew much about the internals of QtMultimedia (and I still don't know all the details of every aspect of the module).
I took a look at several of the existing QCamera related plugins that did at least part of what I was interested in and then applied the same concepts. I was not a random walk but looking at the sources provided a pretty quick insight of how I could write my own.