Trying to capture QImage of video frame
-
no sir not really. The basic code is same as posted in this thread previously. This is just for the reference.You can directly suggest me which api or function will change the pixel formate of frame to RGB and allow me to save direct RGB only? or manually I need to add logic for conversion?
and the other thing I am not getting is why this gives me same frame? or I would say 1st frame only... -
It depends on the output you'll be using e.g. if OpenGL a shader will be used for that conversion.
Note that your grabber looks strange, you return all the types rather than just the one you would like to have and then you map the video frame as write only but you only read from it.
-
Thank you for reply. I tried as you say. but didn't get any change in output.what I do now?
k if you can suggest me any thing which can change frame output(regardless of its formate) rather than being same all the time at any instance i capture a frame.Output is going to same and it is equal to first frame. for instance at least if i'll get different pictures for different frames than for formate i'll convert manually,just for now. -
For converting YUV to RGB, Qt has a private API , qt_imageFromVideoFrame() , which could convert QVideoFrame to QImage in RGB format (I can't remember the exact RGB format to be converted) .
p.s It can't handle texture frame
You could try and see could it solve your problem first.
To enable the private API, you have to add this line in your .pro file
QT += multimedia-private
And include this header file
#include "private/qvideoframe_p.h"
Remarks: That is a private API. Use it as your own risk
-
Please be more precise. "Not working" doesn't say much. What are you getting ? A blank image ? A black image ? Funny colours ?
-
Please be more precise. "Not working" doesn't say much. What are you getting ? A blank image ? A black image ? Funny colours ?
-
Aren't you getting a .png file ?
-
You do realise that if you load your image again in a QImage, you'll get a RGB image ?
If you really want to save an RGB image then go for bitmap but beware, it's uncompressed.
-
oh yes thank you. this will solve my problem partially. but what about new frame capture.? can you please help me out where I am lacking or what i am missing? why I am getting the same frame every time?If I'll get updated frame my task will be almost on final stage.please solve this.and again thank you.
-
You always take the same image from the list, check that your counter increments properly and that you indeed update the list.
On a side note, you should pass const reference to QImage parameters. That will save useless copies.
-
Use:
const QImage &image
as parameter