Captura de imagem em Beaglebone Black usando OpenCV (Parte 12/15)

Image capture in Beaglebone Black using OpenCV (Part 12/15)

As I already explained how to interface web cam with BBB here I will talk about image capture using python script programming. It is a simple tutorial where you can also add effects in the form of black and white image, motion detection, sharp image, etc. I used the opencv library which programs real-time computer functions and machine learning.

Required tools:

  • Black Beaglebone
  • webcam

Environment Setting

Before proceeding, create a configuration as explained in how to interface the web cam with BBB. Connect the webcam to the BBB via the USB port. Connect to the internet and turn on BBB. You have remote access from BBB on your desktop.

Protótipo de câmera de segurança baseada em Beaglebone Black

Fig. 1: Security camera prototype based on Beaglebone Black

First of all, update your kernel version. (Ignore if you have already done so).

Install OpenCV

Install opencv on BBB from the debian repository or official website. Here I installed from debian repository. Run the following commands at the command prompt:

sudo apt-get install python-opencv
sudo apt-get install libopencv-dev

Install dependencies

You need to install some dependencies like build, image, video, GUI etc. at BBB.

Step 1: Install the build dependency by performing the following instructions:

sudo apt-get install build-essential cmake

Step 2: Install the media I/O library by performing the following instructions:

sudo apt-get install zlib1g-dev libwebp-dev libpng-dev libjasper-dev libtiff5-dev libopenexr-dev libgdal-dev libjpeg-dev

Step 3: Install the GUI library by performing the following instructions:

sudo apt-get install qt5-default libvtk6-dev

Step 4: Install the video I/O library by performing the following instructions:

sudo apt-get install libavcodec-dev libavformat-dev libdc1394-22-dev libswscale-dev libtheora-dev libxvidcore-dev libx264-dev libvorbis-dev yasm libopencore-amrnb-dev libopencore-amrwb-dev libv4l-dev libxine2-dev – developer

Introduction to the program

Open command terminal and create a new file using touch command with .py extension (i.e. image.py). Open the file with any text editor (i.e. nano, vim etc.) and write code in python language.

Opencv is a great machine learning and computer science library written in C, C++, java and python. It supports excellent image and video processing functionality and works well on the embedded Linux platform. You need to read the image from the web cam device that is connected to the BBB. It will be zero if a single webcam is connected. So, just pass zero from the function as follows:

camera = cv2.VideoCapture(0)

Imagem da webcam conectada ao Beaglebone Black

Fig. 2: Image of the webcam connected to the Beaglebone Black

I created a frame size of 1280 x 720 which works well with BBB. You can adjust the frame size as you like, compatible with the library. Set the image frame size through the following functions:

cam.set (cv2.cv.CV_CAP_PROP_FRAME_WIDTH, 1280)
cam.set (cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, 720)

Now, capture the image from the device (i.e. web cam) by following the function:

cam.read()

Provide a delay of at least 10 ms after image capture by following the function:

cv2.waitKey(10)

If you want to show the image on the screen, perform the following function:

cv2.imshow (“Test Image”, img)

Save the image file with a specific name by following the function:

cv2.imwrite (“demopic.bmp”, img)

Circuit diagrams

Circuit-Diagram-Beaglebone-Black-Security-Camera

Conteúdo Relacionado

What is the role of automotive sensors in modern vehicles?
A network of sensors is embedded in every vehicle,...
How to choose an e-bike controller
The motor controller is one of the most important...
How to Troubleshoot Common ESP32-CAM Problems
ESP32-CAM is a compact camera module that combines the...
A guide to USB standards from 1.0 to USB4
A evolução dos padrões USB foi fundamental para moldar...
Schurter aprimora série de seletores de tensão com revestimento prateado
A SCHURTER anuncia um aprimoramento para sua conhecida série...
A interface serial PCI fornece conectividade confiável em ambientes extremos
A Sealevel Systems anuncia o lançamento da Interface Serial...
STMicroelectronics expande portfólio de conversão de energia com diodos Trench Schottky de 100 V
A STMicroelectronics introduziu Diodos retificadores Schottky de trincheira de...
O que são Sistemas Globais de Navegação por Satélite (GNSS) e como são usados?
Determinar uma localização precisa é necessário em várias indústrias...
O conversor GaN de 50 W da STMicroelectronics permite projetos de energia de alta eficiência
O novo VIPerGaN50 da STMicroelectronics simplifica a construção de...
Samsung e Red Hat farão parceria em software de memória de próxima geração
A Samsung Electronics, fornecedora de tecnologia de memória avançada,...
Primeiro MPU single-core com interface de câmera MIPI CSI-2 e áudio
O mercado embarcado tem uma necessidade de soluções de...
Understanding Support Insulators in Electrical Systems
You probably have a support insulator if you've noticed...
Explore Stay Insulator – safety, installation and maintenance
You've probably seen stand an insulator sit on power...
More safety and efficiency with the shackle isolator
You've probably seen shackle insulators enthroned on electricity poles,...
Discover the power of latching relays for energy efficiency and more
You have probably experienced situations where controlling a circuit...
Capacitando Tecnologia: Um Guia para Relés Eletromagnéticos
Você pode não pensar nisso com frequência, mas relés...
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.