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

 找回密码
 立即注册
查看: 1728|回复: 23

[技术探讨] Esp-32cam 【含流代码】图像识别接入燃气数据 百度数字识别

[复制链接]

43

主题

407

帖子

3631

积分

元老级技术达人

积分
3631
金钱
3219
HASS币
136
发表于 2023-12-31 16:14:10 | 显示全部楼层 |阅读模式
本帖最后由 hunterfox 于 2024-1-9 20:07 编辑

今天利用一个闲置摄像头完成了家庭燃气表数据的采集接入。  比较有意思,可以探讨一下基本流程就是:  拍照------上传------识别------数据验证------MQTT传输------完结撒花
百度申请了测试ID.
微信图片_20231231114633.png
微信图片_20231231114716.png
用NodeRed 接入调试了一下   

1704010335810.jpg
微信图片_20231231150335.png
制作了一个小视频
9a3aa627b76149b2ec58843a94fea1f2.mp4 (7.03 MB, 下载次数: 96)


                               
登录/注册后可看大图


[
    {
        "id": "ca748038f2e9d7e7",
        "type": "inject",
        "z": "e4d14b7b7c8cb544",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "*/10 16-22 * * *",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 120,
        "y": 980,
        "wires": [
            [
                "acf31b7fb59fe97f"
            ]
        ]
    },
    {
        "id": "acf31b7fb59fe97f",
        "type": "api-call-service",
        "z": "e4d14b7b7c8cb544",
        "name": "",
        "server": "43f262e223290729",
        "version": 5,
        "debugenabled": false,
        "domain": "light",
        "service": "turn_on",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "light.044_esp32_cam_light"
        ],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 270,
        "y": 1020,
        "wires": [
            [
                "5ff49914493234d2"
            ]
        ]
    },
    {
        "id": "979b5f4c33caf08f",
        "type": "inject",
        "z": "e4d14b7b7c8cb544",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "*/10 5-12 * * *",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 120,
        "y": 1020,
        "wires": [
            [
                "acf31b7fb59fe97f"
            ]
        ]
    },
    {
        "id": "5ff49914493234d2",
        "type": "delay",
        "z": "e4d14b7b7c8cb544",
        "name": "",
        "pauseType": "delay",
        "timeout": "10",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 420,
        "y": 1020,
        "wires": [
            [
                "1d9d3814d8779b96"
            ]
        ]
    },
    {
        "id": "1d9d3814d8779b96",
        "type": "function",
        "z": "e4d14b7b7c8cb544",
        "name": "",
        "func": "\nvar now = new Date();\nvar strtimestamp=Date.parse(new Date())/1000;\n\nvar cameraid="123123"\nmsg.payload = {\n        "data": {\n            "filename":"/config/www/camera/"+cameraid+".jpg",\n            "entity_id":cameraid\n                }\n        }\n        \nreturn msg;\n\n",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 550,
        "y": 1020,
        "wires": [
            [
                "9907525ec25e1d69"
            ]
        ]
    },
    {
        "id": "9907525ec25e1d69",
        "type": "api-call-service",
        "z": "e4d14b7b7c8cb544",
        "name": "摄像头本地截图",
        "server": "43f262e223290729",
        "version": 5,
        "debugenabled": false,
        "domain": "camera",
        "service": "snapshot",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "camera.cam_2"
        ],
        "data": "",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 700,
        "y": 1020,
        "wires": [
            [
                "19db7adb9ff0d406"
            ]
        ]
    },
    {
        "id": "19db7adb9ff0d406",
        "type": "function",
        "z": "e4d14b7b7c8cb544",
        "name": "",
        "func": "\nvar picname="123123"\nvar msg1= {};\nmsg1.payload=msg.payload\nreturn msg1;\n",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 850,
        "y": 1020,
        "wires": [
            [
                "6f451de21e173967"
            ]
        ]
    },
    {
        "id": "6f451de21e173967",
        "type": "http request",
        "z": "e4d14b7b7c8cb544",
        "name": "获得图片地址",
        "method": "GET",
        "ret": "bin",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 140,
        "y": 1080,
        "wires": [
            [
                "5247a4a161725962",
                "c2712c1afc40724a"
            ]
        ]
    },
    {
        "id": "5247a4a161725962",
        "type": "image",
        "z": "e4d14b7b7c8cb544",
        "name": "",
        "width": "600",
        "data": "payload",
        "dataType": "msg",
        "thumbnail": false,
        "active": false,
        "pass": false,
        "outputs": 0,
        "x": 140,
        "y": 1120,
        "wires": []
    },
    {
        "id": "c2712c1afc40724a",
        "type": "base64",
        "z": "e4d14b7b7c8cb544",
        "name": "获取图片",
        "action": "",
        "property": "payload",
        "x": 360,
        "y": 1100,
        "wires": [
            [
                "f9be3cc58037aa23"
            ]
        ]
    },
    {
        "id": "f9be3cc58037aa23",
        "type": "change",
        "z": "e4d14b7b7c8cb544",
        "name": "修改",
        "rules": [
            {
                "t": "set",
                "p": "image",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 510,
        "y": 1100,
        "wires": [
            [
                "1d7755af6e6141db"
            ]
        ]
    },
    {
        "id": "1d7755af6e6141db",
        "type": "function",
        "z": "e4d14b7b7c8cb544",
        "name": "图像识别",
        "func": "var key=flow.get('looknumber')\n\nvar newMsg = {\n    "headers": {\n        "Content-Type" : "application/x-www-form-urlencoded"\n    },\n    "payload": {\n        "access_token": key,\n        "image": msg.image\n    }\n}\nreturn newMsg",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 640,
        "y": 1100,
        "wires": [
            [
                "68d3faf42e7aa4ca",
                "79b6dbb63bbcb73b"
            ]
        ]
    },
    {
        "id": "68d3faf42e7aa4ca",
        "type": "http request",
        "z": "e4d14b7b7c8cb544",
        "name": "API",
        "method": "POST",
        "ret": "obj",
        "paytoqs": "query",
        "url": "https://aip.baidubce.com/rest/2.0/ocr/v1/numbers",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 770,
        "y": 1100,
        "wires": [
            [
                "c3db3fc1ca6d7fb5",
                "c954081ef4ead63e"
            ]
        ]
    },
    {
        "id": "79b6dbb63bbcb73b",
        "type": "api-call-service",
        "z": "e4d14b7b7c8cb544",
        "name": "",
        "server": "43f262e223290729",
        "version": 5,
        "debugenabled": false,
        "domain": "light",
        "service": "turn_off",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "light.044_esp32_cam_light"
        ],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 750,
        "y": 1160,
        "wires": [
            []
        ]
    },
    {
        "id": "c3db3fc1ca6d7fb5",
        "type": "function",
        "z": "e4d14b7b7c8cb544",
        "name": "识别结果",
        "func": "\nvar msg1={};\nvar laststate=global.get('homeassistant').homeAssistant_synology.states["sensor.gas_reading"].state;\nif(msg.statusCode==200) \n{\n var getstring= msg.payload.words_result[0].words\n var datelength=getstring.substring(0, 6).length\n  var result = Number(getstring.substring(0, 6))/10;  \n  node.status({text: '识别成功:'+JSON.stringify(result), fill: 'green'})\n\n \n \n //var flag=result.substring(0, 2); \n var charge=result-laststate;\n if (datelength==6 && charge>=0 && charge<20 )\n {\n    msg1.payload=result\n    msg1.topic="sensor/gas_reading/sta/state"\n    return msg1;\n }  \n}\nelse{\n  node.status({text: '登录失败:'+ msg.payload.error_description, fill: 'red'})\n}\n\n",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 900,
        "y": 1100,
        "wires": [
            [
                "a49cc7e77f82d24a",
                "d0ff985002e6b574"
            ]
        ]
    },
    {
        "id": "c954081ef4ead63e",
        "type": "debug",
        "z": "e4d14b7b7c8cb544",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 890,
        "y": 1160,
        "wires": []
    },
    {
        "id": "a49cc7e77f82d24a",
        "type": "debug",
        "z": "e4d14b7b7c8cb544",
        "name": "debug 19",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 960,
        "y": 1260,
        "wires": []
    },
    {
        "id": "d0ff985002e6b574",
        "type": "mqtt out",
        "z": "e4d14b7b7c8cb544",
        "name": "",
        "topic": "",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "f979baf50ef69816",
        "x": 1010,
        "y": 1040,
        "wires": []
    },
    {
        "id": "43f262e223290729",
        "type": "server",
        "name": "Home Assistant_synology",
        "version": 5,
        "addon": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": "30",
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": "at: ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "h23",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": true
    },
    {
        "id": "f979baf50ef69816",
        "type": "mqtt-broker",
        "name": "MQTT_188",
        "broker": "192.168.1.188",
        "port": "1883",
        "clientid": "NodeRed",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    }
]




