collapse

Welcome!



Welcome to Robot Rebels, an online robot maker community.

Register today to post your projects, ask questions, share knowledge and meet like-minded people from around the world.


The RobotRebel.org Community

Recent Posts

Pages: [1] 2 3 ... 10
1
General Discussion / Re: Antique (fun) stuff
« Last post by MEgg on April 24, 2018, 01:48:57 PM »
[...]
 what is enough to help increase knowledge? personally I assume the reader knows nothing and give'em everything to make an informed decision... thinking you cant go far wrong  :) but above all have fun sharing it.

That is similar to my approach: do a "knowledge core dump"  .
;D
Although some people at work are overwhelmed afterwards and the result might be a  "I do not understand",
afterwards they need knowledge in tiny portions - an approach that I do not like as it is too much time consuming (1 Mio tiny
questions and 1 Mio tiny answers instead of one big core dump containing all the "vitamines and micronutrients").
 ;)
2
Walking / Re: Spider
« Last post by viswesh on April 21, 2018, 09:41:33 AM »
Nice one - creepy and crawly but thats exactly the way you wanted it I guess.
If I still had a cat I'd be tempted to make one jut to see its reaction!
........ You don't have access to a cat do you?  ;)

Thanks , no access to cats here. I don't do that for now, cat may damage my spider. LOL but i have access to a friends Dog. thanks for the idea sir
3
Walking / Re: Spider
« Last post by 1 what on April 20, 2018, 10:38:41 PM »
Nice one - creepy and crawly but thats exactly the way you wanted it I guess.
If I still had a cat I'd be tempted to make one jut to see its reaction!
........ You don't have access to a cat do you?  ;)
4
Raspberry / Google Vision API using Raspberry Pi and Node
« Last post by Ladvien on April 20, 2018, 02:38:12 PM »
Google Vision API using Raspberry Pi and Node

This is a jumpstart guide to connecting a Raspberry Pi Zero W to the Google Vision API.

1. Get an Account
Sadly, Google Vision API is not a completely free service.  At the time of writing an API account provides 1000 free Google Vision API calls a month.  Then, it's a $1.00 for each 1000 calls.

I know, I know, not too bad.  But this isn't a commercial project.  I'm wanting to use it for a puttering little house bot.  If my wife gets a bill for $40 because I decided to stream images to the API, well, it'll be a dead bot. Anyway, I thought I'd still explore the service for poo-and-giggles.

To get an account visit

* Google Console

And sign-in with an existing Google account or create one.

2. Enter Billing Information
Now, here's the scary part, you've must enter your billing information before getting going.  Remember, you will be charged if you go over 1000 calls.



Again, if you exceed your 1,000 free calls you will be charged. (What? I said that already? Oh.)

2. Enable Cloud Vision API
After setting up billing information we still need to enable the Cloud Vision API.  This is a security feature, essentially, all Google APIs are disabled by default so if someone accidentally gets access they don't unleash hell everywhere.




Now search for [code single]Vision[/code] and click the button.  Here there should be a glaring [code single]Enable[/code] button.  Press it.




The last thing we need to do is get the API key.  This needs to be included in the API call headers for authentication.

Do not let anyone get your API key. And do not hardcode it in your code.  Trust me, this will bite you.  If this accidentally gets pushed onto the web, a web crawler will find it quickly and you will be paying bajillions of dollars.

Let this article scare you a bit.

* Dev Puts AWS Keys on Github

Let's go get your API Key.  Find the [code single]Credentials[/code] section



You probably wont see any credentials created, as you've probably have not created any yet.

Let's create a new API Key.


I'd name the key something meaningful and limit it to only the Google Cloud API.



Go ahead and copy your API key, as we will need it in the next step.

3. Raspberry Pi Side Setup
The articles listed at the top of this one will help you setup the Raspberry Pi for this step.  But if you are doing things different, most of this should still work for you.  However, when we get to the part of about environment variables, that'll be different for other Linux flavors.

Start by SSH'ing into your Pi.

And update all packages
Code: [Select]
sudo pacman -SyuWe're going to create an environment variable for the Google Cloud Vision API.  This is to avoid hardcoding your API key into the code further down.  _That will work_, but I highly recommend you stick with me and setup an environment variable manager to handle the API.

Switch to the root user by typing
Code: [Select]
suEnter your password.

The next thing we do is add your Google Vision API Key as an environment variable to the [code single]/etc/profile[/code] file, this should cause it to be intialized at boot.

Type, replacing [code single]YOUR_API_KEY[/code] with your actual API Key.
Code: [Select]
echo 'export GOOGLE_CLOUD_VISION_API_KEY=YOUR_API_KEY' >> /etc/profileNow reboot the Pi so that takes effect.

