This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double _euclideanDistance(List e1, List e2) { | |
double sum = 0.0; | |
for (int i = 0; i < e1.length; i++) { | |
sum += pow((e1[i] - e2[i]), 2); | |
} | |
return sqrt(sum); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_cameraService.cameraController.startImageStream((image) async { | |
... | |
try { | |
/// returns a list of faces, but for our propose we just need the first one detected | |
List<Face> faces = await _mlVisionService.getFacesFromImage(image); | |
... | |
} catch (e) { | |
... | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setCurrentPrediction(CameraImage cameraImage, Face face) { | |
/// crops the face from the image and transforms it to an array of data | |
List input = _preProcess(cameraImage, face); | |
/// then reshapes input and ouput to model format 🧑🔧 | |
input = input.reshape([1, 112, 112, 3]); | |
List output = List(1 * 192).reshape([1, 192]); | |
/// runs the interpreter and produces the output 🤖 | |
this._interpreter.run(input, output); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example object result | |
{ | |
"score": 0.32371445304906, | |
"keypoints": [ | |
... | |
{ | |
"position": { | |
"y": 113.9603729248, | |
"x": 393.19735717773 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// right and left wrists are the objects given by the model | |
const rx = rightWrist.position.x; | |
const ry = rightWrist.position.y; | |
const lx = leftWrist.position.x; | |
const ly = leftWrist.position.y; | |
// vertical and horizontal distance | |
var dy = ly - ry; | |
var dx = lx - rx; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// calculate angle | |
let angle = 0.0; | |
angle = angleBetween(wrists); | |
// right condition | |
if(angle < -25) { | |
turnRight(); | |
toRight = true; | |
toLeft = false; | |
} else if(toRight) { |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var startGame = () => { | |
var options = { | |
arena: { | |
arena: mk.arenas.types.THRONE_ROOM | |
}, | |
fighters: [{ name: 'Subzero' }, { name: 'Kano' }], | |
gameType: 'multiplayer' | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var getState = function (index) { | |
var me = mk.game.fighters[index] | |
// 0 === false and 1 === true in js conditionals | |
var opponent = index ? mk.game.fighters[0] : mk.game.fighters[1]; | |
var myLife = me._life; | |
var opponentLife = opponent._life; | |
var myPosition = me._position; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
subzeroActions = { | |
RIGHT: 39, // right arrow | |
LEFT : 37, // left arrow | |
UP : 38, // up arrow | |
DOWN : 40, // down arrow | |
BLOCK: 81, // Q | |
HP : 65, // A | |
LP : 83, // S | |
LK : 68, // D | |
HK : 70 // F |