gocv icon indicating copy to clipboard operation
gocv copied to clipboard

Add support for the VideoCapture::retrieve method.

Open khushbuadav opened this issue 2 years ago • 2 comments

Description

I’m trying to capture the latest frames from an RTSP stream and doing some processing which adds delay in fetching the next frame from the stream. I don’t need to read all the missed frames but get the latest frame and skip the remaining from the buffer. I am planning to use two goroutines. One go routine will continuously grab(VideoCapture::grab) the frames and not process them. The second go routine will be used to retrieve the latest frame and process it.

Right now I am using VideoCapture::read in the second go routine which internally calls VideoCapture::grab. And because of this, I am getting below error during read.

Assertion fctx->async_lock failed at src/libavcodec/pthread_frame.c:155
SIGABRT: abort
PC=0x7fdcb53797bb m=0 sigcode=18446744073709551610

I assumed this is because both the go routine are calling grab at the same time.

Ideally, in the second go routine we should just call retrieve and get the latest from the buffer. However, I did not find the retrieve method in gocv.

Your Environment

  • GoCV version used: 0.29.0
  • Go version: 1.17.2 darwin/amd64

khushbuadav avatar Jan 27 '22 13:01 khushbuadav

is this implemented? @deadprogram

quanqigu avatar Sep 04 '22 02:09 quanqigu

retrieve() is actually not implemented, looks like it was overlooked.

A PR to add this would be welcomed!

Please see https://github.com/hybridgroup/gocv/blob/release/CONTRIBUTING.md#something-you-wantneed-from-opencv-does-not-appear-to-be-in-gocv

deadprogram avatar Sep 06 '22 08:09 deadprogram

Released as part of 0.36 so now closing. Thank you!

deadprogram avatar Apr 02 '24 05:04 deadprogram