Recording and USB Web Cameras with the BBAI and OpenCV

Did you ever want to record video from your USB Camera with the AI with OpenCV?

Recording and USB Web Cameras with the BBAI and OpenCV

Categories: Beginner


On the AI w/ your installed image, use these commands to get up and running.

  • sudo apt install python-opencv python-numpy python-matplotlib


  • sudo apt install python3-opencv python3-numpy python3-matplotlib

That should get us our required software to use for using specific ideas revolving around numpy, matplotlib, and OpenCV.

If you want, you can use a keyboard, mouse, and your HDMI connection to the AI if needed or you can use tightvncserver along w/ PuTTY and VNC Viewer on a Windows dev. desktop.

So, if you so desire, get the source at the end of this small presentation, type python <> in the terminal and see glory at its finest.

Recording in "high" def!

So, we have all our components and tools available to get us along the journey now (hopefully). If not, take a look back at the short description.

Okay, we have a USB Camera, USB Hub, USB Fan, and the AI and our source/software. Now, we need to stick our hardware together and make this source run.

I am retesting this source and maybe updating it soon! Enjoy!

import cv2 as cv

import numpy as np

cap = cv.VideoCapture(0)


# Take each frame
_, frame =

# Convert BGR to HSV
hsv = cv.cvtColor(frame, cv.COLOR_BGR2HSV)

# define range of blue color in HSV
lower_blue = np.array([110,50,50]) # Play with these numbers and see the outcome
upper_blue = np.array([130,255,255]) # Play with these values too! Play!

# Threshold the HSV image to get only blue colors
mask = cv.inRange(hsv, lower_blue, upper_blue)

# Bitwise-AND mask and original image
res = cv.bitwise_and(frame,frame, mask= mask)

k = cv.waitKey(5) & 0xFF
if k == 27:



P.S. If you look below, you will find the source for your USB Camera on the AI. Oh and if you do not use your USB Fan on the AI, it may get too hot to stay connected. It really depends on if you have followed along in the instructions from when you purchased your AI. Use the fan! Again and I repeat, USE THE FAN! Just put it over the am57xx chip or over your already attached heat sink. Hot!

This is from altering the source given which can be firstly found at
for tracking purposes.

Sometimes the most fun one could have is pointless. Enjoy your time on Earth! Oh…there is a FanCape now for the BBAI. It should cool off those warm processors when maxing out your metal, PCB, and silicon.

Comments are not currently available for this post.