AETHER-2319 Move VideoCapture to frame()

Change-Id: Ic9d266c9455565abc0e9dbf351e5b3cd63bc4774
diff --git a/person_detection/person_detection.py b/person_detection/person_detection.py
index 6f56a6f..4b1611d 100644
--- a/person_detection/person_detection.py
+++ b/person_detection/person_detection.py
@@ -63,20 +63,15 @@
         self.n, self.c, self.h, self.w = net.inputs[self.input_blob].shape
         del net
         if args.input == 'cam':
-            input_stream = 0
+            self.input_stream = 0
         elif args.input == 'gstreamer':
             # gst rtp sink
-            input_stream = 'udpsrc port=5000 caps = " application/x-rtp, encoding-name=JPEG,payload=26" ! rtpjpegdepay ! decodebin ! videoconvert ! appsink'
-            #input_stream = 'udpsrc port=5000 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! decodebin ! videoconvert ! appsink'
+            self.input_stream = 'udpsrc port=5000 caps = " application/x-rtp, encoding-name=JPEG,payload=26" ! rtpjpegdepay ! decodebin ! videoconvert ! appsink'
+            #self.input_stream = 'udpsrc port=5000 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! decodebin ! videoconvert ! appsink'
         else:
             input_stream = args.input
             assert os.path.isfile(args.input), "Specified input file doesn't exist"
 
-        if input_stream == 'gstreamer':
-            self.cap = cv2.VideoCapture(input_stream, cv2.CAP_GSTREAMER)
-        else:
-            self.cap = cv2.VideoCapture(input_stream)
-
         if args.labels:
             with open(args.labels, 'r') as f:
                 self.labels_map = [x.strip() for x in f]
@@ -92,6 +87,12 @@
         cv2.destroyAllWindows()
 
     def frames(self):
+
+        if self.input_stream == 'gstreamer':
+            self.cap = cv2.VideoCapture(self.input_stream, cv2.CAP_GSTREAMER)
+        else:
+            self.cap = cv2.VideoCapture(self.input_stream)
+
         cur_request_id = 0
         next_request_id = 1