Radio control car that recognizes words
Contents
Make things
Let’s make the radio control car that moves by recognizing words.
Materials
- obniz Board
- DC Motor x2
- Tires x2
- Smartphone
- Radio control car
How to make
Hardware Connection
Wire as shown in the table and figure below.
Note that the DC Motors orientation. It changes tire rotation direction.
obniz | DC Motor |
---|---|
0 | Left DC Motor OUT1 |
1 | Left DC Motor OUT2 |
10 | Right DC Motor OUT2 |
11 | Right DC Motor OUT1 |
Make the car body so that obniz and Battery can ride on.
Software
Get the api key of “Google Cloud Vision API”
This application uses Google Cloud Vision API. So you need your own API key.
Follow this official document and get the API key.
Use Google Cloud Vision API
By using Google Cloud Vision API, you can easily do image analysis with POST request.
It has many variation of analysis, but this time we use text detection API.
When you use this API, note that the image must be encoded in Base64 format.
var base64Img = BASE64_IMAGE; // get API key var apiKey = document.getElementById("google_api_key").value; var body = { "requests": [{ "image": { "content": base64Img }, "features": [ { "type": "LABEL_DETECTION" }, { "type": "TEXT_DETECTION", "maxResults": 1 } ] }] }; //request to google api fetch("https://vision.googleapis.com/v1/images:annotate?key=" + apiKey, { body: JSON.stringify(body), method: 'POST', headers: { 'Content-Type': 'application/json' } } ).then(function (response) { // process for the response })...
Correspondence between the word and the movement
Word | Movement |
---|---|
go | Go forward |
back | Go back |
stop | Stop |
right | Turn to the right |
left | Turn to the left |
here | Go to the position of the word |