From 2b0f2d5f380c518a0ec35ce786c243f699bd8acb Mon Sep 17 00:00:00 2001 From: zimujun20 <1192147078@qq.com> Date: Tue, 4 Oct 2022 13:44:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E8=8E=B7=E5=8F=96=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=9C=B0=E5=9D=80=E5=92=8C=E8=B4=9F=E8=BD=BD=E5=9D=87?= =?UTF-8?q?=E8=A1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/webserver/pkg/api/android/media_pipe.go | 6 ++--- src/webserver/pkg/api/android/word_send.go | 4 ++-- src/webserver/static/js/mediaToWords.js | 25 ++++++++++++++++++--- src/webserver/static/js/wordsToMedia.js | 9 +++++--- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/webserver/pkg/api/android/media_pipe.go b/src/webserver/pkg/api/android/media_pipe.go index 22b8f3b..ec48cea 100644 --- a/src/webserver/pkg/api/android/media_pipe.go +++ b/src/webserver/pkg/api/android/media_pipe.go @@ -7,8 +7,8 @@ import ( "time" "pkg/app" "errors" - _ "github.com/mattn/go-sqlite3" + _ "github.com/mattn/go-sqlite3" "github.com/gin-gonic/gin" ) @@ -81,12 +81,12 @@ func sendAddress(c *gin.Context) { db.Exec(`update Endpoint set ipAddress = ? where macAddress = ?;`, ipAddress, macAddress) db.Exec(`update Endpoint set isOnLine = ? where macAddress = ?;`, t, macAddress) } - appG.Response(http.StatusOK, "成功", null) + appG.Response(http.StatusOK, "true", null) } func mediaPipe(c *gin.Context) { appG := app.Gin{C: c} //这里将视频流转化为自然语言 data := - appG.Response(http.StatusOK, "成功", data) + appG.Response(http.StatusOK, "true", data) } \ No newline at end of file diff --git a/src/webserver/pkg/api/android/word_send.go b/src/webserver/pkg/api/android/word_send.go index 82d21f7..80e5b3c 100644 --- a/src/webserver/pkg/api/android/word_send.go +++ b/src/webserver/pkg/api/android/word_send.go @@ -4,7 +4,7 @@ import ( "fmt" "database/sql" _ "go-sqlite3-master" - "application/pkg/app" + "pkg/app" "github.com/gin-gonic/gin" ) @@ -35,5 +35,5 @@ func wordSend (c *gin.Context) { //这里获取转化好的数据 data := mediaPipe().data updateAverage() - appG.Response(http.StatusOK, "成功", data) + appG.Response(http.StatusOK, "true", data) } \ No newline at end of file diff --git a/src/webserver/static/js/mediaToWords.js b/src/webserver/static/js/mediaToWords.js index 0d39b5b..3ccb104 100644 --- a/src/webserver/static/js/mediaToWords.js +++ b/src/webserver/static/js/mediaToWords.js @@ -1,8 +1,27 @@ //获取手语视频 -func getMedia() {} +function getMedia() { + media = infos.media.value + mediaToWords(media) +} //翻译视频为自然语言 -func mediaToWords() {} +function mediaToWords(media) { + //这里调用hands_recegnation + display(word) +} //显示自然语言 -func display() {} \ No newline at end of file +function display(word) { + var xmlhttp; + if (window.XMLHttpRequest) xmlhttp=new XMLHttpRequest(); + else xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); + xmlhttp.onreadystatechange=function() + { + if (xmlhttp.readyState==4 && xmlhttp.status==200) { + if (xmlhttp.responseText=="成功") alert("翻译成功!") + else alert("操作失败") + } + } + xmlhttp.open("GET","http://127.0.0.1:8000//",true); + xmlhttp.send(); +} \ No newline at end of file diff --git a/src/webserver/static/js/wordsToMedia.js b/src/webserver/static/js/wordsToMedia.js index c4acf77..9fc8a64 100644 --- a/src/webserver/static/js/wordsToMedia.js +++ b/src/webserver/static/js/wordsToMedia.js @@ -5,7 +5,10 @@ function enterWords() { } //翻译自然语言为动画 -function wordsToMedia(words) {} +function wordsToMedia(words) { + //这里调用word_input + display(media) +} //显示动画 function display(media) { @@ -15,10 +18,10 @@ function display(media) { xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { - if (xmlhttp.responseText=="成功") alert("删除成功!") + if (xmlhttp.responseText=="成功") alert("翻译成功!") else alert("操作失败") } } - xmlhttp.open("GET","http://127.0.0.1:8000//"+"?user="+user+"&ps="+ps,true); + xmlhttp.open("GET","http://127.0.0.1:8000//",true); xmlhttp.send(); } \ No newline at end of file