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 Jun 13, 2024
1 parent 64a9154 commit 7f84a7c
Show file tree
Hide file tree
Showing 5 changed files with 382 additions and 1 deletion.
108 changes: 108 additions & 0 deletions LinkIt7697/France/blocks.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,111 @@
Blockly.Blocks['amb82_mini_facedetection_rtsp'] = {
init: function() {
this.appendDummyInput()
.appendField(Blockly.Msg["AMB82_MINI"])
.appendField(Blockly.Msg["AMB82_MINI_FACEDETECTION"]);
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg["AMB82_MINI_MODEL"])
.appendField(new Blockly.FieldDropdown([
["SCRFD","DEFAULT_SCRFD"],
["SCRFD_SD","CUSTOMIZED_SCRFD"]
]), "model");
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg["AMB82_MINI_FACEDETECTION_LABEL"])
.appendField(new Blockly.FieldDropdown([
["Y","Y"],
["N","N"]
]), "label");
this.appendDummyInput()
.appendField(Blockly.Msg["AMB82_MINI_FACEDETECTION_AFTER"]);
this.appendStatementInput("statement")
.setCheck(null);
this.appendDummyInput()
.appendField(Blockly.Msg["AMB82_MINI_FACEDETECTION_FINISH"]);
this.appendStatementInput("statement_finish")
.setCheck(null);
this.setInputsInline(true);
this.setPreviousStatement(!0);
this.setNextStatement(!0);
this.setColour(Blockly.Msg["HUE_12"]);
}
};

Blockly.Blocks['amb82_mini_facedetection_rtsp_count'] = {
init: function() {
this.appendDummyInput()
.appendField(Blockly.Msg["AMB82_MINI"])
.appendField(Blockly.Msg["AMB82_MINI_FACEDETECTION"])
.appendField(Blockly.Msg["AMB82_MINI_FACEDETECTION_COUNT"]);
this.setInputsInline(true);
this.setOutput(true, null);
this.setColour(Blockly.Msg["HUE_12"]);
}
};

Blockly.Blocks['amb82_mini_facedetection_rtsp_rect'] = {
init: function() {
this.appendDummyInput()
.appendField(Blockly.Msg["AMB82_MINI"])
.appendField(Blockly.Msg["AMB82_MINI_FACEDETECTION"])
.appendField(Blockly.Msg["AMB82_MINI_FACEDETECTION_ITEMLIST"]);
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(new Blockly.FieldDropdown([
[Blockly.Msg["AMB82_MINI_FACEDETECTION_OBJECT"],"OBJECT"],
[Blockly.Msg["AMB82_MINI_FACEDETECTION_SCORE"],"SCORE"],
[Blockly.Msg["AMB82_MINI_FACEDETECTION_X_MIN"],"X"],
[Blockly.Msg["AMB82_MINI_FACEDETECTION_Y_MIN"],"Y"],
[Blockly.Msg["AMB82_MINI_FACEDETECTION_X_MIDDLE"],"XM"],
[Blockly.Msg["AMB82_MINI_FACEDETECTION_Y_MIDDLE"],"YM"],
[Blockly.Msg["AMB82_MINI_FACEDETECTION_X_MAX"],"X1"],
[Blockly.Msg["AMB82_MINI_FACEDETECTION_Y_MAX"],"Y1"],
[Blockly.Msg["AMB82_MINI_FACEDETECTION_WIDTH"],"WIDTH"],
[Blockly.Msg["AMB82_MINI_FACEDETECTION_HIGHT"],"HEIGHT"]
]), "property");
this.setInputsInline(true);
this.setOutput(true, null);
this.setColour(Blockly.Msg["HUE_12"]);
}
};

Blockly.Blocks['amb82_mini_facedetection_rtsp_point'] = {
init: function() {
this.appendDummyInput()
.appendField(Blockly.Msg["AMB82_MINI"])
.appendField(Blockly.Msg["AMB82_MINI_FACEDETECTION"])
.appendField(Blockly.Msg["AMB82_MINI_FACEDETECTION_POINT"]);
this.appendDummyInput()
.appendField(new Blockly.FieldDropdown([
["0", "0"],
["1", "1"],
["2", "2"],
["3", "3"],
["4", "4"]
]), "index");
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(new Blockly.FieldDropdown([
[Blockly.Msg["AMB82_MINI_FACEDETECTION_X_MIN"],"X"],
[Blockly.Msg["AMB82_MINI_FACEDETECTION_Y_MIN"],"Y"]
]), "property");
this.setInputsInline(true);
this.setOutput(true, null);
this.setColour(Blockly.Msg["HUE_12"]);
}
};











