cassick.blogg.se

Opencv ffmpeg rtsp python
Opencv ffmpeg rtsp python













opencv ffmpeg rtsp python

I tried this code, but it’s still not working, i.e. Return cv2.resize(frame,(self.width, self.height)) #read current frame, send it to method that will return it to object detection

opencv ffmpeg rtsp python

Self.p = mp.Process(target=ab_frames, args=(child_conn,rtsp_url))Ĭap = cv2.VideoCapture(rtsp_url,cv2.CAP_FFMPEG) #load pipe for data transmittion to the process _plot_image(frame_np_new)ĭef _init_(self, rtsp_url, width, height): # here, I'm sending fetching the frame currently being handled by bufferless_cameraįrame_nd_orig = mx.nd.array(cv2.cvtColor(frame_np_orig, cv2.COLOR_BGR2RGB)).astype('uint8')įrame_nd_new, frame_np_new = .ansform_test(frame_nd_orig, short=600)įrame_nd_new = frame_nd_new.as_in_context(ctx)Ĭlass_IDs, scores, bboxes = net(frame_nd_new)įrame_np_new = _plot_bbox(frame_np_new, bboxes, scores, class_IDs, thresh=0.8, class_names=net.classes) Net = gcv.model_zoo.get_model('faster_rcnn_resnet50_v1b_coco', pretrained=True, ctx=ctx)Ĭam = bufferless_camera("rtsp://camera_IP_address:port_number", 640, 480) The code I have is something like this: import time Whenever the object detection finishes analyzing a frame, it requests the frame currently being grabbed by the camera_bufferless process. The idea is that I have a process (say, camera_bufferless), parallel to object detection, constantly grabbing frames from the camera. I first tried setting the buffer length by: cap = cv2.VideoCapture("rtsp://camera_IP_address:port_number") This happens automatically when using a camera connected through USB, but with a RTSP stream the frames are buffered, so after completing the detection on frame 01 the program proceeds to analyze frame 02, which I want to avoid. After the elaboration of frame 01 is completed the detection jumps to the frame currently streamed, which is #06. In the meanwhile, the camera gets other 4 frames, from 02 to 05, which should be ignored. So, basically the program should get the first frame and analyze it.















Opencv ffmpeg rtsp python