Code: [Select]
sudo rebootLog back in.  Let's check to make sure it's loading the API key.
Code: [Select]
echo $GOOGLE_CLOUD_VISION_API_KEYIf your API key is echoed back, you should be good to go.

4. Project Setup

Let's create a project directory.

Code: [Select]
mkdir google-vis
cd google-vis
Now let's initialize a new Node project.
Code: [Select]
npm initFeel free to customize the package details if you like.  If you're lazy like me, hit enter until you are back to the command prompt.

Let's add the needed Node libraries.  It's one.  The axios library, which enables async web requests.

Code: [Select]
npm axios
Also, let's create a resource directory and download our lovely test image.  Ah, miss Hepburn!

Make sure you are in the [code single]google-vis/resources[/code] project directory when downloading the image.
Code: [Select]
mkdir resources
cd resources
wget https://ladvien.com/images/hepburn.png

5. NodeJS Code

Create a file in the [code single]go-vis[/code] directory called [code single]app.js[/code]

Code: [Select]
nano app.jsThen paste in the code below and save the file by typing CTRL+O and exiting using CTRL+X.

Code: [Select]
// https://console.cloud.google.com/
const axios = require('axios');
const fs = require('fs');

const API_KEY = process.env.GOOGLE_CLOUD_VISION_API_KEY

if (!API_KEY) {
  console.log('No API key provided')
}

function base64_encode(file) {
    // read binary data
    var bitmap = fs.readFileSync(file);
    // convert binary data to base64 encoded string
    return new Buffer(bitmap).toString('base64');
}
var base64str = base64_encode('./resources/audrey.jpg');

const apiCall = `https://vision.googleapis.com/v1/images:annotate?key=${API_KEY}`;

const reqObj = {
    requests:[
        {
          "image":{
            "content": base64str
          },
          "features":[
                {
                    "type":"LABEL_DETECTION",
                    "maxResults":5
                },
                {
                    "type":"FACE_DETECTION",
                    "maxResults":5           
                },
                {
                    "type": "IMAGE_PROPERTIES",
                    "maxResults":5
                }
            ]
        }
      ]
}

axios.post(apiCall, reqObj).then((response) => {
    console.log(response);
    console.log(JSON.stringify(response.data.responses, undefined, 4));
}).catch((e) => {
    console.log(e.response);
});

This code grabs the API key environment variable and creates a program constant from it.

Code: [Select]
const API_KEY = process.env.GOOGLE_CLOUD_VISION_API_KEYThis is how we avoid hardcoding the API key.

6. Run
Let's run the program.

Code: [Select]
node app.jsIf all went well you should get similar output to below

