hybridgroup / gocv

Go package for computer vision using OpenCV 4 and beyond. Includes support for DNN, CUDA, OpenCV Contrib, and OpenVINO.
https://gocv.io
Other
6.65k stars 865 forks source link

VideoCaptureFPS Does not work #913

Open llianc62 opened 2 years ago

llianc62 commented 2 years ago

When I set VideoCaptureFPS property it does do changed.

Description

I wanna change the frame rate of reading video.

Steps to Reproduce

here is my code:

package main

import (
    "log"

    "gocv.io/x/gocv"
)

func main() {

    webcam, _ := gocv.OpenVideoCapture("test.mp4")

    webcam.Set(gocv.VideoCaptureFPS, 30)
    log.Printf("video rate: %f", webcam.Get(gocv.VideoCaptureFPS))
}

output:

2021/12/07 21:05:53 video rate: 60.042750

Your Environment

wgjtyu commented 2 years ago

after search by google, I have got this: https://stackoverflow.com/questions/52068277/change-frame-rate-in-opencv-3-4-2

wgjtyu commented 2 years ago

this may help us https://github.com/hybridgroup/gocv/blob/release/videoio.go#L379

jiekechoo commented 6 months ago

You should use webca.Grab(webcam.Get(gocv.VideoCaptureFPS) - yourFps) to skip frames before calling webcam.Read()