add-beep-widget

This commit is contained in:
unknown
2025-05-15 18:31:13 +08:00
parent 2a92fa385b
commit 590941a7a1
8 changed files with 65 additions and 107 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
<svg t="1731897743046" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4299" width="200" height="200"><path d="M130.112 669.76v222.464h224.64V960H64v-290.24h66.112z m828.8 0V960h-293.056v-67.776h226.88v-222.464h66.112zM560.448 243.2l232.64 512h-103.424l-48-106.048H405.504L361.216 755.2H257.792l217.856-512h84.864z m-40.576 135.296L444.16 555.904h155.072l-79.36-177.408zM354.752 64v65.536h-224.64v288.704H64V64h290.752zM960 64v290.24h-66.112V129.536h-227.456V64H960z" fill="#4e73df" p-id="4300"></path></svg>
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1747302769143" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2770" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M756.46289902 153.75412286l17.5412294-59.82008995c-16.6416794-4.49775088-34.18290878 4.94752588-39.13043555 21.13943027-4.49775088 17.0914544 4.94752588 34.18290878 21.58920616 38.68065967zM288.69678125 115.52323818c-4.94752588-16.6416794-22.03898028-26.08695615-39.13043467-21.13943027l17.5412294 59.82008995c16.6416794-4.94752588 26.08695615-22.03898028 21.58920527-38.68065968z" fill="#4e73df" p-id="2771"></path><path d="M131.27549258 395.73313349c-27.43628203-107.94602724 41.82908555-215.44227862 135.8320834-241.97901063L249.56634658 94.38380791C122.72976494 129.9160417 34.12406797 270.24587685 70.10607676 410.57571201c4.04797588 16.6416794 21.13943028 26.98650703 38.23088467 22.93853115 16.6416794-4.04797588 26.98650703-20.68965528 22.93853115-37.78110967zM133.52436758 733.96401787zM893.19453242 738.01199375c-1.79910088-12.59370352-6.74662675-24.73763115-14.39280351-35.08245879l-86.8065961-123.23838076V400.23088438l-0.449775-3.14842589-31.03448291 6.29685177 31.03448291-6.29685177v-0.449775c-2.24887588-8.99550263-4.49775088-17.5412294-7.19640263-26.08695615-6.74662675-21.13943028-15.29235352-41.37931055-25.63718115-61.16941582-22.48875527-42.27886055-59.82008994-92.65367286-119.19040489-124.13793076C638.62181914 116.87256406 582.39993008 62 513.1345625 62c-69.26536758 0-125.48725664 54.87256406-125.93703164 123.23838076C327.37744092 216.72263867 290.49588213 267.09745097 268.00712685 309.37631153c-10.34482763 19.34033028-18.8905544 40.02998467-25.63718203 61.16941581-2.69865088 8.99550263-5.39730176 17.5412294-7.19640175 26.98650615l30.58470791 6.29685177-30.58470791-5.84707589-0.449775 1.349325v1.349325s4.04797588 0.449775 6.29685175 0.449775l-6.29685175-0.449775-18.4407794 179.46026983L142.96964521 706.97751084c-4.94752588 8.09595175-8.09595175 17.0914544-9.44527763 26.53673203l62.51874082 8.99550264c0.449775-1.79910088 1.349325-3.59820088 2.24887587-4.94752676l76.01199346-133.13343339 3.14842589-5.84707589 0.449775-6.29685176-31.48425792-3.14842587 31.48425792 3.14842587L296.34295888 408.32683701c0.449775-1.349325 0.449775-2.69865088 0.89955-4.04797675 0.89955-3.59820088 2.24887588-8.99550263 4.49775089-15.29235352 4.49775088-13.04347852 11.24437763-31.48425791 21.58920527-51.27436318C344.46889531 298.13193388 378.6518041 255.40329834 430.82571729 232.91454307l-12.59370352-28.33583203L430.82571729 232.91454307l18.89055438-8.09595264v-38.68065967c0-34.18290878 28.33583203-62.06896582 62.96851583-62.06896494s62.96851582 27.88605703 62.96851582 62.06896494v38.68065967l18.89055439 8.09595264 12.59370352-28.33583203c-6.29685176 14.39280352-12.59370352 28.33583203-12.59370352 28.33583203 52.62368818 22.48875527 86.35682198 65.2173917 107.49625225 104.79760048 10.34482763 19.79010527 17.5412294 37.78110967 21.58920527 51.27436319 1.79910088 5.84707675 3.59820088 11.69415263 4.94752676 17.99100439V599.48125948l5.39730088 8.09595175 26.08695703-17.5412294-26.08695703 17.5412294 92.20389786 130.88455752c1.79910088 1.79910088 2.69865088 4.04797588 3.14842587 6.74662676 1.349325 11.69415263-1.349325 19.79010527-4.49775087 24.28785615-2.24887588 3.59820088-6.29685176 6.29685176-14.84257852 6.29685176H214.93366279c-8.54572676 0-12.59370352-3.14842588-15.29235352-6.74662676-3.14842588-4.94752588-5.84707675-13.49325352-4.04797587-26.08695615l-62.51874082-8.99550264c-3.59820088 23.83808115 0 49.0254873 13.94302851 69.26536758 14.39280352 21.58920528 38.23088467 34.63268378 67.4662667 34.63268379h135.83208428c14.39280352 70.61469258 78.26086933 124.13793076 154.27286368 124.13793076s139.88006016-53.07346318 154.27286367-124.13793076h151.57421279c28.33583203 0 51.72413818-12.14392763 66.1169417-32.83358379 15.29235352-19.79010527 19.34033028-44.07796143 16.64167851-67.0164917z m-388.15592167 161.46926543a94.45277373 94.45277373 0 0 1-89.05547198-62.06896494h178.11094394c-13.04347852 35.98200878-48.12593731 62.06896582-89.05547196 62.06896494zM774.00412842 94.38380791l-17.54122939 59.82008994c94.00299873 26.53673203 163.26836543 134.0329834 135.83208339 241.97901064-4.04797588 16.6416794 6.74662675 33.28335791 23.38830615 37.33133467 16.6416794 3.59820088 33.28335791-5.84707675 37.78110968-22.03898115l-15.2923544-3.59820088 15.2923544 3.59820088c35.98200878-141.22938516-52.62368818-281.55922031-179.46026983-317.0914541z" fill="#4e73df" p-id="2772"></path></svg>

