Skip to content

Commit 25a773f

Browse files
author
Marty
committed
first commit
1 parent 07b628e commit 25a773f

18 files changed

+583
-1
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Webduino
3+
Copyright (c) 2018 marty5499
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# webduino-module-imageml

blockly.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"types": ["imageml2_classifier", "imageml2_callback", "imageml2_levelVal", "imageml2_confidenceVal"],
3+
"category": "toolbox",
4+
"scripts": [
5+
"blockly/hashids.min.js",
6+
"blockly/util.js",
7+
"blockly/blocks.js",
8+
"blockly/javascript.js"
9+
],
10+
"dependencies": [
11+
"imageml.js",
12+
"imageml-blockly.js"
13+
],
14+
"msg": "blockly/msg",
15+
"blocksMsg": "blockly/msg/blocks",
16+
"toolbox": "blockly/toolbox.xml"
17+
}

blockly/blocks.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//https: //blockly-demo.appspot.com/static/demos/blockfactory_old/index.html#ckpupe
2+
3+
Blockly.Blocks['imageml2_classifier'] = {
4+
init: function () {
5+
this.appendDummyInput()
6+
.appendField(Blockly.Msg.WEBDUINO_IMAGEML_CAMERA_SRC)
7+
.appendField(new Blockly.FieldTextInput(Blockly.Msg.WEBDUINO_IMAGEML_CAMERA_LOCAL), "camSource")
8+
.appendField("旋轉鏡頭")
9+
.appendField(new Blockly.FieldCheckbox("TRUE"), "rotate")
10+
.appendField(Blockly.Msg.WEBDUINO_IMAGEML_MODEL_NAME)
11+
.appendField(new Blockly.FieldTextInput(""), "modelName");
12+
this.setOutput(true, null);
13+
this.setColour(230);
14+
this.setTooltip('');
15+
this.setToolUrl(hasher.getUIUrl());
16+
}
17+
};
18+
19+
Blockly.Blocks['imageml2_callback'] = {
20+
init: function () {
21+
this.appendDummyInput()
22+
.appendField(new Blockly.FieldVariable("imageClassifier"), "name")
23+
.appendField(Blockly.Msg.WEBDUINO_IMAGEML_CLASSIFY)
24+
.appendField(new Blockly.FieldTextInput("0"), "idx")
25+
.appendField(Blockly.Msg.WEBDUINO_IMAGEML_CLASSIFY2);
26+
this.appendStatementInput("name")
27+
.setCheck(null)
28+
.appendField(Blockly.Msg.WEBDUINO_IMAGEML_RUN);
29+
this.setPreviousStatement(true, null);
30+
this.setNextStatement(true, null);
31+
this.setColour(75);
32+
this.setTooltip('');
33+
this.setToolUrl(hasher.getUIUrl());
34+
}
35+
};
36+
37+
Blockly.Blocks['imageml2_levelVal'] = {
38+
init: function () {
39+
this.appendDummyInput()
40+
.appendField(new Blockly.FieldVariable("imageClassifier"), "name")
41+
.appendField(Blockly.Msg.WEBDUINO_IMAGEML_LEVEL);
42+
this.setOutput(true, null);
43+
this.setColour(45);
44+
this.setTooltip("");
45+
this.setToolUrl(hasher.getUIUrl());
46+
}
47+
};
48+
49+
Blockly.Blocks['imageml2_confidenceVal'] = {
50+
init: function () {
51+
this.appendDummyInput()
52+
.appendField(new Blockly.FieldVariable("imageClassifier"), "name")
53+
.appendField(Blockly.Msg.WEBDUINO_IMAGEML_CONFIDENCE);
54+
this.setOutput(true, null);
55+
this.setColour(45);
56+
this.setTooltip("");
57+
this.setToolUrl(hasher.getUIUrl());
58+
}
59+
};

blockly/hashids.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