Code: [Select]
data: { responses: [ [Object] ] } }
[
    {
        "labelAnnotations": [
            {
                "mid": "/m/03q69",
                "description": "hair",
                "score": 0.9775374,
                "topicality": 0.9775374
            },
            {
                "mid": "/m/027n3_",
                "description": "eyebrow",
                "score": 0.90340185,
                "topicality": 0.90340185
            },
            {
                "mid": "/m/01ntw3",
                "description": "human hair color",
                "score": 0.8986981,
                "topicality": 0.8986981
            },
            {
                "mid": "/m/0ds4x",
                "description": "hairstyle",
                "score": 0.8985265,
                "topicality": 0.8985265
            },
            {
                "mid": "/m/01f43",
                "description": "beauty",
                "score": 0.87356544,
                "topicality": 0.87356544
            }
        ],
  ....
]

7. And so much more...
This article is short--a jump start.  However, there is lots of potential here.  For example, sending your own images using the Raspberry Pi Camera

raspicam
pi-camera

Please feel free to ask any questions regarding how to use the output.

There are other feature detection requests.

Google Vision API -- Other Features

However, I'm going to end the article and move on to rolling my on vision detection systems.  As soon as I figure out stochastic gradient descent.
5
Walking / Re: Spider
« Last post by viswesh on April 20, 2018, 01:26:35 PM »
thank you sir
6
Introductions / Re: Hello from HITBOT - a young robot arm team
« Last post by tinhead on April 20, 2018, 11:32:57 AM »
Hi,

Where are you guys from?

-TH
7
General Discussion / Re: Antique (fun) stuff
« Last post by Ladvien on April 20, 2018, 06:58:52 AM »
It loos like someone using Yahoo Translate.
8
3D Printing / Re: MKS Gen L 1.0
« Last post by grayknight235 on April 20, 2018, 06:55:50 AM »
hi,
 
Quote
Lots of "echo: Unknown command: " followed by garbage when Repetier tries to connect.
you got matching baudrate between repetier and the board?

then just a thought: disconnect the controller while using repetier,  sure they share the same IO lines as the USB connection  (could be something going odd there!) suggest you update the controller as well to use win8 tiles, it much more complete than the other red and blue styles.

I thought the baud rates were the same. I've got Marlin set at 112500 and Repetier also set at 112500.

I'll check the connection this weekend. Got too much else going on today to do it. And I'll update the controller to the win8 tiles as you suggest.
9
General Discussion / Re: Antique (fun) stuff
« Last post by jinx on April 20, 2018, 04:25:26 AM »
hi,
 Welcome to RR
Quote
For information related to this site, what is enough to help increase knowledge?
I gotta say I really don't fully understand your comment with reference to MEgg posting, but you find we rebels will and can kick an idea around if it takes our interest and generally it starts with a link..

 what is enough to help increase knowledge? personally I assume the reader knows nothing and give'em everything to make an informed decision... thinking you cant go far wrong  :) but above all have fun sharing it.
10
3D Printing / Re: MKS Gen L 1.0
« Last post by jinx on April 20, 2018, 02:13:52 AM »
hi,
 
Quote
Lots of "echo: Unknown command: " followed by garbage when Repetier tries to connect.
you got matching baudrate between repetier and the board?

then just a thought: disconnect the controller while using repetier,  sure they share the same IO lines as the USB connection  (could be something going odd there!) suggest you update the controller as well to use win8 tiles, it much more complete than the other red and blue styles.
Pages: [1] 2 3 ... 10

* Search


* Recent Topics

Antique (fun) stuff by MEgg
[April 24, 2018, 01:48:57 PM]


Spider by viswesh
[April 21, 2018, 09:41:33 AM]


Google Vision API using Raspberry Pi and Node by Ladvien
[April 20, 2018, 02:38:12 PM]


Hello from HITBOT - a young robot arm team by tinhead
[April 20, 2018, 11:32:57 AM]


MKS Gen L 1.0 by grayknight235
[April 20, 2018, 06:55:50 AM]


1B1 -- RAN Stack by Ladvien
[April 14, 2018, 10:40:54 AM]


Editing Raspberry Pi Code Remotely from Visual Studio Code by Ladvien
[April 14, 2018, 05:09:09 AM]


Post your last purchase. by Impala
[April 08, 2018, 12:54:11 PM]


Supercon by BaldwinK
[April 04, 2018, 09:57:55 AM]


Hex VI formally know as XCR3D v6 by jinx
[April 04, 2018, 07:10:51 AM]


Upload Arduino or AVR Programs to ATtiny84/85 Over UART by Ladvien
[April 02, 2018, 09:39:21 AM]


Are separate metric drill bit sizes sold in the US? by fabry
[April 01, 2018, 09:58:34 AM]


I2C Setup for Raspberry Pi Zero W with Arch Linux by Ladvien
[March 30, 2018, 09:35:16 PM]


Headless Arch Linux on Raspberry Pi Zero W by Ladvien
[March 30, 2018, 09:28:37 PM]


Sbase and the reprap full graphics smart controller by jinx
[March 30, 2018, 11:03:45 AM]

* Recent Posts

Re: Antique (fun) stuff by MEgg
[April 24, 2018, 01:48:57 PM]


Re: Spider by viswesh
[April 21, 2018, 09:41:33 AM]


Re: Spider by 1 what
[April 20, 2018, 10:38:41 PM]


Google Vision API using Raspberry Pi and Node by Ladvien
[April 20, 2018, 02:38:12 PM]


Re: Spider by viswesh
[April 20, 2018, 01:26:35 PM]


Re: Hello from HITBOT - a young robot arm team by tinhead
[April 20, 2018, 11:32:57 AM]


Re: Antique (fun) stuff by Ladvien
[April 20, 2018, 06:58:52 AM]


Re: MKS Gen L 1.0 by grayknight235
[April 20, 2018, 06:55:50 AM]


Re: Antique (fun) stuff by jinx
[April 20, 2018, 04:25:26 AM]


Re: MKS Gen L 1.0 by jinx
[April 20, 2018, 02:13:52 AM]


Re: MKS Gen L 1.0 by grayknight235
[April 19, 2018, 08:03:25 PM]


Re: Antique (fun) stuff by Catalinaz
[April 19, 2018, 01:04:15 AM]


Re: Hello from HITBOT - a young robot arm team by Catalinaz
[April 19, 2018, 01:01:55 AM]


Re: Spider by erco
[April 17, 2018, 01:24:55 PM]


Re: MKS Gen L 1.0 by MEgg
[April 15, 2018, 07:47:32 AM]