Before

Width:  |  Height:  |  Size: 552 B

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
img/alarm.mp3 Normal file

Binary file not shown.

BIN
img/strong.mp3 Normal file

Binary file not shown.

BIN
img/weak.mp3 Normal file

Binary file not shown.

View File

@@ -1,13 +1,14 @@
var JSLang = {
"zh": {
"beepAudio": "提示音类型",
"tensorAI": "- 人工智能 -",
"imageNet": "ImageNet 图像分类",
"cocoSSD": "CocoSSD 对象检测",
"deepLab": "DeepLab 图像分割",
"blazeFace": "人脸识别",
"mediaPipe": "手势检测",
"ocr": "车牌识别",
"qr": "图形码识别",
"ocr": "蜂鸣器",
"qr": "二维码识别",
"MoveNet": "MoveNet 关节点识别",
"Bert": "文本问答",
"SpeechCMD": "SpeechCMD 语音指令",
@@ -228,13 +229,14 @@ var JSLang = {
"fps": "帧率"
},
"tw": {
"beepAudio": "Audio",
"tensorAI": "- AI·Tensorflow.js -",
"imageNet": "ImageNet",
"cocoSSD": "CocoSSD",
"deepLab": "DeepLab",
"blazeFace": "BlazeFace",
"mediaPipe": "MediaPipe",
"ocr": "Real-time OCR",
"ocr": "Beep",
"qr": "Code Recognition",
"MoveNet": "MoveNet",
"Bert": "BERT",
@@ -456,13 +458,14 @@ var JSLang = {
"fps": "幀率"
},
"en": {
"beepAudio": "Beep Audio",
"tensorAI": "- AI·Tensorflow.js -",
"imageNet": "ImageNet",
"cocoSSD": "CocoSSD",
"deepLab": "DeepLab",
"blazeFace": "BlazeFace",
"mediaPipe": "MediaPipe",
"ocr": "Real-time OCR",
"ocr": "Beep",
"qr": "Code Recognition",
"MoveNet": "MoveNet",
"Bert": "BERT",

View File

@@ -1974,7 +1974,7 @@ function add_widget() {
//widget_list.append($("<h5 style='width:100%;text-align:center;margin-bottom:5px;margin-top:10px;color:#4e73df;font-size:1.3rem;font-weight:bold'>" + JSLang[lang].tensorAI + "</h5>"))
var blazeFace_add = $("<div class='widget_div'><div><img src='icons/blazeFace.svg'><span>" + JSLang[lang].blazeFace + "</span></div><a class='btn btn-success btn-block'><i class='fa fa-plus'></i></a></div>")
widget_list.append(blazeFace_add)
var ocr_add = $("<div class='widget_div'><div><img src='icons/mediaPipe.svg'><span>" + JSLang[lang].ocr + "</span></div><a class='btn btn-secondary btn-block'><i class='fa fa-plus'></i></a></div>")
var ocr_add = $("<div class='widget_div'><div><img src='icons/mediaPipe.svg'><span>" + JSLang[lang].ocr + "</span></div><a class='btn btn-success btn-block'><i class='fa fa-plus'></i></a></div>")
widget_list.append(ocr_add)
var qr_add = $("<div class='widget_div'><div><img src='icons/qrcode.svg'><span>" + JSLang[lang].qr + "</span></div><a class='btn btn-success btn-block'><i class='fa fa-plus'></i></a></div>")
widget_list.append(qr_add)
@@ -2185,8 +2185,6 @@ function add_widget() {
})
ocr_add.children("a").click(function() {
showtext("开发中")
return
d.close().remove()
var editForm = $('<div class="nnt"/>')
editForm.append($('<div style="margin-top:-63px;margin-left:82.5px;margin-bottom:15px;box-shadow: 1px 1px 20px #4e73df;background-color:white;width:75px;height:75px;padding:40px;border-radius:80px;border:solid #4e73df 3px;display:flex;align-items:center;justify-content:center"><img src="icons/mediaPipe.svg" style="width:45px;"></div>'))
@@ -2198,21 +2196,18 @@ function add_widget() {
editForm.append($('<h5 style="margin-top:15px;text-align:center">' + JSLang[lang].messTopic + '</h5>'))
var topic_input_div = $('<div style="display:flex;flex-direction:row;align-items:center"/>')
var topic_input = $("<input class='form-control form-control-user' style='text-align:center'/>")
topic_input.val("beep")
topic_input_div.append(topic_input)
topic_input.val("ocr")
editForm.append(topic_input_div)
editForm.append($('<h5 style="margin-top:15px;text-align:center">' + JSLang[lang].triggerInterval + '</h5>'))
var trigger_interval_div = $('<div style="display:flex;flex-direction:row;align-items:center"/>')
var trigger_interval = $("<input type='number' step='100' min='1000' max='100000' required class='form-control form-control-user' style='text-align:center' readonly/>")
trigger_interval.val(10000)
trigger_interval_div.append(trigger_interval)
trigger_interval.change(function(){
if(trigger_interval.val()<1000)
trigger_interval.val(1000)
})
editForm.append(trigger_interval_div)
editForm.append($('<h5 style="margin-top:15px;text-align:center">' + JSLang[lang].beepAudio + '</h5>'))
var beep_select = $('<select class="form-control form-control-user" style="margin-top:15px;text-align:center"/>')
beep_select.append($('<option value="weak">弱提示</option>'))
beep_select.append($('<option value="strong">强提示</option>'))
beep_select.append($('<option value="alarm">警报音</option>'))
editForm.append(beep_select)
beep_select.val("weak")
var bottomDiv = $('<div style="width:100%;margin-top:15px;display:flex;flex-direction:row;align-items:center;justify-content:space-around"/>')
var confirmEdit = $('<a class="btn btn-primary btn-circle" style="margin-right:10px;box-shadow:1px 1px 5px #4e73df;"><i class="fa fa-check"></i></a>')
var confirmEdit = $('<a class="btn btn-primary btn-circle" style="margin-right:10px;box-shadow:1px 1px 5px #4e73df"><i class="fa fa-check"></i></a>')
bottomDiv.append(confirmEdit)
confirmEdit.click(function() {
if (getByteLen(title_input.val()) > 0 && getByteLen(title_input.val()) < 21) {
@@ -2220,7 +2215,7 @@ function add_widget() {
if (getByteLen(topic_input.val()) > 0 && getByteLen(topic_input.val()) < 11)
if (true) {
if (countSubstr(grid.html(), 'user-title=\"' + title_input.val() + '\"', false) <= 0) {
add_ocr(title_input.val(), topic_input.val(), trigger_interval.val())
add_ocr(title_input.val(), topic_input.val(), beep_select.val())
modifyDia.close().remove()
} else
showtext(JSLang[lang].sameUnit)
@@ -2231,7 +2226,7 @@ function add_widget() {
} else
showtext(JSLang[lang].nameLenIllegal)
})
var cancelEdit = $('<a class="btn btn-danger btn-circle"><i class="fa fa-arrow-left"></i></a>')
var cancelEdit = $('<a class="btn btn-danger btn-circle" style="box-shadow:1px 1px 5px #e74a3b"><i class="fa fa-arrow-left"></i></a>')
cancelEdit.click(function() {
modifyDia.close().remove()
add_widget()

View File

@@ -6547,84 +6547,19 @@ function add_face(user_title, user_topic, user_content, user_style, title_style)
}
function add_ocr(user_title, user_topic, user_content, user_style, title_style) {
showtext("开发中")
return
var isAlive = true
var contents = []
var title = $("<h4 class='userTitle' style='margin-top:20px'>" + user_title + "</h4>")
var title = $("<h4 class='userTitle'>" + user_title + "</h4>")
title.attr("hidden", title_style)
contents.push(title)
var topicDiv = $("<div class='topicDiv'/>")
var topic = $("<span class='index-topic' style='margin:0;color:#858796;'>" + user_topic + "</span>")
topicDiv.append($("<i class='fa fa-podcast' style='color:#858796;margin-right:3px'></i>"))
topicDiv.append(topic)
var cameraDiv = $("<div class='cameraDiv' style='position:relative'/>")
contents.push(cameraDiv)
// add a real-time web camera
var video = $("<video autoplay style='width:100%;height:100%;'/>")
cameraDiv.append(video)
// 底部字幕
var bottomDiv11 = $("<div style='background-color:rgba(0,0,0,0.5);text-align:center;color:white;position:absolute;bottom:0;width:100%;height:40px'/>")
cameraDiv.append(bottomDiv11)
// 居中显示Loading...
navigator.mediaDevices.getUserMedia({
video: {
width: {
ideal: 1000
},
height: {
ideal: 1000
},
frameRate: {
ideal: 30,
min: 10
},
facingMode: "environment"
},
audio: false
}).then(function(stream) {
video[0].srcObject = stream
var canvas = $("<canvas style='width:100%;height:100%;'/>")
canvas[0].width = 1000
canvas[0].height = 1000
var ctx = canvas[0].getContext('2d')
setInterval(function(){
ctx.drawImage(video[0], 0, 0, 1000, 1000)
var base64 = canvas[0].toDataURL('image/png')
$.ajax({
type: "POST",
url: "proxy",
dataType: "json",
data: JSON.stringify({
"url": "http://127.0.0.1:5000",
"data":{
"pic": base64
}
}),
contentType: "application/json;charset=utf-8",
success: function (data) {
var text = data["result"]
if(text=="")
{
bottomDiv11.text("未检测到车牌")
}
else
{
bottomDiv11.text(text)
if(isAlive && isRunning)
publish(user_topic, text)
}
},
error: function (data) {
console.log(data)
}
});
},10000)
})
var icon_div = $('<div style="display:flex;flex-direction:row;align-items:center;justify-content:center"/>')
var bell_icon = $('<i class="fa fa-bell" style="font-size:40px;color:#858796"></i>')
icon_div.append(bell_icon)
contents.push(icon_div)
attrs = [
['user-type', 'ocr'],
['user-title', user_title],
@@ -6632,7 +6567,8 @@ function add_ocr(user_title, user_topic, user_content, user_style, title_style)
['user-content', user_content],
['title-hidden', title_style]
]
var itemdiv = add_block(3, 3, contents, attrs)
var itemdiv = add_block(1, 1, contents, attrs)
var delete_on_click = function() {
title.parent().parent().remove();
@@ -6657,19 +6593,42 @@ function add_ocr(user_title, user_topic, user_content, user_style, title_style)
var topic_input = $("<input class='form-control form-control-user' style='text-align:center'/>")
topic_input_div.append(topic_input)
editForm.append(topic_input_div)
editForm.append($('<h5 style="margin-top:15px;text-align:center">' + JSLang[lang].triggerInterval + '</h5>'))
var trigger_interval_div = $('<div style="display:flex;flex-direction:row;align-items:center"/>')
var trigger_interval = $("<input type='number' step='100' min='1000' max='100000' required class='form-control form-control-user' style='text-align:center' readonly/>")
trigger_interval.val(10000)
trigger_interval.change(function(){
if(trigger_interval.val()<1000)
trigger_interval.val(1000)
})
trigger_interval_div.append(trigger_interval)
editForm.append(trigger_interval_div)
editForm.append($('<h5 style="margin-top:15px;text-align:center">' + JSLang[lang].beepAudio + '</h5>'))
var beep_select = $('<select class="form-control form-control-user" style="margin-top:15px;text-align:center"/>')
beep_select.append($('<option value="weak">弱提示</option>'))
beep_select.append($('<option value="strong">强提示</option>'))
beep_select.append($('<option value="alarm">警报音</option>'))
editForm.append(beep_select)
var bottomDiv = $('<div style="width:100%;margin-top:15px;display:flex;flex-direction:row;align-items:center;justify-content:space-around"/>')
var confirmEdit = $('<a class="btn btn-primary btn-circle" style="margin-right:10px;box-shadow:1px 1px 5px #4e73df"><i class="fa fa-check"></i></a>')
bottomDiv.append(confirmEdit)
client.on('message', function(topic1, message1) {
if (isAlive && isRunning)
if (topic1.split("/")[(isMixly ? 3 : 2)] == topic.text()) {
const music = new Audio('img/'+ title.parent().parent().attr('user-content') +'.mp3');
music.play();
music.loop = false;
if(title.parent().parent().attr('user-content') == "weak")
{
bell_icon.css("color", "#4e73df")
itemdiv.css("box-shadow", "#4e73df 1px 1px 10px")
}
if(title.parent().parent().attr('user-content') == "strong")
{
bell_icon.css("color", "#1cc88a")
itemdiv.css("box-shadow", "#1cc88a 1px 1px 10px")
}
if(title.parent().parent().attr('user-content') == "alarm")
{
bell_icon.css("color", "#e74a3b")
itemdiv.css("box-shadow", "#e74a3b 1px 1px 10px")
}
setTimeout(function(){
bell_icon.css("color", "#858796")
itemdiv.css("box-shadow", "")
},300)
}
})
confirmEdit.click(function() {
if (getByteLen(title_input.val()) > 0 && getByteLen(title_input.val()) < 21) {
var re = /^[a-z0-9]+$/i;
@@ -6678,7 +6637,7 @@ function add_ocr(user_title, user_topic, user_content, user_style, title_style)
if (countSubstr(grid.html(), 'user-title=\"' + title_input.val() + '\"', false) <= (title_input.val() == title.text() ? 1 : 0)) {
title.parent().parent().attr('user-title', title_input.val())
title.parent().parent().attr('user-topic', topic_input.val())
title.parent().parent().attr('user-content', trigger_interval.val())
title.parent().parent().attr('user-content', beep_select.val())
title.text(title_input.val())
topic.text(topic_input.val())
modifyDia.close()
@@ -6723,7 +6682,7 @@ function add_ocr(user_title, user_topic, user_content, user_style, title_style)
if (!isRunning)
bubble.append(deleteButton)
if (!isRunning)
{
{
copyButton.attr("user-origin", title.text())
bubble.append(copyButton)
styleButton.attr("user-origin", title.text())
@@ -6733,7 +6692,7 @@ function add_ocr(user_title, user_topic, user_content, user_style, title_style)
}
title_input.val(title.text())
topic_input.val(topic.text())
trigger_interval.val(title.parent().parent().attr('user-content'))
beep_select.val(title.parent().parent().attr('user-content'))
if (!d.open)
{
d.show(itemdiv[0]);