blockly/javascript.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Blockly.JavaScript['imageml2_classifier'] = function (block) {
2+
var text_cameraurl = block.getFieldValue('cameraURL');
3+
var text_camSource = block.getFieldValue('camSource');
4+
var text_modelname = block.getFieldValue('modelName');
5+
var checkbox_rotate = block.getFieldValue('rotate') == 'TRUE';
6+
var code = 'getVideoClassifier("' + text_modelname + '","' + text_camSource + '",' + hasher.userId + ',' + checkbox_rotate + ')';
7+
return [code, Blockly.JavaScript.ORDER_NONE];
8+
};
9+
10+
Blockly.JavaScript['imageml2_callback'] = function (block) {
11+
var idx = block.getFieldValue('idx');
12+
var variable_name = Blockly.JavaScript.variableDB_.getName(block.getFieldValue('name'), Blockly.Variables.NAME_TYPE);
13+
var statements_name = Blockly.JavaScript.statementToCode(block, 'name');
14+
var code = variable_name + '.onLabel(' + idx + ', async function(idx){\n';
15+
code += statements_name + '\n';
16+
code += '});\n';
17+
return code;
18+
};
19+
20+
Blockly.JavaScript['imageml2_levelVal'] = function (block) {
21+
var variable_name = Blockly.JavaScript.variableDB_.getName(block.getFieldValue('name'), Blockly.Variables.NAME_TYPE);
22+
var code = variable_name + '.getClass()';
23+
return [code, Blockly.JavaScript.ORDER_NONE];
24+
};
25+
26+
Blockly.JavaScript['imageml2_confidenceVal'] = function (block) {
27+
var variable_name = Blockly.JavaScript.variableDB_.getName(block.getFieldValue('name'), Blockly.Variables.NAME_TYPE);
28+
var code = variable_name + '.getConfidence()';
29+
return [code, Blockly.JavaScript.ORDER_NONE];
30+
};

blockly/msg/blocks/en.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Blockly.Msg.WEBDUINO_IMAGEML_CAMERA_SRC = "Camera Source:";
2+
Blockly.Msg.WEBDUINO_IMAGEML_CAMERA_LOCAL = "Local";
3+
Blockly.Msg.WEBDUINO_IMAGEML_MODEL_NAME = ", load model:";
4+
Blockly.Msg.WEBDUINO_IMAGEML_CLASSIFY = "Start to classify, when the class index is";
5+
Blockly.Msg.WEBDUINO_IMAGEML_CLASSIFY2 = "";
6+
Blockly.Msg.WEBDUINO_IMAGEML_RUN = "Run";
7+
Blockly.Msg.WEBDUINO_IMAGEML_LEVEL = "Class index";
8+
Blockly.Msg.WEBDUINO_IMAGEML_CONFIDENCE = "Class confidence";

blockly/msg/blocks/zh-hans.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Blockly.Msg.WEBDUINO_IMAGEML_CAMERA_SRC = "相机位置:";
2+
Blockly.Msg.WEBDUINO_IMAGEML_CAMERA_LOCAL = "本机";
3+
Blockly.Msg.WEBDUINO_IMAGEML_MODEL_NAME = ",加载模型:";
4+
Blockly.Msg.WEBDUINO_IMAGEML_CLASSIFY = "对影像进行分类,当分类编号为";
5+
Blockly.Msg.WEBDUINO_IMAGEML_CLASSIFY2 = "时";
6+
Blockly.Msg.WEBDUINO_IMAGEML_RUN = "执行";
7+
Blockly.Msg.WEBDUINO_IMAGEML_LEVEL = "分类编号";
8+
Blockly.Msg.WEBDUINO_IMAGEML_CONFIDENCE = "分类信心度";

blockly/msg/blocks/zh-hant.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Blockly.Msg.WEBDUINO_IMAGEML_CAMERA_SRC = "相機位置:";
2+
Blockly.Msg.WEBDUINO_IMAGEML_CAMERA_LOCAL = "本機";
3+
Blockly.Msg.WEBDUINO_IMAGEML_MODEL_NAME = ",載入模型:";
4+
Blockly.Msg.WEBDUINO_IMAGEML_CLASSIFY = "對影像進行分類,當分類編號為";
5+
Blockly.Msg.WEBDUINO_IMAGEML_CLASSIFY2 = "時";
6+
Blockly.Msg.WEBDUINO_IMAGEML_RUN = "執行";
7+
Blockly.Msg.WEBDUINO_IMAGEML_LEVEL = "分類編號";
8+
Blockly.Msg.WEBDUINO_IMAGEML_CONFIDENCE = "分類信心度";

blockly/msg/en.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MSG.catImageML = "Image Classifier";

0 commit comments

Comments
 (0)