Reader small image

You're reading from  Artificial Intelligence for IoT Cookbook

Product typeBook
Published inMar 2021
Reading LevelIntermediate
PublisherPackt
ISBN-139781838981983
Edition1st Edition
Languages
Right arrow
Author (1)
Michael Roshak
Michael Roshak
author image
Michael Roshak

Michael Roshak is a cloud architect and strategist with extensive subject matter expertise in enterprise cloud transformation programs and infrastructure modernization through designing, and deploying cloud-oriented solutions and architectures. He is responsible for providing strategic advisory for cloud adoption, consultative technical sales, and driving broad cloud services consumption with highly strategic accounts across multiple industries.
Read more about Michael Roshak

Right arrow

How to do it...

The steps for this recipe are as follows:

  1. Import OpenCV:
import cv2
  1. Select the camera:
cap = cv2.VideoCapture(0)
  1. Check whether the camera is available:
if not (cap.isOpened()):
print('Could not open video device')
  1. Capture, save, and show frames from the camera:
x = 0
while(True):
ret, frame = cap.read()
cv2.imshow('preview',frame)
time.sleep(1)
cv2.imwrite(f'./images/cap{x}.jpg', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
  1. Release the camera:
cap.release()
cv2.destroyAllWindows()
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Artificial Intelligence for IoT Cookbook
Published in: Mar 2021Publisher: PacktISBN-13: 9781838981983

Author (1)

author image
Michael Roshak

Michael Roshak is a cloud architect and strategist with extensive subject matter expertise in enterprise cloud transformation programs and infrastructure modernization through designing, and deploying cloud-oriented solutions and architectures. He is responsible for providing strategic advisory for cloud adoption, consultative technical sales, and driving broad cloud services consumption with highly strategic accounts across multiple industries.
Read more about Michael Roshak