评分

参与人数 3金钱 +19 收起 理由
sandra602 + 8 感谢楼主分享!
moonandsky + 1 感谢楼主分享!
firewater + 10 论坛有你更精彩!

查看全部评分

回复

使用道具 举报

109

主题

1586

帖子

5012

积分

元老级技术达人

积分
5012
金钱
3421
HASS币
30
发表于 2023-12-31 16:20:49 | 显示全部楼层
这种东西,放在燃气表旁边,不知道安全不,
回复

使用道具 举报

43

主题

407

帖子

3631

积分

元老级技术达人

积分
3631
金钱
3219
HASS币
136
 楼主| 发表于 2023-12-31 16:23:31 | 显示全部楼层
bugensui 发表于 2023-12-31 16:20
这种东西,放在燃气表旁边,不知道安全不,

适配器是放在水槽下面的。直接用跟数据线穿过来给ESP-32 cam 供的电
回复

使用道具 举报

0

主题

80

帖子

288

积分

中级会员

Rank: 3Rank: 3

积分
288
金钱
208
HASS币
0
发表于 2023-12-31 19:07:13 | 显示全部楼层
感谢分享。
回复

使用道具 举报

25

主题

224

帖子

1011

积分

金牌会员

007潜水了

Rank: 6Rank: 6

