Visual Object Detection With a Camera (TfCD)

1,850

34

0

Published

Introduction: Visual Object Detection With a Camera (TfCD)

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!

Step 1: Get Your API Key

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...

Step 2: Gather Your Hardware

    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

    Step 3: Solder Your LCD Together

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

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

    Step 4: Download NOOBS for Your Raspberry Pi

    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.

    Step 5: 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!

    Step 6: ​Locate the Camera Port and Connect the Camera

    Step 7: ​Open the Raspberry Pi Configuration Tool From the Main Menu

    Step 8: ​Ensure the Camera Software Is Enabled

    Step 9: Camera Preview

    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

    Step 10: Still Pictures

    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.

    Step 11: Your Camera Is Working!

    YES! Next step!

    Step 12: 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...

    Step 13: 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

    Step 14: Take a Picture!

    Step 15: Done!!

    Share

      Recommendations

      • Water Contest

        Water Contest
      • Clocks Contest

        Clocks Contest
      • Creative Misuse Contest

        Creative Misuse Contest

      Discussions