Capture video size and frame rate with gstreamer/opencv

HI

I even created a video object.(

OpenCV · GitBook)

I want to measure FPS on a video object.

like in opencv
cam = cv.videocapture()
height = cam.get(cv.CAP_PROB_FRAME_HEIGHT)
I want to know the code to get the height.

Hi @HanJIK,

Both examples explain how to extract fps and size of the frame, can you point what is not exactly clear ?
The information is extract directly from the pipeline and not from the video capture device, since there is none, the stream comes com UDP packages.

I don’t understand about the UDP package.
Could you please explain again??

Is there any other way??
I need to measure the frame size and FPS of the real-time camera control video. Please

Hi HanJIK,
If you are using linux , Install Gstreamer on your computer and simply run the command " gst-launch-1.0 -e -v udpsrc port=5600 ! application/x-rtp, payload=96 ! rtpjitterbuffer ! rtph264depay ! avdec_h264 ! fpsdisplaysink sync=false text-overlay=true"

Thanks

Thank you.
How can I measure by entering and executing commands???

hi,
Are you currently working with an ROV or a Gstreamer based video sysyem?

yes, ROV video system used

you are able to see videos with your QGroundControl ,Right?

yes QGC reporting is Windows 10 based.
thank you

ok understood. Please go through this.
gstreamer-windows

in linux system , open a terminal and copy-paste the commands and you can see the frame rate and other details overlayed on video, provided your system is installed with gstreamer.

thank you

http://www.ardusub.com/developers/opencv.html
I even succeeded in viewing live video using the code in this link.

Thanks for the answer.

The video comes as encoded H264 frames via UDP, it’s a way to get video as fast as possible.

You can get the frame rate and image size directly from your ROV video stream configuration, the only value that may change is the frame rate, but it should not change if everything is working as expected.

But, if you want to get theses values directly with a program/script, you can get it with python with the line caps.get_structure(0).get_value('height') or caps.get_structure(0).get_value('width'), and with C++ using the variables width and height. The frame rate will be the rate that a new frame will be available, that can be done in the python script with the frequency of frame_available function and in the C++ with framecount frequency.

Thank you.
To check the frequency of the frame_available(self) function
How many times can I check the number of calls in 1 second?

Can I do this??
while True:
# Wait for the next frame
if not video.frame_available():
continue
# fps check
** curTime = time.time()**
** sec = curTime - prevTime**
** prevTime = curTime**

** fps = 1/(sec)**
** #end**
frame = video.frame()
cv2.imshow(‘frame’, frame)
if cv2.waitKey(1) & 0xFF == ord(‘q’):
break

Hello
Is my answer wrong??

Happy New Years

I look forward to your answer.
help me

The idea looks right. Have you tried it?