Error Releasing VideoCapture in OpenCV Using GStreamer Pipeline

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Nov 13 14:35:44 CET 2024


Hello Gaspar,

On Wed, Nov 13, 2024 at 12:51:11PM +0100, Gaspar Ramôa wrote:
> Dear libcamera community,
> 
> Thank you for developing such a helpful library.

I'm glad you find it helpful.

> I am trying to get frames using opencv. I am actually able to get frames via
> cv2.VideoCapture through GStreamer.
> 
> However, when I try to release the capture (for ending the program or maybe
> adjusting raw image size): cap.release()
> I get the following error:
> 
> [1:39:52.854669803] [1885] ERROR DeviceEnumerator device_enumerator.cpp:172
> Removing media device /dev/media4 while still in use
> [1:39:52.854709759] [1885] ERROR DeviceEnumerator device_enumerator.cpp:172
> Removing media device /dev/media3 while still in use
> 
> I've already published an issue on the raspberry Pi libcamera GitHub repo where
> you can get more detail on my problem: https://github.com/raspberrypi/libcamera
> /issues/163
> 
> I found the following commit which apparently did to solve the problem I am
> having now: https://github.com/raspberrypi/libcamera/commit/
> fa63d428aef62bacf0a6ad1622a7965b3ff2ba2f 

That commit has been merged a long time ago, before v0.0.1, so I expect
it is included in the libcamera version you are using. Your problem may
have the same symptoms but a different root cause.

You mentioned in your bug report that you tried both libcamera v0.0.5
and v0.3.0+65-6ddd79b5. v0.0.5 is fairly old. v0.3.0 is better, but I
would still recommend trying the latest master branch to see if the
issue has been fixed already.

If the issue is still present, can you try running the same GStreamer
pipeline (likely replacing appsink with some sort of display sink, or
even fakesink) from gst-launch, and see if the problem exists there too
?

> This commit was done by the user https://github.com/pinchartl. But I have no
> way of contacting him to help me fix the problem.

I'm slightly puzzled by why you had trouble contacting me, given that my
e-mail address is listed in the commit you mentioned above. Regardless,
it looks like you found a way :-) 

> Any suggestions? Thanks in advance!

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list