Visual Object Detection With a Camera (TfCD)

by Yoon Lee in Circuits > Raspberry Pi

5344 Views, 49 Favorites, 0 Comments

Visual Object Detection With a Camera (TfCD)

WhatsApp Image 2017-12-21 at 2.13.23 PM.jpeg

Cognitive services that can recognize emotions, faces of people or simple objects are currently still at an early stage of development, but with machine learning, this technology is increasingly developing. We can expect to see more of this magic in the future.

For a project of the TU Delft for TfCD, We decided to use the vision cognitive services provided by Microsoft to demonstrate how to perform a vision recognition analysis on photos. (See the video).

NOTE!!!

The electronics and code work properly, but the internet connection at the TU Delft was off so we do not have a proper video. We will upload a proper one later! Thank you for understanding!

Get Your API Key

캡처1.PNG

First, go to the Azure cognitive services site and obtain the Computer Vision API key from the Microsoft site. The link is down below:
https://azure.microsoft.com/nl-nl/services/cogniti...

EXTRA: If you want to try out the API to have a bit of fun, get the key for Face Recognition and Emotion Recognition too. Download Visual Studios (the community version is fine) and also download the code from github to put in Visual Studios.

Visual Studios: https://www.visualstudio.com/thank-you-downloadin...

Github: https://www.visualstudio.com/thank-you-downloadin...

Gather Your Hardware

rbp.jpg

Get started with the Raspberry Pi Camera Module, using Python and picamera. You’ll take still pictures, record video, and apply image effects. To start with, you will need:

  • Raspberry Pi, Camera Board V2, 8MP
  • Raspberry Pi 3, Model B, 1GB RAM for coding
  • Adafruit 16x2 Character LCD
  • Mouse to link to the Raspberry Pi
  • Keyboard to link to the Raspberry Pi
  • Monitor to link to the Raspberry Pi
  • Ethernet cable to link the Raspberry Pi to the web
  • Laptop for input
  • Soldering set to solder your LCD

Solder Your LCD Together

lcd.jpeg

Use the Adafruit site to solder your LCD properly. The link is down below:

https://learn.adafruit.com/adafruit-16x2-character...

Download NOOBS for Your Raspberry Pi

rbppp.jpg

Download Raspbian to get your Raspberry Pi running!

https://www.raspberrypi.org/downloads/noobs/

See your Raspberry Pi as a small computer. It needs a monitor, mouse, keyboard and internet. Connect these to your Raspberry Pi.

Getting Started With Picamera

The Camera Module is a great accessory for the Raspberry Pi, allowing users to take still pictures and record video in full HD. First of all, with the Pi switched off, you’ll need to connect the Camera Module to the Raspberry Pi’s camera port, then start up the Pi and ensure the software is enabled. Follow the images for the further steps!

​Locate the Camera Port and Connect the Camera

11.jpg

​Open the Raspberry Pi Configuration Tool From the Main Menu

12.png

​Ensure the Camera Software Is Enabled

13.png

Camera Preview

preview.jpg

Now your camera is connected and the software is enabled, you can get started by trying out the camera preview.

  • Open Python 3 from the main menu
  • Open a new file and save it as camera.py. It’s important that you do not save it as picamera.py.
  • Enter the following code:

  1. from picamera import PiCamera
  2. from time import sleep
  3. camera = PiCamera()
  4. camera.start_preview() sleep(10) camera.stop_preview()

  • Save with Ctrl + S and run with F5. The camera preview should be shown for 10 seconds, and then close. Move the camera around to preview what the camera sees.
  • The live camera preview should fill the screen

Still Pictures

photo.png

The most common use for the Camera Module is taking still pictures.

  • Amend your code to reduce the sleep and add a camera.capture() line:

camera.start_preview()

sleep(5)

camera.capture('/home/pi/Desktop/image.jpg')

camera.stop_preview()

  • Run the code and you’ll see the camera preview open for 5 seconds before capturing a still picture. You’ll see the preview adjust to a different resolution momentarily as the picture is taken.
  • You’ll see your photo on the Desktop. Double-click the file icon to open it.

Your Camera Is Working!

YES! Next step!

Take Your Assembled LCD Kit and Test

Enable the LCD by following the substeps:

Configuring the LCD

a. http://learn.adafruit.com/adafruits-raspberry-pi-l...

Installing the LCD and testing if your LCD is correctly soldered!

b. https://learn.adafruit.com/adafruit-16x2-character...

Get the Code to Install It on Your Selfmade Device

Get the code from github: https://github.com/cchannon/WhatIsThis

NOTE: The code does not seem to work well in the Tronny. Use the Terminal of Raspbian to start the code. Place the code (ComputerVision.py) in the map: home/pi/Adafruit_Python_CharLCD/examples (For some reason it only works this way, other methods will only give unexplainable errors)

Open your Terminal and type:

cd Adafruit_Python_CharLCD/examples

./ComputerVision.py

Take a Picture!

WhatsApp Image 2017-12-22 at 14.26.33.jpeg

Done!!

Vision Recognition Camera