Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
KEYMORPH=e8228c7fa5a635e3e3de90ec8872c717bbedaa641d00
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Local Netlify folder
.netlify
47 changes: 12 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 35 additions & 25 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useRef } from "react";
import { useExternalScript } from "./helpers/ai-sdk/externalScriptsLoader";
import { getAiSdkControls } from "./helpers/ai-sdk/loader";

import './App.css';
import "./App.css";

import GenderComponent from "./components/GenderComponent";
import AgeComponent from "./components/AgeComponent";
Expand All @@ -14,50 +14,60 @@ import MoodComponent from "./components/MoodComponent";
import EmotionBarsComponent from "./components/EmotionBarsComponent";

function App() {

const mphToolsState = useExternalScript("https://sdk.morphcast.com/mphtools/v1.0/mphtools.js");
const aiSdkState = useExternalScript("https://ai-sdk.morphcast.com/v1.16/ai-sdk.js");
const videoEl = useRef(undefined)
const mphToolsState = useExternalScript(
"https://sdk.morphcast.com/mphtools/v1.0/mphtools.js"
);
const aiSdkState = useExternalScript(
"https://ai-sdk.morphcast.com/v1.16/ai-sdk.js"
);
const videoEl = useRef(undefined);

useEffect(() => {
videoEl.current = document.getElementById("videoEl");
async function getAiSdk (){
if(aiSdkState === "ready" && mphToolsState === "ready"){
async function getAiSdk() {
if (aiSdkState === "ready" && mphToolsState === "ready") {
const { source, start } = await getAiSdkControls();
await source.useCamera({
toVideoElement: document.getElementById("videoEl"),
});
await source.useCamera({
toVideoElement: document.getElementById("videoEl"),
});
await start();

}

}
getAiSdk();
}, [aiSdkState, mphToolsState]);

return (
<div className="App">
<header className="App-header">
<div style={{display:"flex", flexDirection: "column", alignItems:"center"}}>
<div style={{width:"640px", height: "480px", position:"relative"}}>
<video id="videoEl"></video>
<FaceTrackerComponent videoEl={videoEl}></FaceTrackerComponent>
<div
style={{
display: "flex",
flexDirection: "column",
alignItems: "center",
}}
>
<div>
<div
style={{ width: "640px", height: "480px", position: "relative",textAlign:"left" }}
>
<video id="videoEl"></video>
<FaceTrackerComponent videoEl={videoEl}></FaceTrackerComponent>
</div>
<EmotionBarsComponent></EmotionBarsComponent>
</div>
<GenderComponent></GenderComponent>
<hr className="solid" style={{width:"100%"}}></hr>
<hr className="solid" style={{ width: "100%" }}></hr>
<DominantEmotionComponent></DominantEmotionComponent>
<hr className="solid" style={{width:"100%"}}></hr>
<hr className="solid" style={{ width: "100%" }}></hr>
<AgeComponent></AgeComponent>
<hr className="solid" style={{width:"100%"}}></hr>
<hr className="solid" style={{ width: "100%" }}></hr>
<FeatureComponent></FeatureComponent>
<hr className="solid" style={{width:"100%"}}></hr>
<hr className="solid" style={{ width: "100%" }}></hr>
<EngagementComponent></EngagementComponent>
<hr className="solid" style={{width:"100%"}}></hr>
<hr className="solid" style={{ width: "100%" }}></hr>
<MoodComponent></MoodComponent>
<hr className="solid" style={{width:"100%"}}></hr>
<EmotionBarsComponent></EmotionBarsComponent>
<hr className="solid" style={{width:"100%"}}></hr>

<hr className="solid" style={{ width: "100%" }}></hr>
<hr className="solid" style={{ width: "100%" }}></hr>
</div>
</header>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/ai-sdk/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ async function initAiSdk() {
throw new Error("An instance of the AI-SDK is already running.");
}
source = new Source();
console.log(process.env.KEYMORPH)

aiSdkInstance = await globalThis.CY.loader()
// TODO INSERT YOUR LICENSE KEY HERE
.licenseKey("insert-here-your-license-key") // <--- ##############
.licenseKey("e8228c7fa5a635e3e3de90ec8872c717bbedaa641d00") // <--- ##############
.source(source)
.addModule(globalThis.CY.modules().FACE_DETECTOR.name)
.addModule(globalThis.CY.modules().FACE_EMOTION.name, {
Expand Down