Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
fustyles authored May 3, 2022
1 parent 4ed59c2 commit 0b80d1a
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 10 deletions.
9 changes: 9 additions & 0 deletions Blazeface_20201012/blazeface.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,21 @@
document.getElementById("sourceId_blazeface").innerHTML = "gameimage_blazeface";
}
}

function blazeface_clear() {
document.getElementById("gamediv_blazeface").innerHTML = "";
}

function blazeface_recognitionFinish() {
}

window.blazeface_video = blazeface_video;
window.blazeface_get = blazeface_get;
window.blazeface_video_position = blazeface_video_position;
window.blazeface_state = blazeface_state;
window.blazeface_startvideo_media = blazeface_startvideo_media;
window.blazeface_startvideo_stream = blazeface_startvideo_stream;
window.blazeface_clear = blazeface_clear;
window.blazeface_recognitionFinish = blazeface_recognitionFinish;

}(window, window.document));
7 changes: 3 additions & 4 deletions Blazeface_20201012/blazeface_video.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,15 @@ window.onload = function () {
context.drawImage(obj, 0, 0, obj.width, obj.height);

if (blazefaceState.innerHTML=="0") {
result.innerHTML = "";
//result.innerHTML = "";
setTimeout(function(){DetectVideo(obj);}, 100);
return;
}

const returnTensors = false;
await Model.estimateFaces(canvas, returnTensors).then(predictions => {
result.innerHTML = "";

var scoreLimit = Number(document.getElementById("scorelimit_blazeface").value);

//console.log(predictions.score);
//console.log(predictions.keypoints);
result.innerHTML = "";
Expand Down Expand Up @@ -89,7 +88,7 @@ window.onload = function () {
}
if (result.innerHTML!="") {
result.innerHTML = result.innerHTML.substr(0,result.innerHTML.length-4);
if (typeof recognitionFinish === 'function') recognitionFinish();
if (typeof blazeface_recognitionFinish === 'function') blazeface_recognitionFinish();
}
}

Expand Down
2 changes: 1 addition & 1 deletion Blazeface_20201012/blockly.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"types": ["blazeface_video","blazeface_person","blazeface_state","blazeface_video_position","blazeface_startvideo_media","blazeface_startvideo_stream"],
"types": ["blazeface_video","blazeface_person","blazeface_state","blazeface_video_position","blazeface_startvideo_media","blazeface_startvideo_stream", "blazeface_clear", "blazeface_pause", "blazeface_recognitied"],
"category": "catPlus",
"scripts": [
"blockly/blocks.js",
Expand Down
37 changes: 37 additions & 0 deletions Blazeface_20201012/blockly/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,40 @@ Blockly.Blocks['blazeface_startvideo_stream'] = {
this.setColour(60);
}
};

Blockly.Blocks['blazeface_clear'] = {
init: function() {
this.appendDummyInput()
.appendField(Blockly.Msg.BLAZEFACE_CLEAR_SHOW);
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setColour(60);
}
};

Blockly.Blocks['blazeface_pause'] = {
init: function() {
this.appendDummyInput()
.appendField(Blockly.Msg.BLAZEFACE_PAUSE_SHOW);
this.appendValueInput("time_")
.setCheck("Number")
.appendField("(ms)");
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setColour(60);
}
};

Blockly.Blocks['blazeface_recognitied'] = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.BLAZEFACE_RECOGNITIED_SHOW);
this.appendStatementInput("do_");
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setColour(60);
}
};
17 changes: 17 additions & 0 deletions Blazeface_20201012/blockly/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,21 @@ Blockly.JavaScript['blazeface_startvideo_stream'] = function(block) {
var value_src_ = Blockly.JavaScript.valueToCode(block, 'src_', Blockly.JavaScript.ORDER_ATOMIC);
var code = 'blazeface_startvideo_stream(' + value_src_ + ');\n';
return code;
};

Blockly.JavaScript['blazeface_clear'] = function(block) {
var code = 'blazeface_clear();\n';
return code;
};

Blockly.JavaScript['blazeface_pause'] = function(block) {
var value_time = Blockly.JavaScript.valueToCode(block, 'time_', Blockly.JavaScript.ORDER_ATOMIC);
var code = 'blazeface_state(0);setTimeout(function(){blazeface_state(1);}, '+value_time+');\n';
return code;
};