Blockly.Blocks['RC522_initial'] = {
init: function() {
this.appendDummyInput()
Expand Down
19 changes: 19 additions & 0 deletions LinkIt7697/France/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ Blockly.Msg["HUE_28"] = 290;
Blockly.Msg["HUE_29"] = 340;
Blockly.Msg["HUE_30"] = 50;

Blockly.Msg["AMB82_MINI_FACEDETECTION"] = "Face Detection";
Blockly.Msg["AMB82_MINI_FACEDETECTION_LABEL"] = "Label";
Blockly.Msg["AMB82_MINI_FACEDETECTION_AFTER"] = "Enumerate All Faces";
Blockly.Msg["AMB82_MINI_FACEDETECTION_FINISH"] = "After Enumeration";
Blockly.Msg["AMB82_MINI_FACEDETECTION_COUNT"] = "Number of Faces";
Blockly.Msg["AMB82_MINI_FACEDETECTION_ITEMLIST"] = "Enumerate Face Attributes";
Blockly.Msg["AMB82_MINI_FACEDETECTION_OBJECT"] = "Face Name";
Blockly.Msg["AMB82_MINI_FACEDETECTION_SCORE"] = "Confidence Score";
Blockly.Msg["AMB82_MINI_FACEDETECTION_X_MIN"] = "X Top Left";
Blockly.Msg["AMB82_MINI_FACEDETECTION_Y_MIN"] = "Y Top Left";
Blockly.Msg["AMB82_MINI_FACEDETECTION_X_MIDDLE"] = "X Middle";
Blockly.Msg["AMB82_MINI_FACEDETECTION_Y_MIDDLE"] = "Y Middle";
Blockly.Msg["AMB82_MINI_FACEDETECTION_X_MAX"] = "X Bottom Right";
Blockly.Msg["AMB82_MINI_FACEDETECTION_Y_MAX"] = "Y Bottom Right";
Blockly.Msg["AMB82_MINI_FACEDETECTION_WIDTH"] = "Width";
Blockly.Msg["AMB82_MINI_FACEDETECTION_HIGHT"] = "Height";
Blockly.Msg["AMB82_MINI_FACEDETECTION_POINT"] = "Feature Point";


Blockly.Msg["ESP32_AES_ENCRYPT"] = "AES ENCRYPT";
Blockly.Msg["ESP32_AES_DECRYPT"] = "AES DECRYPT";
Blockly.Msg["ESP32_AES_KEY"] = "Key";
Expand Down
122 changes: 122 additions & 0 deletions LinkIt7697/France/javascript.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,125 @@
Blockly.Arduino['amb82_mini_facedetection_rtsp'] = function(block) {

Blockly.Arduino.definitions_.define_custom_command = "";
Blockly.Arduino.setups_.write_peri_reg = "";

var model = block.getFieldValue('model');
var label = block.getFieldValue('label');
var statement = Blockly.Arduino.statementToCode(block, 'statement');
var statement_finish = Blockly.Arduino.statementToCode(block, 'statement_finish');

Blockly.Arduino.definitions_['define_linkit_wifi_include'] ='#include "WiFi.h"\n#include "StreamIO.h"\n#include "VideoStream.h"\n#include "RTSP.h"\n#include "NNFaceDetection.h"\n#include "VideoStreamOverlay.h"\n#define amb82_CHANNEL 0\n#define CHANNELNN 3\n#define NNWIDTH 576\n#define NNHEIGHT 320\nVideoSetting config(VIDEO_FHD, 30, VIDEO_H264, 0);\nVideoSetting configNN(NNWIDTH, NNHEIGHT, 10, VIDEO_RGB, 0);\nNNFaceDetection facedet;\nRTSP rtsp;\nStreamIO videoStreamer(1, 1);\nStreamIO videoStreamerNN(1, 1);\n';
Blockly.Arduino.definitions_['define_amb82_mini_facedetection_rtsp_faceDetectionItem'] =''+
'void FDPostProcess(std::vector<FaceDetectionResult> results) {\n'+
' uint16_t im_h = config.height();\n'+
' uint16_t im_w = config.width();\n'+
' OSD.createBitmap(amb82_CHANNEL);\n'+
' if (facedet.getResultCount() > 0) {\n'+
' for (int i = 0; i < facedet.getResultCount(); i++) {\n'+
' FaceDetectionResult item = results[i];\n'+
' int xmin = (int)(item.xMin() * im_w);\n'+
' int xmax = (int)(item.xMax() * im_w);\n'+
' int ymin = (int)(item.yMin() * im_h);\n'+
' int ymax = (int)(item.yMax() * im_h);\n'+ statement;

if (label=="Y") {
Blockly.Arduino.definitions_['define_amb82_mini_facedetection_rtsp_faceDetectionItem'] +=
' //printf("Face %ld confidence %d:\\t%d %d %d %d\\n\\r", i, item.score(), xmin, xmax, ymin, ymax);\n'+
' OSD.drawRect(amb82_CHANNEL, xmin, ymin, xmax, ymax, 3, OSD_COLOR_WHITE);\n'+
' char text_str[40];\n'+
' snprintf(text_str, sizeof(text_str), "%s %d", item.name(), item.score());\n'+
' OSD.drawText(amb82_CHANNEL, xmin, ymin - OSD.getTextHeight(amb82_CHANNEL), text_str, OSD_COLOR_CYAN);\n';
}

Blockly.Arduino.definitions_['define_amb82_mini_facedetection_rtsp_faceDetectionItem'] +=
' }\n'+
' }\n'+ statement_finish +
' OSD.update(amb82_CHANNEL);\n'+
'}';


Blockly.Arduino.setups_.setup_amb82_mini_facedetection = ''+
'config.setBitrate(2 * 1024 * 1024);\n '+
'Camera.configVideoChannel(amb82_CHANNEL, config);\n '+
'Camera.configVideoChannel(CHANNELNN, configNN);\n '+
'Camera.videoInit();\n '+
'rtsp.configVideo(config);\n '+
'rtsp.begin();\n '+
'facedet.configVideo(configNN);\n '+
'facedet.setResultCallback(FDPostProcess);\n '+
'facedet.modelSelect(FACE_DETECTION, NA_MODEL, '+model+', NA_MODEL);\n '+
'facedet.begin();\n '+
'videoStreamer.registerInput(Camera.getStream(amb82_CHANNEL));\n '+
'videoStreamer.registerOutput(rtsp);\n '+
'if (videoStreamer.begin() != 0) {\n '+
' Serial.println("StreamIO link start failed");\n '+
'}\n '+
'Camera.channelBegin(amb82_CHANNEL);\n '+
'videoStreamerNN.registerInput(Camera.getStream(CHANNELNN));\n '+
'videoStreamerNN.setStackSize();\n '+
'videoStreamerNN.setTaskPriority();\n '+
'videoStreamerNN.registerOutput(facedet);\n '+
'if (videoStreamerNN.begin() != 0) {\n '+
' Serial.println("StreamIO link start failed");\n '+
'}\n '+
'Camera.channelBegin(CHANNELNN);\n '+
'OSD.configVideo(amb82_CHANNEL, config);\n '+
'OSD.begin();\n';

return "";
};

Blockly.Arduino['amb82_mini_facedetection_rtsp_count'] = function(block) {
var code = 'facedet.getResultCount()';
return [code, Blockly.Arduino.ORDER_NONE];
};

Blockly.Arduino['amb82_mini_facedetection_rtsp_rect'] = function(block) {
var property = block.getFieldValue('property');
if (property == "OBJECT")
var code = 'String(item.name())';
else if (property == "SCORE")
var code = 'item.score()';
else if (property == "X")
var code = 'xmin';
else if (property == "Y")
var code = 'ymin';
else if (property == "XM")
var code = 'int((xmin+xmax)/2)';
else if (property == "YM")
var code = 'int((ymin+ymax)/2)';
else if (property == "X1")
var code = 'xmax';
else if (property == "Y1")
var code = 'ymax';
else if (property == "WIDTH")
var code = '(xmax-xmin)';
else if (property == "HEIGHT")
var code = '(ymax-ymin)';
return [code, Blockly.Arduino.ORDER_NONE];
};

Blockly.Arduino['amb82_mini_facedetection_rtsp_point'] = function(block) {
var index = block.getFieldValue('index');
var property = block.getFieldValue('property');
if (property == "X")
var code = '(int)(item.xFeature('+index+') * im_w);';
else if (property == "Y")
var code = '(int)(item.yFeature('+index+') * im_h)';
return [code, Blockly.Arduino.ORDER_NONE];
};












Blockly.Arduino['RC522_initial'] = function(block) {
var keya = Blockly.Arduino.valueToCode(block, 'keya', Blockly.Arduino.ORDER_ATOMIC)||"0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF";
var keyb = Blockly.Arduino.valueToCode(block, 'keyb', Blockly.Arduino.ORDER_ATOMIC)||"0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF";
Expand Down
117 changes: 116 additions & 1 deletion LinkIt7697/France/toolbox.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2834,7 +2834,122 @@
</block>
</category>
<category id="france23" name="amb82_mini_FaceDetection">

<block type="amb82_mini_facedetection_rtsp">
</block>
<block type="amb82_mini_facedetection_rtsp_rect">
</block>
<block type="amb82_mini_facedetection_rtsp_count">
</block>
<block type="amb82_mini_facedetection_rtsp_point">
</block>
<block type="amb82_mini_drawline">
<value name="x">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<value name="y">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<value name="x1">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<value name="y1">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<value name="linewidth">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<value name="alpha">
<block type="math_number">
<field name="NUM">255</field>
</block>
</value>
</block>
<block type="amb82_mini_drawpoint">
<value name="x">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<value name="y">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<value name="pointwidth">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<value name="alpha">
<block type="math_number">
<field name="NUM">255</field>
</block>
</value>
</block>
<block type="amb82_mini_drawrect">
<value name="x">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<value name="y">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<value name="x1">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<value name="y1">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<value name="linewidth">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<value name="alpha">
<block type="math_number">
<field name="NUM">255</field>
</block>
</value>
</block>
<block type="amb82_mini_drawtext">
<value name="x">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<value name="y">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<value name="txt">
<block type="text">
<field name="TEXT"></field>
</block>
</value>
<value name="alpha">
<block type="math_number">
<field name="NUM">255</field>
</block>
</value>
</block>
</category>
<category id="france23" name="amb82_mini_FaceRecognition">

Expand Down
Loading

0 comments on commit 7f84a7c

Please sign in to comment.