Unsolved Convert QvideoFrame to Mat image
-
Hello,
i need to analyze a QvideoFrame in OpenCV, how do i convert the QvideoFrame into a Mat image?Thanks
-
Hi
To answer you question you will need three things,Image data -> can be taken from bits() (be sure to call map() function first)
image dimensions -> call width() and height() function
image data format -> call pixelFormat()Use those information to create cv::Mat
However if you want to analyze frames from OpenCV why dont you use it to read the video in first place. Why use Qt?
Thanks
-
@asanka424 I am using QT because i need a GUI.. ye..would have been way easier that way
-
@giuBRIT You can still use Qt widgets with OpenCV. In a simplest way, you can update the image on QLabel as your video output. But all depend on your application requirements
-
@asanka424 Could you please be more specific regarding the three things? I don't quite understnad how to call bits and map function.. would you mind posting a small example?
-
@giuBRIT Unfortunately I dont have a sample code to share with you. But to give you more information
Image data is bits in your image. For example if you have a video frame of 640x480 pixels which means you have 640*480 pixel data. These data will be in a byte array. How this array is formed depend on the format of your video frame. For example if this is a 8 bit grey scale image your array will have same number of bytes as your pixels. If this is a RGB (color) image each pixel will have three bytes to represent the colors of Red, Green and Blue components. Also these color components can be in a different order, for example, it cant BGR rather than RGB. Thats why you want to know the pixel format. Last the dimensions will tell you width and height of your frame.If you are not familiar with these things I strongly encourage you to read relevant literature and get a good idea.
Thanks
-
@asanka424 thanks
-
This post is deleted! -
This post is deleted!