123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521 |
- /**
- * @license
- * Visual Blocks Editor
- *
- * Copyright 2012 Google Inc.
- * https://developers.google.com/blockly/
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- /**
- * @fileoverview Colour blocks for Blockly.
- * @author fraser@google.com (Neil Fraser)
- */
- 'use strict';
- goog.provide('Blockly.Blocks.visionkit');
- goog.require('Blockly.Blocks');
- /**
- * Common HSV hue for all blocks in this category.
- */
- Blockly.Blocks.visionkit.HUE = "#2c4fc9";
- Blockly.Blocks['visionkit_setup'] = {
- /**
- * Block for log setup.
- * @this Blockly.Block
- */
- init: function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendDummyInput()
- // .appendField(new Blockly.FieldImage("./../blockly/media/google_aiy_vision_kit_setup_header.png", 140, 60, "0"));
- .appendField(new Blockly.FieldImage("./blockly/media/google_aiy_vision_kit_setup.png", 140, 60, "0"));//staging
- this.appendDummyInput()
- .appendField(Blockly.Msg.VISIONKIT_SETUP);
- // this.setInputsInline(false);
- // this.setOutput(true);
- // this.setPreviousStatement(true);
- // this.setNextStatement(true);
- },
- };
- Blockly.Blocks['visionkit_demo'] = {
- /**
- * Block for log setup.
- * @this Blockly.Block
- */
- init: function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendDummyInput()
- // .appendField(new Blockly.FieldImage("./../blockly/media/google_aiy_vision_kit_setup_header.png", 140, 60, "0"));
- .appendField(new Blockly.FieldImage("./blockly/media/google_aiy_vision_joy_demo.png", 140, 60, "0"));//staging
- this.appendDummyInput()
- .appendField(Blockly.Msg.VISIONKIT_JOY_DETECT);
- this.appendDummyInput()
- .appendField(Blockly.Msg.VISIONKIT_CLOUDEVENT_API)
- .appendField(new Blockly.FieldTextInput("yourCloudEventAPI"),"API")
- // this.setInputsInline(false);
- // this.setOutput(true);
- // this.setPreviousStatement(true);
- // this.setNextStatement(true);
- },
- };
- /*
- * vision kit
- * import block from
- */
- Blockly.Blocks['visionkit_import'] = {
- /**
- * Block for import.
- * @this Blockly.Block
- */
- init: function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendValueInput("IMPORT")
- .appendField(Blockly.Msg.VISIONKIT_IMPORT)
- .appendField(new Blockly.FieldDropdown([
- ["AIY.Vision.Inference","aiy.vision.inference"],
- ["AIY.Vision.Models","aiy.vision.models"],
- ["AIY.Vision.Annotator","aiy.vision.annotator"]
- ]), "FROM")
- // this.setInputsInline(false);
- // this.setOutput(true);
- this.setPreviousStatement(true);
- this.setNextStatement(true);
- },
- };
- /*
- * vision kit
- * import block annotator
- */
- Blockly.Blocks['visionkit_import_annotator'] = {
- /**
- * Block for import.
- * @this Blockly.Block
- */
- init: function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendDummyInput()
- .appendField(Blockly.Msg.VISIONKIT_IMPORT_ANNOTATOR)
- .appendField(new Blockly.FieldDropdown([
- ["Annotator","Annotator"]
- ]), "IMPORT")
- // this.setInputsInline(false);
- this.setOutput(true);
- // this.setPreviousStatement(true);
- // this.setNextStatement(true);
- },
- };
- /*
- * vision kit
- * import block models
- */
- Blockly.Blocks['visionkit_import_models'] = {
- /**
- * Block for import.
- * @this Blockly.Block
- */
- init: function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendDummyInput()
- .appendField(Blockly.Msg.VISIONKIT_IMPORT_MODELS)
- .appendField(new Blockly.FieldDropdown([
- ["Face Detection","face_detection"]
- ]), "IMPORT")
- // this.setInputsInline(false);
- this.setOutput(true);
- // this.setPreviousStatement(true);
- // this.setNextStatement(true);
- },
- };
- /*
- * vision kit
- * import block inference
- */
- Blockly.Blocks['visionkit_import_inference'] = {
- /**
- * Block for import.
- * @this Blockly.Block
- */
- init: function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendDummyInput()
- .appendField(Blockly.Msg.VISIONKIT_IMPORT_INFERENCE)
- .appendField(new Blockly.FieldDropdown([
- ["Camera Inference","CameraInference"]
- ]), "IMPORT")
- // this.setInputsInline(false);
- this.setOutput(true);
- // this.setPreviousStatement(true);
- // this.setNextStatement(true);
- },
- };
- /*
- * vision kit
- * camera inference block
- */
- Blockly.Blocks['visionkit_cameraInference'] = {
- /**
- * Block for import.
- * @this Blockly.Block
- */
- init: function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendDummyInput()
- .appendField(Blockly.Msg.VISIONKIT_AIY_VISION_INFERENCE)
- this.appendDummyInput()
- .appendField(Blockly.Msg.VISIONKIT_CAMERA_INFERENCE)
- .appendField(new Blockly.FieldTextInput("inference"),"INFERENCE")
- this.appendDummyInput()
- .appendField(Blockly.Msg.VISIONKIT_USE_MODEL)
- .appendField(new Blockly.FieldDropdown([
- ["Face Detection","face_detection.model()"]
- ]), "USEMODEL")
- this.appendStatementInput("STACK")
- .appendField(Blockly.Msg.VISIONKIT_DO)
- // this.setInputsInline(false);
- // this.setOutput(true);
- this.setPreviousStatement(true);
- this.setNextStatement(true);
- },
- };
- /*
- * vision kit
- * run inference block
- */
- Blockly.Blocks['visionkit_runInference'] = {
- /**
- * Block for import.
- * @this Blockly.Block
- */
- init: function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendValueInput("INPUT")
- .appendField(Blockly.Msg.VISIONKIT_RUN_INFERENCE)
- this.setInputsInline(true);
- this.setOutput(true);
- // this.setPreviousStatement(true);
- // this.setNextStatement(true);
- },
- };
- /*
- * vision kit
- * get inference block
- */
- Blockly.Blocks['visionkit_GetInference'] = {
- /**
- * Block for import.
- * @this Blockly.Block
- */
- init: function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendDummyInput()
- .appendField(Blockly.Msg.VISIONKIT_GETINFERENCE)
- .appendField(new Blockly.FieldDropdown([
- ["Count","count"],
- ["Rate","rate"]
- ]),"INFERENCE")
- // this.setInputsInline(true);
- this.setOutput(true);
- // this.setPreviousStatement(true);
- // this.setNextStatement(true);
- },
- };
- /*
- * vision kit
- * get inference block
- */
- Blockly.Blocks['visionkit_faceDetection_operation'] = {
- /**
- * Block for import.
- * @this Blockly.Block
- */
- init: function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendValueInput("INPUT")
- .appendField(Blockly.Msg.VISIONKIT_IMPORT)
- .appendField(new Blockly.FieldDropdown([
- ["Face Detection","face_detection"]
- ]),"MODEL")
- .appendField(Blockly.Msg.VISISONKIT_MODEL)
- .appendField(new Blockly.FieldDropdown([
- ["Get Faces","get_faces"]
- ]),"OPERATION")
- // this.setInputsInline(true);
- this.setOutput(true);
- // this.setPreviousStatement(true);
- // this.setNextStatement(true);
- },
- };
- /*
- * vision kit
- * get model block
- */
- Blockly.Blocks['visionkit_model_get'] = {
- /**
- * Block for import.
- * @this Blockly.Block
- */
- init: function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendValueInput("INPUT")
- .appendField(Blockly.Msg.VISIONKIT_GETMODEL_MODEL)
- .appendField(new Blockly.FieldDropdown([
- ["Bounding Box","bounding_box"],
- ["Joy Score","joy_score"]
- ]),"MODEL")
- .appendField(Blockly.Msg.VISIONKIT_GETMODEL_OF)
- this.setInputsInline(true);
- this.setOutput(true);
- // this.setPreviousStatement(true);
- // this.setNextStatement(true);
- },
- };
- /*
- * vision kit
- * Use Annotator block
- */
- Blockly.Blocks['visionkit_Use_Annotator'] = {
- /**
- * Block for import.
- * @this Blockly.Block
- */
- init: function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendDummyInput()
- .appendField(Blockly.Msg.VISIONKIT_ANNOTATOR)
- .appendField(new Blockly.FieldTextInput("camera"),"ANNOTATOR")
- .appendField(Blockly.Msg.VISIONKIT_ANNOTATOR_SETTING)
- .appendField(new Blockly.FieldTextInput("320"),"X-DIMEN")
- .appendField(",")
- .appendField(new Blockly.FieldTextInput("240"),"Y-DIMEN")
- // this.setInputsInline(true);
- // this.setOutput(true);
- this.setPreviousStatement(true);
- this.setNextStatement(true);
- },
- };
- Blockly.Blocks['visionkit_Use_Annotator_output'] = {
- /**
- * Block for import.
- * @this Blockly.Block
- */
- init: function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendDummyInput()
- .appendField(Blockly.Msg.VISIONKIT_ANNOTATOR)
- .appendField(new Blockly.FieldTextInput("camera"),"ANNOTATOR")
- .appendField(Blockly.Msg.VISIONKIT_ANNOTATOR_SETTING)
- .appendField(new Blockly.FieldTextInput("320"),"X-DIMEN")
- .appendField(",")
- .appendField(new Blockly.FieldTextInput("240"),"Y-DIMEN")
- // this.setInputsInline(true);
- this.setOutput(true);
- // this.setPreviousStatement(true);
- // this.setNextStatement(true);
- },
- };
- /*
- * vision kit
- * Annotator clear/update block
- */
- Blockly.Blocks['visionkit_Annotator_operation'] = {
- /**
- * Block for import.
- * @this Blockly.Block
- */
- init: function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendDummyInput()
- .appendField(Blockly.Msg.VISIONKIT_ANNOTATOR)
- .appendField(new Blockly.FieldDropdown([
- ["Clear","clear"],
- ["Update","update"]
- ]),"OPERATION")
- // this.setInputsInline(true);
- // this.setOutput(true);
- this.setPreviousStatement(true);
- this.setNextStatement(true);
- },
- };
- /*
- * vision kit
- * Annotator Bounding block
- */
- Blockly.Blocks['visionkit_Annotator_Bounding'] = {
- /**
- * Block for import.
- * @this Blockly.Block
- */
- init: function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendDummyInput()
- .appendField(Blockly.Msg.VISIONKIT_ANNOTATOR_BOUNDING)
- this.appendValueInput("INPUT")
- .appendField(Blockly.Msg.VISIONKIT_ANNOTATOR_FILL)
- .appendField(new Blockly.FieldNumber("1"),"FILL")
- // this.setInputsInline(true);
- // this.setOutput(true);
- this.setPreviousStatement(true);
- this.setNextStatement(true);
- },
- };
- Blockly.Blocks['visionkit_myAssistant'] = {
- /**
- * Block for import.
- * @this Blockly.Block
- */
- init: function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendDummyInput()
- .appendField("MyAssistant")
- // this.setInputsInline(true);
- this.setOutput(true);
- // this.setPreviousStatement(true);
- // this.setNextStatement(true);
- },
- }
- /************************************
- * Simplify *
- *************************************/
- Blockly.Blocks['visionkit_import_aiy'] = {
- /**
- * Block for import.
- * @this Blockly.Block
- */
- init: function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendDummyInput()
- .appendField("import AIY Vision Kit Modules")
- // this.appendValueInput("INPUT")
- // .appendField("faces")
- // this.setInputsInline(true);
- this.setPreviousStatement(true);
- this.setNextStatement(true);
- },
- }
- Blockly.Blocks['visionkit_avg_joy_score'] = {
- /**
- * Block for import.
- * @this Blockly.Block
- */
- init: function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendDummyInput()
- .appendField("Define Average Joy Score Demo")
- // this.appendValueInput("INPUT")
- // .appendField("faces")
- // this.setInputsInline(true);
- this.setPreviousStatement(true);
- this.setNextStatement(true);
- },
- }
- Blockly.Blocks['visionkit_annotator_camera'] = {
- init:function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendDummyInput()
- .appendField("Annotator(camera,dimensions=(")
- .appendField(new Blockly.FieldTextInput("320"),"X")
- .appendField(",")
- .appendField(new Blockly.FieldTextInput("240"),"Y")
- .appendField(")")
- this.appendDummyInput()
- .appendField("Scale_x")
- .appendField(new Blockly.FieldTextInput("1640"),"SCALE_X")
- .appendField("Scale_y")
- .appendField(new Blockly.FieldTextInput("1232"),"SCALE_Y")
- this.setPreviousStatement(true);
- this.setNextStatement(true);
- }
- }
- Blockly.Blocks['visionkit_transform_boundingBox'] = {
- init:function() {
- this.setColour(Blockly.Blocks.visionkit.HUE);
- this.appendDummyInput()
- .appendField("Define Bounding Box Transform")
- this.setPreviousStatement(true);
- this.setNextStatement(true);
- }
- }
- Blockly.Blocks['visionkit_CameraInference'] = {
- init:function() {
- this.setColour(Blockly.Blocks.visionkit.HUE)
- this.appendDummyInput()
- // .appendField("with CameraInference as inference")
- .appendField("Camera Inference set ")
- .appendField(new Blockly.FieldDropdown([
- ["Face Detection","Face Detection"]
- ]),"SETTING")
- this.appendStatementInput("STACK")
- this.setPreviousStatement(true);
- this.setNextStatement(true);
- }
- }
- Blockly.Blocks['visionkit_avg_joy_score_num'] = {
- init:function() {
- this.setColour(Blockly.Blocks.visionkit.HUE)
- this.appendDummyInput()
- .appendField("avg_joy_score(")
- .appendField(new Blockly.FieldTextInput("faces"),"FACE")
- .appendField(")")
- this.setOutput(true);
- }
- }
- Blockly.Blocks['visionkit_face'] = {
- init:function() {
- this.setColour(Blockly.Blocks.visionkit.HUE)
- this.appendDummyInput()
- .appendField("faces")
- this.setOutput(true)
- }
- }
|