博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
api cloud_如何使用Google Cloud Vision API和ClickSend在宠物上保持标签
阅读量:2532 次
发布时间:2019-05-11

本文共 5829 字,大约阅读时间需要 19 分钟。

api cloud

by Namratha Subramanya

由Namratha Subramanya

如何使用Google Cloud Vision API和ClickSend在宠物上保持标签 (How to use the Google Cloud Vision API and ClickSend to keep tabs on your pets)

Just like people, dogs are scared by all kinds of things. Most often, it’s a result of having a negative experience or not being handled when their natural fears surface. In this article, we’ll create a way to make sure your dog is safe when you are away.

就像人一样,狗被各种各样的事物吓到。 大多数情况下,这是因为他们的天生恐惧感使他们经历了消极的经历或没有得到处理。 在本文中,我们将创建一种方法来确保您的狗在外出时安全。

You can attach a camera to your dog’s collar that can capture images, and use Vision API to detect and recognize the images.

您可以将相机连接到可以捕获图像的狗项圈,并使用Vision API来检测和识别图像。

Let’s say your dog is scared of cats, and you want to make sure your little furry friend is safe from cats while playing in the backyard in your absence. You could build an application where you could get SMS alerts to your device when cats are recognized by Cloud Vision API.

假设您的狗害怕猫,并且您想确保在您不在的情况下在后院玩耍时,小毛茸茸的朋友可以安全地避开猫。 您可以构建一个应用程序,当Cloud Vision API识别出猫时,您可以在其中将SMS警报发送到设备。

In this tutorial, you’ll learn how to recognize an image using Google Cloud Vision API and alert the user with an SMS using ClickSend API. PubNub forms the skeleton of the application and interconnects the features.

在本教程中,您将学习如何使用Google Cloud Vision API识别图像,以及如何使用ClickSend API通过SMS提醒用户。 PubNub构成了应用程序的框架并互连了功能。

让我们开始建设 (Let’s Get Building)

Assume your laptop’s webcam is the camera fixed to your dog’s collar. Below is the code that opens your webcam and takes pictures for you. You could set a time interval to capture images frequently. These images go into a canvas element and can be saved on your device. You can find the code for clicking and saving the images below.

假设您的笔记本电脑的网络摄像头是固定在狗项圈上的摄像头。 以下是打开网络摄像头并为您拍照的代码。 您可以设置时间间隔以频繁捕获图像。 这些图像会进入canvas元素,并可以保存在您的设备上。 您可以在下面找到用于单击和保存图像的代码。

Cloud Vision API (Cloud Vision API)

The Google Cloud Vision API enables developers to understand the content of an image through its powerful machine learning models. To get started with implementing the Vision API, you need to create a new project . Before you create a new project, you need to set up your billing account. After this, you need to enable Vision API.

Google Cloud Vision API使开发人员能够通过其强大的机器学习模型来理解图像的内容。 要开始实施Vision API,您需要在创建一个新项目。 在创建新项目之前,您需要设置您的计费帐户。 之后,您需要启用Vision API。

For more details, check this quick start .

有关更多详细信息,请查看此快速入门 。

Run the following command in your terminal:

在终端中运行以下命令:

pip install --upgrade google-cloud-vision

To run the client library, you must first set up authentication by creating a service account and setting an environment variable.

要运行客户端库,必须首先通过创建服务帐户并设置环境变量设置身份验证。

  • From the Service account drop-down list, select the New service account.

    从“ 服务帐户”下拉列表中,选择“新服务帐户”

  • Enter a name into the Service account name field.

    服务帐户名称字段中输入名称

  • Do not select a value from the Role drop-down list. No role is required to access this service.

    不要从“ 角色”下拉列表中选择一个值。 访问该服务不需要任何角色。

  • Click Create. A note appears, warning that this service account has no role.

    点击创建 。 出现一条注释,警告该服务帐户没有作用。

  • Click Create without role. A JSON file that contains your key will download to your computer.

    单击创建无角色 。 包含密钥的JSON文件将下载到您的计算机。

Now set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the file path of the JSON file that contains your service account key. This can be done as follows:

