Unit 3: Computer Vision 2

Objective

This unit will tell you the basic concept of computer vision.  Computer vision is an important source of input for AI application.  Knowing it will allow you to do a lot of AI experiment easily and interestingly.

With the knowledge of computer vision, we will conduct 2 simple AI activities. 

Teaching (Basic Concept of Computer Vision)

(Revision)

Computer vision enables computers and systems to derive meaningful information from digital images  — and take actions based on that information. If AI enables computers to think, computer vision enables them to see.

The following shows how a computer machine read digital images.  the setting is in gray scale (black and white).  It divides the image into zones.  How many zones are there in the below set up?

In AlphAI, we call the zones "pixels".  You can customize the camera into different resolution 2 x 1, 4 x 3, 8 x 6, etc.  The camera above is set to 4 x 3 pixels.

Note that these pixel inputs will become input to the neural network for further processing.

We have explained the basic concept of computer vision.  What computer machine sees is a digital image captured by the camera which is divided into pixels (or zones).  The below image has 16 pixels (or zones).  It is captured by the AlphAI camera with 4 x 3 pixels.

In the pixel boxes, there are numbers - 249, 156 and 248 in column 1.

These numbers represents the intensity of light captured in the pixels.  The numbers are ranged from 0 to 255.

The bigger the number is, the pixel is more bright.  For example, 249 and 250 are bright.

The smaller the number is, the pixel is more dark (black).  For example, 156 and 90 are dark.

** Note that these numbers ranged from 0 to 255 are usually converted to a range 0 to 1.00 for the further processing by the machine.

====

These pixels can be reformatted as below.  It can be viewed in 4 vertical columns A, B, C, and D.

If these 4 columns are arranged in one vertical line, like the one on the right hand side, this becomes the input neurons which are inputted into the AI neural network for processing.

Activity 1 - train the robot to recognize binary numbers

Material:

We use 8 cards (10 cm x 10 cm) to represent the binary numbers 1 to 8.  Each card divides into 4 equal-size vertical columns.  A black column represents a "1" and a white column represents a "0".

Column 1 - Binary Number
Column 2 - decimal
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8

AI Setting

Sensors

  • camera 4 x 3 pixels, gray scale

Actions

  • 8 outputs
  • 2 x forward turn, 2 x slight turn, 2 x turn in place, 2 x backward turn

A.I.

  • Learning method - supervised learning
  • Algorithm - neural network
  • Hidden Layer - none

Visualization

  • Animation
  • Connection activity

 

Labeled Outputs

Start the experiment

Switch on and connect the robot to your PC.

With the AI parameters set up correctly, the following will be shown.

Training

- click the <reset learning> button once

- click the <learning> button

- put the card "0001" on the stand.  Look at the camera on the computer screen.  If it is detected correctly, click the output according to the label chart (right forward turn).

- put the card "0010" on the stand.  Look at the camera on the computer screen.  If it is detected correctly, click the output according to the label chart (right turn in place).

- repeat the above training for all cards.

Testing

- Off the <learning> button.

- Click the <self drive> button.   The robot will use the learned intelligence to recognize the card.

- test with the 8 cards.

- Are the result correct?

- if result is not 100% correct, you may need to re-train some of the cards.

 

Record the result of each card on the Worksheet

First one (for "0001") has been done for you.

Discussion

How many input pixels are there?

How could the input pixels help to recognize the binary numbers?

 

Ideas for Extended Activities

Can AlphAI be trained to recognize the photos of dogs and cats?  

  • Is a large number of pixels required?  
  • Is 3-color required?