diff --git a/applications/emocam/emocam1.js b/applications/emocam/emocam1.js
index d1afc94..3183c60 100644
--- a/applications/emocam/emocam1.js
+++ b/applications/emocam/emocam1.js
@@ -12,12 +12,11 @@
//
-
-(function() {
+(function () {
var jsMainFileName = "emocam1.js";
var ROOT = Script.resolvePath('').split(jsMainFileName)[0];
var channel = "org.overte.application.emocam";
-
+
var TABLET_BUTTON_NAME = "EMOTIONS";
var TRANSITION_TIME_SECONDS = 0.25;
var onEmoteScreen = false;
@@ -26,7 +25,7 @@
var icon = "face.png";
var activeIcon = "face.png";
var isActive = true;
- var EMOTE_APP_BASE = "index.html?"+Date.now();
+ var EMOTE_APP_BASE = "index.html?" + Date.now();
var EMOTE_APP_URL = Script.resolvePath(EMOTE_APP_BASE);
var EMOTE_APP_SORT_ORDER = 12;
var EMOTE_LABEL = "FACE";
@@ -59,14 +58,22 @@
function onScreenChanged(type, url) {
onEmoteScreen = type === "Web" && (url.indexOf(EMOTE_APP_BASE) === url.length - EMOTE_APP_BASE.length);
- button.editProperties({ isActive: onEmoteScreen });
+ button.editProperties({isActive: onEmoteScreen});
}
var mapping = Controller.newMapping();
- var yawBinding = mapping.from(function() { return yawValue; }).to(Controller.Actions.DeltaYaw);
- var pitchBinding = mapping.from(function() { return pitchValue; }).to(Controller.Actions.DeltaPitch);
- var forwardBinding = mapping.from(function() { return forwardValue; }).to(Controller.Actions.TranslateZ);
- var sideBinding = mapping.from(function() { return sideValue; }).to(Controller.Actions.TranslateX);
+ var yawBinding = mapping.from(function () {
+ return yawValue;
+ }).to(Controller.Actions.DeltaYaw);
+ var pitchBinding = mapping.from(function () {
+ return pitchValue;
+ }).to(Controller.Actions.DeltaPitch);
+ var forwardBinding = mapping.from(function () {
+ return forwardValue;
+ }).to(Controller.Actions.TranslateZ);
+ var sideBinding = mapping.from(function () {
+ return sideValue;
+ }).to(Controller.Actions.TranslateX);
mapping.enable();
var propList = ["headRotation", "headType"];
@@ -86,103 +93,103 @@
var parsed = JSON.parse(event);
if (parsed.channel === channel) {
- if (parsed.type === "tracking" || parsed.type === "trackingmotion"){
+ if (parsed.type === "tracking" || parsed.type === "trackingmotion") {
var emotion = parsed.data;
MyAvatar.hasScriptedBlendshapes = true;
- var bend ={
- "EyeOpen_L": emotion["eyeWideLeft"]*4,
- "EyeOpen_R": emotion["eyeWideRight"]*4,
- "EyeBlink_L": emotion["eyeBlinkLeft"],
- "EyeBlink_R": emotion["eyeBlinkRight"],
- "EyeSquint_L": emotion["eyeSquintLeft"],
- "EyeSquint_R": emotion["eyeSquintRight"],
- "BrowsD_L": emotion["browDownLeft"],
- "BrowsD_R": emotion["browDownRight"],
- "BrowsU_C": emotion["browInnerUp"],
- "BrowsU_L": emotion["browOuterUpLeft"],
- "BrowsU_R": emotion["browOuterUpRight"],
- "JawOpen": emotion["jawOpen"],
- "MouthOpen": emotion["jawOpen"],
- "JawFwd": emotion["jawForward"],
- "MouthFrown_L": emotion["mouthFrownLeft"],
- "MouthFrown_R": emotion["mouthFrownRight"],
- "MouthSmile_L": emotion["mouthSmileLeft"]*0.8,
- "MouthSmile_R": emotion["mouthSmileRight"]*0.8,
- "MouthDimple_L": emotion["mouthStretchLeft"],
- "MouthDimple_R": emotion["mouthStretchRight"],
- "NoseSneer_L": emotion["noseSneerLeft"],
- "NoseSneer_R": emotion["noseSneerRight"],
- "Puff": emotion["cheekPuff"]*1.3,
- "CheekSquint_L": emotion["cheekSquintLeft"],
- "CheekSquint_R": emotion["cheekSquintRight"],
- "EyeDown_L": emotion["eyeLookDownLeft"]*1.2,
- "EyeDown_R": emotion["eyeLookDownRight"]*1.2,
- "EyeIn_L": emotion["eyeLookInLeft"],
- "EyeIn_R": emotion["eyeLookInRight"],
- "EyeOut_L": emotion["eyeLookOutLeft"],
- "EyeOut_R": emotion["eyeLookOutRight"],
- "EyeUp_L": emotion["eyeLookUpLeft"],
- "EyeUp_R": emotion["eyeLookUpRight"],
- "EyeSquint_L": emotion["eyeSquintLeft"],
- "EyeSquint_R": emotion["eyeSquintRight"],
- "TongueOut": emotion["jawForward"],
- "JawLeft": emotion["jawLeft"]*3,
- "JawRight": emotion["jawRight"]*3,
- "MouthClose": emotion["mouthClose"],
- "MouthDimple_L": emotion["mouthDimpleLeft"],
- "MouthDimple_R": emotion["mouthDimpleRight"],
- "LipsFunnel": emotion["mouthFunnel"],
- "MouthLeft": emotion["mouthLeft"],
- "MouthLowerDown_L": emotion["mouthLowerDownLeft"],
- "MouthLowerDown_R": emotion["mouthLowerDownRight"],
- "MouthPress_L": emotion["mouthPressLeft"],
- "MouthPress_L": emotion["mouthPressRight"],
- "LipsPucker": emotion["mouthPucker"],
- "MouthRight": emotion["mouthRight"],
- "MouthRollLower": emotion["mouthRollLower"],
- "MouthRollUpper": emotion["mouthRollUpper"],
- "MouthShrugLower": emotion["mouthShrugLower"],
- "MouthShrugUpper": emotion["mouthShrugUpper"],
- "MouthUpperUp_L": emotion["mouthUpperUpLeft"],
- "MouthUpperUp_R": emotion["mouthUpperUpRight"]
+ var bend = {
+ "EyeOpen_L": emotion["eyeWideLeft"] * 4,
+ "EyeOpen_R": emotion["eyeWideRight"] * 4,
+ "EyeBlink_L": emotion["eyeBlinkLeft"],
+ "EyeBlink_R": emotion["eyeBlinkRight"],
+ "EyeSquint_L": emotion["eyeSquintLeft"],
+ "EyeSquint_R": emotion["eyeSquintRight"],
+ "BrowsD_L": emotion["browDownLeft"],
+ "BrowsD_R": emotion["browDownRight"],
+ "BrowsU_C": emotion["browInnerUp"],
+ "BrowsU_L": emotion["browOuterUpLeft"],
+ "BrowsU_R": emotion["browOuterUpRight"],
+ "JawOpen": emotion["jawOpen"],
+ "MouthOpen": emotion["jawOpen"],
+ "JawFwd": emotion["jawForward"],
+ "MouthFrown_L": emotion["mouthFrownLeft"],
+ "MouthFrown_R": emotion["mouthFrownRight"],
+ "MouthSmile_L": emotion["mouthSmileLeft"] * 0.8,
+ "MouthSmile_R": emotion["mouthSmileRight"] * 0.8,
+ "MouthDimple_L": emotion["mouthStretchLeft"],
+ "MouthDimple_R": emotion["mouthStretchRight"],
+ "NoseSneer_L": emotion["noseSneerLeft"],
+ "NoseSneer_R": emotion["noseSneerRight"],
+ "Puff": emotion["cheekPuff"] * 1.3,
+ "CheekSquint_L": emotion["cheekSquintLeft"],
+ "CheekSquint_R": emotion["cheekSquintRight"],
+ "EyeDown_L": emotion["eyeLookDownLeft"] * 1.2,
+ "EyeDown_R": emotion["eyeLookDownRight"] * 1.2,
+ "EyeIn_L": emotion["eyeLookInLeft"],
+ "EyeIn_R": emotion["eyeLookInRight"],
+ "EyeOut_L": emotion["eyeLookOutLeft"],
+ "EyeOut_R": emotion["eyeLookOutRight"],
+ "EyeUp_L": emotion["eyeLookUpLeft"],
+ "EyeUp_R": emotion["eyeLookUpRight"],
+ "EyeSquint_L": emotion["eyeSquintLeft"],
+ "EyeSquint_R": emotion["eyeSquintRight"],
+ "TongueOut": emotion["jawForward"],
+ "JawLeft": emotion["jawLeft"] * 3,
+ "JawRight": emotion["jawRight"] * 3,
+ "MouthClose": emotion["mouthClose"],
+ "MouthDimple_L": emotion["mouthDimpleLeft"],
+ "MouthDimple_R": emotion["mouthDimpleRight"],
+ "LipsFunnel": emotion["mouthFunnel"],
+ "MouthLeft": emotion["mouthLeft"],
+ "MouthLowerDown_L": emotion["mouthLowerDownLeft"],
+ "MouthLowerDown_R": emotion["mouthLowerDownRight"],
+ "MouthPress_L": emotion["mouthPressLeft"],
+ "MouthPress_L": emotion["mouthPressRight"],
+ "LipsPucker": emotion["mouthPucker"],
+ "MouthRight": emotion["mouthRight"],
+ "MouthRollLower": emotion["mouthRollLower"],
+ "MouthRollUpper": emotion["mouthRollUpper"],
+ "MouthShrugLower": emotion["mouthShrugLower"],
+ "MouthShrugUpper": emotion["mouthShrugUpper"],
+ "MouthUpperUp_L": emotion["mouthUpperUpLeft"],
+ "MouthUpperUp_R": emotion["mouthUpperUpRight"]
};
- if (parsed.type === "trackingmotion"){
- print("pitch: "+ parsed.pitch + "yaw: " +parsed.yaw);
- if (parsed.pitch <= -15 || parsed.pitch >= 5){
+ if (parsed.type === "trackingmotion") {
+ print("pitch: " + parsed.pitch + "yaw: " + parsed.yaw);
+ if (parsed.pitch <= -15 || parsed.pitch >= 5) {
forwardValue = 0;
- yawValue = 0;
- if (parsed.pitch > 5){
+ yawValue = 0;
+ if (parsed.pitch > 5) {
pitchValue = 0.3;
}
- if (parsed.pitch < -15){
- pitchValue = -0.3;
- }
- if (parsed.pitch >= -15 && parsed.pitch <= 5){
+ if (parsed.pitch < -15) {
+ pitchValue = -0.3;
+ }
+ if (parsed.pitch >= -15 && parsed.pitch <= 5) {
pitchValue = 0;
}
} else {
pitchValue = 0;
- if (parsed.yaw <= - 10 || parsed.yaw >= 10){
+ if (parsed.yaw <= -10 || parsed.yaw >= 10) {
forwardValue = 0;
-
- if (parsed.yaw > 10){
- yawValue = parsed.yaw /20;
+
+ if (parsed.yaw > 10) {
+ yawValue = parsed.yaw / 20;
}
- if (parsed.yaw < -10){
- yawValue = parsed.yaw /20;
- }
- if (parsed.yaw >= - 10 && parsed.yaw <= 10){
+ if (parsed.yaw < -10) {
+ yawValue = parsed.yaw / 20;
+ }
+ if (parsed.yaw >= -10 && parsed.yaw <= 10) {
yawValue = 0;
}
} else {
- yawValue = 0;
- if (emotion["browInnerUp"]>0.1){
+ yawValue = 0;
+ if (emotion["browInnerUp"] > 0.1) {
forwardValue = -1;
}
- if (emotion["browDownLeft"]>0.4){
+ if (emotion["browDownLeft"] > 0.4) {
forwardValue = 1;
}
- if (emotion["browInnerUp"] <= 0.1 && emotion["browDownLeft"] <= 0.4){
+ if (emotion["browInnerUp"] <= 0.1 && emotion["browDownLeft"] <= 0.4) {
forwardValue = 0;
}
}
@@ -199,6 +206,7 @@
}
}
}
+
function setEmotion(currentEmotion) {
if (emotion !== lastEmotionUsed) {
lastEmotionUsed = emotion;
@@ -229,6 +237,6 @@
}
MyAvatar.restoreAnimation();
- mapping.disable();
+ mapping.disable();
});
}());
diff --git a/applications/emocam/index.html b/applications/emocam/index.html
index 2577d29..2323db2 100644
--- a/applications/emocam/index.html
+++ b/applications/emocam/index.html
@@ -13,904 +13,924 @@
-->
-
-
-
- MediaPipe Face Landmarker
-
+ .switch {
+ position: relative;
+ display: inline-block;
+ width: 60px;
+ height: 34px;
+ }
-
+ /* Hide default HTML checkbox */
+ .switch input {
+ opacity: 0;
+ width: 0;
+ height: 0;
+ }
+
+ /* The slider */
+ .slider {
+ position: absolute;
+ cursor: pointer;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background-color: #ccc;
+ -webkit-transition: .4s;
+ transition: .4s;
+ }
+
+ .slider:before {
+ position: absolute;
+ content: "";
+ height: 26px;
+ width: 26px;
+ left: 4px;
+ bottom: 4px;
+ background-color: white;
+ -webkit-transition: .4s;
+ transition: .4s;
+ }
+
+ input:checked + .slider {
+ background-color: #007db8;
+ }
+
+ input:focus + .slider {
+ box-shadow: 0 0 1px #007db8;
+ }
+
+ input:checked + .slider:before {
+ -webkit-transform: translateX(26px);
+ -ms-transform: translateX(26px);
+ transform: translateX(26px);
+ }
+
+ /* Rounded sliders */
+ .slider.round {
+ border-radius: 34px;
+ }
+
+ .slider.round:before {
+ border-radius: 50%;
+ }
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
- Increase
- Decrease
-
+
+
+ Increase
+ Decrease
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
+ function applyLandmarksMapping(values) {
+ // Object to hold the mapped values
+ var mappedValues = {};
+
+ // Loop through each key-value pair in the provided JSON object
+ for (var landmark in values) {
+ // Skip the neutral landmark
+ if (landmark === "_neutral") {
+ continue;
+ }
+ if (values.hasOwnProperty(landmark)) {
+ // Check if there is a mapping for this landmark
+ if (landmarkMappings.hasOwnProperty(landmark)) {
+ // Apply the mapping
+ var value = values[landmark];
+ value *= 100;
+ var mapping = landmarkMappings[landmark];
+ var mappedValue = monotoneCubicSplineInterpolation(mapping.x_data, mapping.y_data_1)(value);
+ mappedValue /= 100;
+
+ // Store the mapped value
+ mappedValues[landmark] = mappedValue;
+ }
+ }
+ }
+
+ return mappedValues;
+ }
+
+
+
-
+