现在,将环境变量GOOGLE_APPLICATION_CREDENTIALS设置为包含您的服务帐户密钥的JSON文件的文件路径。 可以按照以下步骤进行:

For Linux/Mac OS:

对于Linux / Mac OS:

export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"

For Windows:

对于Windows:

set GOOGLE_APPLICATION_CREDENTIALS=[PATH]

Now you are all ready to run the code that recognizes your images. Here’s the Python code that takes the snapshots from the directory where you have saved them (mine is Downloads) and responds with labels.

现在,您已经准备好运行可识别图像的代码。 这是Python代码,用于从保存快照的目录中获取快照(我的是Downloads),并使用标签进行响应。

The result of the image recognition is sent to the user using . You just need to subscribe your device to a channel, say, alert_notify to which Vision API’s sends the results of the image recognition.

图像识别的结果使用发送给用户。 您只需要为设备订阅频道即可,例如alert_notify哪个Vision API将图像识别结果发送给该频道。

使用PubNub的Web通知警报 (Web Notification Alert using PubNub)

You’ll now have to initialize your PubNub keys. and create a project in the .

现在,您必须初始化您的PubNub键。 并在创建一个项目。

Now you can publish the alert message inside your Python code which you can send as a web push notification to your device. The device, in turn, subscribes to alert_notify channel and receives the alert message from your camera.

现在,您可以在Python代码中发布警报消息,您可以将其作为Web推送通知发送到设备。 该设备依次订阅alert_notify频道并从您的摄像机接收警报消息。

You can design the web push notification using the in HTML5.

您可以使用HTML5中的设计Web推送通知。

ClickSend API (ClickSend API)

allows developers to integrate SMS, voice, fax, posts, or email into their applications. You could send an SMS to your mobile device along with web push notifications using PubNub. The ClickSend API is well-documented for developers.

,开发人员可以将SMS,语音,传真,帖子或电子邮件集成到他们的应用程序中。 您可以使用PubNub将SMS连同Web推送通知一起发送到移动设备。 ClickSend API为开发人员提供了完善的文档。

You can use ClickSend’s . Every time Vision API recognizes an image, you get an SMS to your device.

您可以使用ClickSend的 。 每次Vision API识别图像时,您都会向设备发送一条SMS。

恭喜! (Congrats!)

Now that you have set up Cloud Vision API and ClickSend API to communicate with each other through PubNub’s Publish-Subscribe, you will be able to receive web notifications and SMS alerts sent to your device every time your camera captures an image of a cat. Undoubtedly, this is a great starting point for building applications using different APIs and connecting them through PubNub.

现在,您已经设置了Cloud Vision API和ClickSend API,可以通过PubNub的Publish-Subscribe相互通信,每当您的相机拍摄到一只猫的图像时,您就可以接收发送到设备的Web通知和SMS警报。 毫无疑问,这是使用不同API构建应用程序并通过PubNub连接它们的一个很好的起点。

Originally published at .

最初在发布。

翻译自:

api cloud

转载地址:http://dnkzd.baihongyu.com/

你可能感兴趣的文章
【MM系列】在SAP里查看数据的方法
查看>>
C#——winform
查看>>
CSS3 transform制作的漂亮的滚动式导航
查看>>
《小强升职记——时间管理故事书》读书笔记
查看>>
Alpha 冲刺(3/10)
查看>>
Kaldi中的Chain模型
查看>>
spring中的ResourceBundleMessageSource使用和测试示例
查看>>
css规范 - bem
查看>>
电梯调度程序的UI设计
查看>>
转自 zera php中extends和implements的区别
查看>>
Array.of使用实例
查看>>
【Luogu】P2498拯救小云公主(spfa)
查看>>
如何获取网站icon
查看>>
几种排序写法
查看>>
java 多线程的应用场景
查看>>
dell support
查看>>
转:Maven项目编译后classes文件中没有dao的xml文件以及没有resources中的配置文件的问题解决...
查看>>
MTK android 设置里 "关于手机" 信息参数修改
查看>>
单变量微积分笔记6——线性近似和二阶近似
查看>>
补几天前的读书笔记
查看>>