积分
1011
金钱
787
HASS币
0
发表于 2023-12-31 23:14:02 | 显示全部楼层
paddle ocr 本地化的识图可以试试
回复

使用道具 举报

6

主题

78

帖子

512

积分

高级会员

Rank: 4

积分
512
金钱
434
HASS币
0
发表于 2024-1-1 14:04:25 | 显示全部楼层
百度的东西不免费吧。。。
回复

使用道具 举报

6

主题

41

帖子

286

积分

中级会员

Rank: 3Rank: 3

积分
286
金钱
245
HASS币
0
发表于 2024-1-1 15:14:49 来自手机 | 显示全部楼层
家里空气能热水器放在最偏僻的阳台,总是要去看温度很不方便,这个思路很不错,大佬们还有其他思路吗
回复

使用道具 举报

43

主题

407

帖子

3631

积分

元老级技术达人

积分
3631
金钱
3219
HASS币
136
 楼主| 发表于 2024-1-2 08:32:20 | 显示全部楼层
hnjzjql 发表于 2024-1-1 14:04
百度的东西不免费吧。。。

图像数字识别是免费使用的。
回复

使用道具 举报

0

主题

55

帖子

335

积分

中级会员

Rank: 3Rank: 3

积分
335
金钱
280
HASS币
0
发表于 2024-1-2 09:04:02 | 显示全部楼层
node-red流程粘贴分享学习下
回复

使用道具 举报

2

主题

52

帖子

587

积分

高级会员

Rank: 4

积分
587
金钱
535
HASS币
0
发表于 2024-1-9 11:00:00 | 显示全部楼层
有点意思,提供了新思路
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-5-2 07:22 , Processed in 0.100307 second(s), 35 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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