Python imutils.video.VideoStream() Examples
The following are 5
code examples of imutils.video.VideoStream().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
imutils.video
, or try the search function
.
Example #1
Source File: Camera.py From Facial-Recognition-Attendance-System with MIT License | 8 votes |
def start_capture(self, height=None, width=None, usingPiCamera=IS_RASPBERRY_PI, ): import imutils from imutils.video import VideoStream resolution = (self.height, self.width) if height: if width: resolution = (height, width) print("Camera Resolution:", resolution) cf = VideoStream(usePiCamera=usingPiCamera, resolution=resolution, framerate=30).start() self.current_frame = cf time.sleep(2) if not usingPiCamera: frame = imutils.resize(self.current_frame.read(), width=resolution[0], height=resolution[1]) # Stream started, call current_frame.read() to get current frame
Example #2
Source File: camera.py From mqtt-camera-streamer with GNU General Public License v3.0 | 8 votes |
def main(): client = get_mqtt_client() client.connect(MQTT_BROKER, port=MQTT_PORT) time.sleep(4) # Wait for connection setup to complete client.loop_start() # Open camera camera = VideoStream(src=VIDEO_SOURCE, framerate=FPS).start() time.sleep(2) # Webcam light should come on if using one while True: frame = camera.read() np_array_RGB = opencv2matplotlib(frame) # Convert to RGB image = Image.fromarray(np_array_RGB) # PIL image byte_array = pil_image_to_byte_array(image) client.publish(MQTT_TOPIC_CAMERA, byte_array, qos=MQTT_QOS) now = get_now_string() print(f"published frame on topic: {MQTT_TOPIC_CAMERA} at {now}") time.sleep(1 / FPS)
Example #3
Source File: Camera.py From SmoothStream with GNU General Public License v3.0 | 7 votes |
def start_capture(self, height=None, width=None, usingPiCamera=IS_RASPBERRY_PI, ): import imutils from imutils.video import VideoStream resolution = (self.height, self.width) if height: if width: resolution = (height, width) cf = VideoStream(usePiCamera=usingPiCamera, resolution=resolution, framerate=32).start() self.current_frame = cf time.sleep(2) if not usingPiCamera: frame = imutils.resize(self.current_frame.read(), width=resolution[0]) # Stream started, call current_frame.read() to get current frame
Example #4
Source File: tracker.py From telloCV with Apache License 2.0 | 6 votes |
def main(): """Handles inpur from file or stream, tests the tracker class""" arg_parse = argparse.ArgumentParser() arg_parse.add_argument("-v", "--video", help="path to the (optional) video file") args = vars(arg_parse.parse_args()) # define the lower and upper boundaries of the "green" # ball in the HSV color space. NB the hue range in # opencv is 180, normally it is 360 green_lower = (50, 50, 50) green_upper = (70, 255, 255) # red_lower = (0, 50, 50) # red_upper = (20, 255, 255) # blue_lower = (110, 50, 50) # upper_blue = (130, 255, 255) # if a video path was not supplied, grab the reference # to the webcam if not args.get("video", False): vid_stream = VideoStream(src=0).start() # otherwise, grab a reference to the video file else: vid_stream = cv2.VideoCapture(args["video"]) # allow the camera or video file to warm up time.sleep(2.0) stream = args.get("video", False) frame = get_frame(vid_stream, stream) height, width = frame.shape[0], frame.shape[1] greentracker = Tracker(height, width, green_lower, green_upper) # keep looping until no more frames more_frames = True while more_frames: greentracker.track(frame) frame = greentracker.draw_arrows(frame) show(frame) frame = get_frame(vid_stream, stream) if frame is None: more_frames = False # if we are not using a video file, stop the camera video stream if not args.get("video", False): vid_stream.stop() # otherwise, release the camera else: vid_stream.release() # close all windows cv2.destroyAllWindows()
Example #5
Source File: tracker.py From telloCV with Apache License 2.0 | 6 votes |
def get_frame(vid_stream, stream): """grab the current video frame""" frame = vid_stream.read() # handle the frame from VideoCapture or VideoStream frame = frame[1] if stream else frame # if we are viewing a video and we did not grab a frame, # then we have reached the end of the video if frame is None: return None else: frame = imutils.resize(frame, width=600) return frame