Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Intel Edison Projects

You're reading from  Intel Edison Projects

Product type Book
Published in May 2017
Publisher Packt
ISBN-13 9781787288409
Pages 264 pages
Edition 1st Edition
Languages
Concepts
Author (1):
Avirup Basu Avirup Basu
Profile icon Avirup Basu

Table of Contents (7) Chapters

Preface Setting up Intel Edison Weather Station (IoT) Intel Edison and IoT (Home Automation) Intel Edison and Security System Autonomous Robotics with Intel Edison Manual Robotics with Intel Edison

Real-time video display using OpenCV

Before we move on to face detection, let's first see whether we can access our camera or not. To do that, let's write a very simple Python script to display the webcam video feed:

import cv2 

cap = cv2.VideoCapture(0)

while(True):
# Capture frame-by-frame
ret, frame = cap.read()

# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

# Display the resulting frame
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

In the preceding code, we initially import the openCV module as import cv2.

Next we initialize the video capture device and set the index to zero as we're using the default webcam that comes with the laptop. For desktop users, you may need to vary the parameter.

After...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}