Blockly.JavaScript['blazeface_recognitied'] = function(block) {
var statements_do = Blockly.JavaScript.statementToCode(block, 'do_');
var code = 'blazeface_recognitionFinish = async function() {\nblazeface_state(0);\n' + statements_do + '\nblazeface_state(1);};\n';
return code;
};
5 changes: 4 additions & 1 deletion Blazeface_20201012/blockly/msg/blocks/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ Blockly.Msg.BLAZEFACE_FRAME_SHOW = "Frame";
Blockly.Msg.BLAZEFACE_FACING_SHOW = "Camera Facing";
Blockly.Msg.BLAZEFACE_FACING_FRONT_SHOW = "Front";
Blockly.Msg.BLAZEFACE_FACING_BACK_SHOW = "Back";
Blockly.Msg.BLAZEFACE_SRC_SHOW = "Stream URL";
Blockly.Msg.BLAZEFACE_SRC_SHOW = "Stream URL";
Blockly.Msg.BLAZEFACE_CLEAR_SHOW = "Face Detection (blazeface) clear result";
Blockly.Msg.BLAZEFACE_PAUSE_SHOW = "Face Detection (blazeface) Pause";
Blockly.Msg.BLAZEFACE_RECOGNITIED_SHOW = "Face Detection (blazeface) recognitied";
5 changes: 4 additions & 1 deletion Blazeface_20201012/blockly/msg/blocks/zh-hans.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ Blockly.Msg.BLAZEFACE_FRAME_SHOW = "框架";
Blockly.Msg.BLAZEFACE_FACING_SHOW = "镜头";
Blockly.Msg.BLAZEFACE_FACING_FRONT_SHOW = "前置";
Blockly.Msg.BLAZEFACE_FACING_BACK_SHOW = "后置";
Blockly.Msg.BLAZEFACE_SRC_SHOW = "串流网址";
Blockly.Msg.BLAZEFACE_SRC_SHOW = "串流网址";
Blockly.Msg.BLAZEFACE_CLEAR_SHOW = "脸部侦测 (blazeface) 清除结果";
Blockly.Msg.BLAZEFACE_PAUSE_SHOW = "脸部侦测 (blazeface) 暂停侦测";
Blockly.Msg.BLAZEFACE_RECOGNITIED_SHOW = "脸部侦测 (blazeface) 侦测完成后执行";
5 changes: 4 additions & 1 deletion Blazeface_20201012/blockly/msg/blocks/zh-hant.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ Blockly.Msg.BLAZEFACE_FRAME_SHOW = "框架";
Blockly.Msg.BLAZEFACE_FACING_SHOW = "鏡頭";
Blockly.Msg.BLAZEFACE_FACING_FRONT_SHOW = "前置";
Blockly.Msg.BLAZEFACE_FACING_BACK_SHOW = "後置";
Blockly.Msg.BLAZEFACE_SRC_SHOW = "串流網址";
Blockly.Msg.BLAZEFACE_SRC_SHOW = "串流網址";
Blockly.Msg.BLAZEFACE_CLEAR_SHOW = "臉部偵測 (blazeface) 清除結果";
Blockly.Msg.BLAZEFACE_PAUSE_SHOW = "臉部偵測 (blazeface) 暫停偵測";
Blockly.Msg.BLAZEFACE_RECOGNITIED_SHOW = "臉部偵測 (blazeface) 偵測完成後執行";
15 changes: 13 additions & 2 deletions Blazeface_20201012/blockly/toolbox.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
<field name="TEXT">http://192.168.***.***:81/stream</field>
</block>
</value>
</block>
</block>
<block type="blazeface_recognitied">
</block>
<block type="blazeface_person">
<value name="person_">
<block type="math_number">
Expand All @@ -34,6 +36,8 @@
</block>
<block type="blazeface_state">
</block>
<block type="blazeface_clear">
</block>
<block type="blazeface_video_position">
<value name="left_">
<block type="math_number">
Expand All @@ -45,5 +49,12 @@
<field name="NUM">0</field>
</block>
</value>
</block>
</block>
<block type="blazeface_pause">
<value name="time_">
<block type="math_number">
<field name="NUM">1000</field>
</block>
</value>
</block>
</category>

0 comments on commit 0b80d1a

Please sign in to comment.