『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 253826|回复: 696

[进阶教程] 免费的本地图像识别系统(人体、物体)并接入HA

  [复制链接]

59

主题

731

帖子

4221

积分

论坛元老

Rank: 8Rank: 8

积分
4221
金钱
3485
HASS币
20
发表于 2021-2-3 09:25:26 | 显示全部楼层 |阅读模式
本帖最后由 guitengyue 于 2022-11-24 00:10 编辑

受坛友指引,发现了deepstack这个本地的图像识别系统,于是倒腾了一下子,感觉还是可以玩一下的;第一,系统是永久免费;第二,所有的数据都是本地的,识别速度也还可以,基本在0.1s-2s之内,不过对docker的宿主cpu有点要求第一步: 部署deepstack
我是在黑群晖docker中安装的,cpu是x86架构的,选deepquestai/deepstack :CPU-x6-beta
容器端口5000,改为本地端口84,环境中添加:VISION-DETECTION = True
访问   http://宿主ip:84 出现如下说明deepstack部署成功
1.png

第二部: 部署AI系统

下载node-deepstackai-trigger,选择latest
新建文件夹:node-deepstackai,在该文件夹内新建:aiinput,config,node-deepstackai-trigger; 在node-deepstackai-trigger中新建annotations,originals,snapshots 三个文件夹
如下图所示:
2.png 3.png

在config中新建settings.json和triggers.json
settings.json内容如下:
{
  // Leave this line alone. It enables Intellisense when editing this file in Visual Studio Code.
  "$schema": "https://raw.githubusercontent.com/danecreekphotography/node-deepstackai-trigger/main/src/schemas/settings.schema.json",

  // This is the default uri for Deepstack when deploying using the docker-compose.yaml file
  // provided in this sampleConfiguration folder. If you have another deployment of Deepstack
  // running elsewhere change this setting to point to the correction location.
  "deepstackUri": "http://宿主ip:84/",

  // Set this to true to enable annotated images for use in trigger handlers.
  // There is a performance penalty to using this, leave it off unless
  // you really want to see the annotated images.
  "enableAnnotations": false,

  // Set this to true to enable the internal web server for remote access
  // to processed and annotated images.
  "enableWebServer": false,

  // Enables verbose logging. Useful when setting up the system to ensure
  // everything is running correctly.
  "verbose": true,

  // Set this to true if your images are stored in a remote folder that's
  // mounted as a network share and then mapped to the Docker image.
  "awaitWriteFinish": false,

  // Provides the configuration details for your MQTT server. To enable
  // mqtt set the uri, username (if required), password (if required),
  // and set enabled to true.
  "mqtt": {
    "uri": "mqtt://mqtt-ip:1883",
    "username": "mqtt",
    "password": "mqtt",
    "enabled": true
  },

  // Provides the configuration details for Telegram bot messages.
  // Set the botToken and enabled to true to use Telegram.
  "telegram": {
    "botToken": "insert bot token here",
    "enabled": false
  },

  // Provides the configuration details for Pushbullet notifications.
  // Set the accessToken and enabled to true to use Pushbullet.
  "pushbullet": {
    "accessToken": "",
    "enabled": false
  },

  // Provides the configuration details for Pushover notifications.
  // Set the apiKey, userKey, and enabled to true to use Pushover.
  "pushover": {
    "apiKey": "api key here",
    "userKey": "user key here",
    "enabled": false
  }
}

在triggers.json内容如下:
{
  "$schema": "https://raw.githubusercontent.com/danecreekphotography/node-deepstackai-trigger/main/src/schemas/triggerConfiguration.schema.json",
  "triggers": [
        {
      "name": "car detector",
      "watchPattern": "/aiinput/*.jpeg",
      "enabled": true,
      "threshold": {
        "minimum": 10,
        "maximum": 90
      },
      "handlers": {
        "mqtt": {
          "messages": [{ "topic": "aimotion/triggers/car" }]
        }
      },
      "watchObjects": ["car"]
    }
    
  

  ]
}
第三部: HA配置
binary_sensor:
  - platform: mqtt
    device_class: motion
    name: "Front door motion"
    state_topic: "aimotion/triggers/car"
    payload_on: "on"
    payload_off: "off"
    value_template: "{{value_json.state}}"
    json_attributes_topic: "aimotion/triggers/car"


第四部: 将摄像头快照放入aiinput文件夹中
我才用的方式是群晖的surveillance动作检测后拍下快照(操作规则中添加),并放入该文件夹中



最终效果:
游客,如果您要查看本帖隐藏内容请回复

评分

参与人数 13金钱 +110 HASS币 +20 收起 理由
器大活好人还帅 + 1 感谢楼主分享!
HA.怿 + 5
zelotoj + 8 高手,这是高手!
menlsux + 1
EDAD + 2 <font style="vertical-align: inh
diba.qiu + 8
l24195656 + 8 感谢楼主分享!
924215947 + 10
893399065 + 20 论坛有你更精彩!
neoyang + 5
lidicn + 20 论坛有你更精彩!
+ 20 + 20 厉害了word楼主!
firberhome + 2 使用K210芯片的设备应该是更好方案,毕竟K2.

查看全部评分

回复

使用道具 举报

0

主题

38

帖子

428

积分

中级会员

Rank: 3Rank: 3

积分
428
金钱
390
HASS币
0
发表于 2021-2-3 09:35:46 | 显示全部楼层
神奇厉害,崇拜大神
回复

使用道具 举报

0

主题

14

帖子

182

积分

注册会员

Rank: 2

积分
182
金钱
168
HASS币
0
发表于 2021-2-3 09:35:46 | 显示全部楼层
厉害啊,学习一下
回复

使用道具 举报

2

主题

163

帖子

2634

积分

金牌会员

Rank: 6Rank: 6

积分
2634
金钱
2471
HASS币
0
发表于 2021-2-3 09:37:45 | 显示全部楼层
厉害,试试。
回复

使用道具 举报

0

主题

168

帖子

4577

积分

论坛元老

Rank: 8Rank: 8

积分
4577
金钱
4409
HASS币
0
发表于 2021-2-3 09:59:38 来自手机 | 显示全部楼层
崇拜大神
回复

使用道具 举报

5

主题

72

帖子

1505

积分

金牌会员

Rank: 6Rank: 6

积分
1505
金钱
1433
HASS币
0
发表于 2021-2-3 10:05:17 | 显示全部楼层
学习学习
回复

使用道具 举报

0

主题

25

帖子

1834

积分

金牌会员

Rank: 6Rank: 6

积分
1834
金钱
1809
HASS币
0
发表于 2021-2-3 10:09:07 | 显示全部楼层
学习学习
回复

使用道具 举报

8

主题

863

帖子

5126

积分

论坛元老

Rank: 8Rank: 8

积分
5126
金钱
4263
HASS币
0
发表于 2021-2-3 10:13:21 | 显示全部楼层
谢谢分享,学习
回复

使用道具 举报

5

主题

265

帖子

1899

积分

金牌会员

Rank: 6Rank: 6

积分
1899
金钱
1634
HASS币
0
发表于 2021-2-3 10:15:54 | 显示全部楼层
这个很厉害啊。不错。
回复

使用道具 举报

9

主题

358

帖子

3037

积分

论坛元老

Rank: 8Rank: 8

积分
3037
金钱
2679
HASS币
0
发表于 2021-2-3 10:17:10 | 显示全部楼层
感謝分享  趕快來學習一下
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-4-27 12:55 , Processed in 0.203481 second(s), 35 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表