From c344efc22401ef9ccc69c1dc031d9e04dedbe133 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Thu, 29 Aug 2019 17:41:23 +0200 Subject: [PATCH] weight_decay fix --- utils/datasets.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/utils/datasets.py b/utils/datasets.py index 941352dd..177fea48 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -124,6 +124,8 @@ class LoadWebcam: # for inference pipe = 0 # local camera # pipe = 'rtsp://192.168.1.64/1' # IP camera # pipe = 'rtsp://username:password@192.168.1.64/1' # IP camera with login + pipe = 'rtsp://170.93.143.139/rtplive/470011e600ef003a004ee33696235daa' # IP traffic camera + # pipe = 'http://wmccpinetop.axiscam.net/mjpg/video.mjpg' # IP golf camera # https://answers.opencv.org/question/215996/changing-gstreamer-pipeline-to-opencv-in-pythonsolved/ # pipe = '"rtspsrc location="rtsp://username:password@192.168.1.64/1" latency=10 ! appsink' # GStreamer @@ -132,6 +134,7 @@ class LoadWebcam: # for inference # https://stackoverflow.com/questions/54095699/install-gstreamer-support-for-opencv-python-package # install help # pipe = "rtspsrc location=rtsp://root:root@192.168.0.91:554/axis-media/media.amp?videocodec=h264&resolution=3840x2160 protocols=GST_RTSP_LOWER_TRANS_TCP ! rtph264depay ! queue ! vaapih264dec ! videoconvert ! appsink" # GStreamer + self.pipe = pipe self.cap = cv2.VideoCapture(pipe) # video capture object def __iter__(self): @@ -144,11 +147,23 @@ class LoadWebcam: # for inference cv2.destroyAllWindows() raise StopIteration - # Read image - ret_val, img0 = self.cap.read() + # Read frame + if self.pipe == 0: # local camera + ret_val, img0 = self.cap.read() + img0 = cv2.flip(img0, 1) # flip left-right + else: # IP camera + n = 0 + while True: + n += 1 + self.cap.grab() + if n % 30 == 0: # skip frames + ret_val, img0 = self.cap.retrieve() + if ret_val: + break + + # Print assert ret_val, 'Webcam Error' img_path = 'webcam_%g.jpg' % self.count - img0 = cv2.flip(img0, 1) # flip left-right print('webcam %g: ' % self.count, end='') # Padded resize