Hello Team,
Using below code is causing little memory to build up and not releasing it until we restart the procress. First run take about 500MB and each run adds about 2MB and adds it to the RAM. RAM usage goes from 0-90% in few days some times it goes up in a day. I used memory profiler and it shows the ram usage is from videoCapture.read()
Sample Code
videoCapture = cv2.VideoCapture(self.videoCapture_url)
videoCapture.set(_cv2.CAP_PROP_FRAME_WIDTH, self.resize[0])
videoCapture.set(_cv2.CAP_PROP_FRAME_HEIGHT, self.resize[1])
while True:
if not videoCapture.isOpened():
success, frame = self.videoCapture.read() #Memory builds up here.
Please let me know if there is a solution to release that memory and any more information is needed.
1 Like
can’t reproduce. please provide all material that’s required to reproduce this. have you considered that knowing the value of videoCapture_url
might be helpful? that’s one piece.
Thanks for the reply, really appreciate it.
I wont be able to provide the actual videoCapture_url. But let me give the same code.
import cv2 as _cv2
url = https://web.cam.ip/video.web?sessionid=1234&cameraid=123454/format=H.264 (AVC)
videoCapture = _cv2.VideoCapture(url)
videoCapture.set(_cv2.CAP_PROP_FRAME_WIDTH, 140)
videoCapture.set(_cv2.CAP_PROP_FRAME_HEIGHT, 140)
if not videoCapture.isOpened():
error = ValueError(
f"videoCapture.isOpened() = {videoCapture.isOpened()}"
)
raise error
success, frame = self.videoCapture.read()
#converting frame from BGR to RBG
frame = frame[:, :, ::-1]
return frame
Also as the url is https and it takes sessionId as a auth parameter, is it possible to convert it to a gstreamer pipeline?
Thanks