SlideShare a Scribd company logo
1 of 12
@affectiva
JavaScript SDK
Jason Radice
Overview
@affectiva
● What is the JavaScript SDK?
● How does it work under the covers?
● Quick notes on how to use it
● Demo Apps
What is the JSSDK?
@affectiva
● Emscripten compiled version of our C++ SDK
○ Output is our SDK in asm.js
● Runs completely in the browser - no server communications
● Does not require any plugins or third party JS libraries
● Analyzes an image, a sequence of frames, or a video in real-time
● In a nutshell - you pass it some image data and it returns some metrics about it
Emotions: {"joy":100, "sadness":0, "disgust":0,
"contempt":0, "anger":0, "fear":0, "surprise":2,
"valence":98, "engagement":100},
Expressions: {"smile":100, "innerBrowRaise":0,
"browRaise":0, "browFurrow":0, "noseWrinkle":0,
"upperLipRaise":5, "lipCornerDepressor":0,
"chinRaise":0, "lipPucker":0, "lipPress":0,
"lipSuck":0, "mouthOpen":100, "smirk":0,
"eyeClosure":0, "attention":98, "lidTighten":0,
"jawDrop":0, "dimpler":0, "eyeWiden":0,
"cheekRaise":41, "lipStretch":0}
How does it work?
@affectiva
● Simply include the SDK JavaScript file in any web page
● Create a new detector instance and then start!
● Once the detector is started, it spawns a Web Worker thread
● Compiled SDK is downloaded and initialized on the worker
● Worker sends a message back to the detector once initialization is complete
● Detector will trigger the "onInitializeSuccess" event
<script src="https://download.affectiva.com/js/3.1/affdex.js"/>
var detector = new affdex.PhotoDetector();
detector.start();
detector.addEventListener("onInitializeSuccess", function() {
// now you're ready to start processing frames!
});
How to process an image
@affectiva
● Draw an image to a hidden Canvas, and pass the ImageData to the detector
● To process an image or frame, the detector posts a message to the SDK worker with
the ImageData
○ Worker thread does not have access to the DOM, so the raw image data is sent to
the SDK via postMessage()
● After processing the image data, worker will post a message to the detector with the
results
● Detector will trigger an event in your code with the results
var img = new Image();
img.onload = function() {
var context = document.createElement("canvas").getContext("2d");
context.drawImage(img, 0, 0, img.width, img.height);
var img_data = context.getImageData(0, 0, img.width, img.height);
detector.process(img_data, 0);
};
img.src = "http://example.com/some_image.jpg";
Metrics
@affectiva
● Attach an event listener to the detector and listen for onImageResultsSuccess()
● The faces object contains an array of faces found.
○ Currently, the JSSDK will only return metrics for 1 face
○ Future versions will return results for multiple faces
● Each face object will have 3 metric categories: Emotions, Expressions, Emoji
○ Feature point data is also available in the FeaturePoints category
● Get the "joy" emotion metric for the image that was just processed
● Metric value will be between 0 and 100
detector.addEventListener("onImagesResultsSuccess", function(faces, img, ts) {
// metrics are in the 'faces' object
});
var joy_value = faces[0]["emotions"]["joy"];
Demos and sample code
@affectiva
● Some simple demonstration applications on the Affectiva JSSDK Github page
○ https://github.com/Affectiva/js-sdk-sample-apps
● Detect emotions from a photo on your hard drive
○ https://jsfiddle.net/affectiva/h6p64vwg/show/
● Detect emotions from your webcam
○ https://jsfiddle.net/affectiva/opyh5e8d/show/
Photo Detector Demo
https://jsfiddle.net/affectiva/h6p64vwg/show/
@affectiva
Camera Detector Demo
https://jsfiddle.net/affectiva/opyh5e8d/show
/
@affectiva
Instagram Demo
@affectiva
Game feedback demo
https://labs.affectiva.com/jssdk-game-demo/
@affectiva
@affectiva
Emotion-enable your own apps and
digital experiences with our SDK
Get started today:
affectiva.com/SDK

More Related Content

Viewers also liked

Top 20 observation series # 7 21 CFR 211.42 (Subpart C-Buildings and Facili...
Top 20 observation series # 7   21 CFR 211.42 (Subpart C-Buildings and Facili...Top 20 observation series # 7   21 CFR 211.42 (Subpart C-Buildings and Facili...
Top 20 observation series # 7 21 CFR 211.42 (Subpart C-Buildings and Facili...Sathish Vemula
 
Age-Related Macular Degeneration
Age-Related Macular DegenerationAge-Related Macular Degeneration
Age-Related Macular DegenerationRetina Associates
 
Top 20 observation series 1 21 CFR 211.160
Top 20 observation series 1   21 CFR 211.160Top 20 observation series 1   21 CFR 211.160
Top 20 observation series 1 21 CFR 211.160Sathish Vemula
 
Top 20 observation series # 5 21 CFR 211.100
Top 20 observation series # 5   21 CFR 211.100Top 20 observation series # 5   21 CFR 211.100
Top 20 observation series # 5 21 CFR 211.100Sathish Vemula
 
Production Planning and Control
Production Planning and ControlProduction Planning and Control
Production Planning and ControlNishant Agrawal
 
Accenture’s Change Management Strategy for Workday
Accenture’s Change Management Strategy for WorkdayAccenture’s Change Management Strategy for Workday
Accenture’s Change Management Strategy for WorkdayAccenture Technology
 
Power SiC 2016: Materials, Devices, Modules, and Applications - 2016 Report b...
Power SiC 2016: Materials, Devices, Modules, and Applications - 2016 Report b...Power SiC 2016: Materials, Devices, Modules, and Applications - 2016 Report b...
Power SiC 2016: Materials, Devices, Modules, and Applications - 2016 Report b...Yole Developpement
 
Using neurodata to inform user-centered design : Dr Pierre-Majorique Léger a...
Using neurodata to inform user-centered design  : Dr Pierre-Majorique Léger a...Using neurodata to inform user-centered design  : Dr Pierre-Majorique Léger a...
Using neurodata to inform user-centered design : Dr Pierre-Majorique Léger a...Pierre-Majorique Léger
 
Automotive Lighting: Technology, Industry, and Market Trends - 2016 Report by...
Automotive Lighting: Technology, Industry, and Market Trends - 2016 Report by...Automotive Lighting: Technology, Industry, and Market Trends - 2016 Report by...
Automotive Lighting: Technology, Industry, and Market Trends - 2016 Report by...Yole Developpement
 
Electronic Control Unit(ECU)
Electronic Control Unit(ECU)Electronic Control Unit(ECU)
Electronic Control Unit(ECU)Ankul Gupta
 

Viewers also liked (12)

Top 20 observation series # 7 21 CFR 211.42 (Subpart C-Buildings and Facili...
Top 20 observation series # 7   21 CFR 211.42 (Subpart C-Buildings and Facili...Top 20 observation series # 7   21 CFR 211.42 (Subpart C-Buildings and Facili...
Top 20 observation series # 7 21 CFR 211.42 (Subpart C-Buildings and Facili...
 
Age-Related Macular Degeneration
Age-Related Macular DegenerationAge-Related Macular Degeneration
Age-Related Macular Degeneration
 
Top 20 observation series 1 21 CFR 211.160
Top 20 observation series 1   21 CFR 211.160Top 20 observation series 1   21 CFR 211.160
Top 20 observation series 1 21 CFR 211.160
 
Top 20 observation series # 5 21 CFR 211.100
Top 20 observation series # 5   21 CFR 211.100Top 20 observation series # 5   21 CFR 211.100
Top 20 observation series # 5 21 CFR 211.100
 
El show de truman
El show de trumanEl show de truman
El show de truman
 
Production Planning and Control
Production Planning and ControlProduction Planning and Control
Production Planning and Control
 
Accenture’s Change Management Strategy for Workday
Accenture’s Change Management Strategy for WorkdayAccenture’s Change Management Strategy for Workday
Accenture’s Change Management Strategy for Workday
 
Power SiC 2016: Materials, Devices, Modules, and Applications - 2016 Report b...
Power SiC 2016: Materials, Devices, Modules, and Applications - 2016 Report b...Power SiC 2016: Materials, Devices, Modules, and Applications - 2016 Report b...
Power SiC 2016: Materials, Devices, Modules, and Applications - 2016 Report b...
 
Using neurodata to inform user-centered design : Dr Pierre-Majorique Léger a...
Using neurodata to inform user-centered design  : Dr Pierre-Majorique Léger a...Using neurodata to inform user-centered design  : Dr Pierre-Majorique Léger a...
Using neurodata to inform user-centered design : Dr Pierre-Majorique Léger a...
 
Automotive Lighting: Technology, Industry, and Market Trends - 2016 Report by...
Automotive Lighting: Technology, Industry, and Market Trends - 2016 Report by...Automotive Lighting: Technology, Industry, and Market Trends - 2016 Report by...
Automotive Lighting: Technology, Industry, and Market Trends - 2016 Report by...
 
Electronic Control Unit(ECU)
Electronic Control Unit(ECU)Electronic Control Unit(ECU)
Electronic Control Unit(ECU)
 
Drones: Present & Future
Drones: Present & FutureDrones: Present & Future
Drones: Present & Future
 

Recently uploaded

Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxgindu3009
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPirithiRaju
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksSérgio Sacani
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsAArockiyaNisha
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTSérgio Sacani
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )aarthirajkumar25
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...anilsa9823
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxAArockiyaNisha
 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticssakshisoni2385
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​kaibalyasahoo82800
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsSérgio Sacani
 
Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfSumit Kumar yadav
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bSérgio Sacani
 
DIFFERENCE IN BACK CROSS AND TEST CROSS
DIFFERENCE IN  BACK CROSS AND TEST CROSSDIFFERENCE IN  BACK CROSS AND TEST CROSS
DIFFERENCE IN BACK CROSS AND TEST CROSSLeenakshiTyagi
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPirithiRaju
 
GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)Areesha Ahmad
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxUmerFayaz5
 
Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)PraveenaKalaiselvan1
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfSumit Kumar yadav
 

Recently uploaded (20)

Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdf
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disks
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based Nanomaterials
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOST
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
 
Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdf
 
CELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdfCELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdf
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
 
DIFFERENCE IN BACK CROSS AND TEST CROSS
DIFFERENCE IN  BACK CROSS AND TEST CROSSDIFFERENCE IN  BACK CROSS AND TEST CROSS
DIFFERENCE IN BACK CROSS AND TEST CROSS
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
 
GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptx
 
Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdf
 

Jason Radice - Emotion AI Developer Day 2016

  • 2. Overview @affectiva ● What is the JavaScript SDK? ● How does it work under the covers? ● Quick notes on how to use it ● Demo Apps
  • 3. What is the JSSDK? @affectiva ● Emscripten compiled version of our C++ SDK ○ Output is our SDK in asm.js ● Runs completely in the browser - no server communications ● Does not require any plugins or third party JS libraries ● Analyzes an image, a sequence of frames, or a video in real-time ● In a nutshell - you pass it some image data and it returns some metrics about it Emotions: {"joy":100, "sadness":0, "disgust":0, "contempt":0, "anger":0, "fear":0, "surprise":2, "valence":98, "engagement":100}, Expressions: {"smile":100, "innerBrowRaise":0, "browRaise":0, "browFurrow":0, "noseWrinkle":0, "upperLipRaise":5, "lipCornerDepressor":0, "chinRaise":0, "lipPucker":0, "lipPress":0, "lipSuck":0, "mouthOpen":100, "smirk":0, "eyeClosure":0, "attention":98, "lidTighten":0, "jawDrop":0, "dimpler":0, "eyeWiden":0, "cheekRaise":41, "lipStretch":0}
  • 4. How does it work? @affectiva ● Simply include the SDK JavaScript file in any web page ● Create a new detector instance and then start! ● Once the detector is started, it spawns a Web Worker thread ● Compiled SDK is downloaded and initialized on the worker ● Worker sends a message back to the detector once initialization is complete ● Detector will trigger the "onInitializeSuccess" event <script src="https://download.affectiva.com/js/3.1/affdex.js"/> var detector = new affdex.PhotoDetector(); detector.start(); detector.addEventListener("onInitializeSuccess", function() { // now you're ready to start processing frames! });
  • 5. How to process an image @affectiva ● Draw an image to a hidden Canvas, and pass the ImageData to the detector ● To process an image or frame, the detector posts a message to the SDK worker with the ImageData ○ Worker thread does not have access to the DOM, so the raw image data is sent to the SDK via postMessage() ● After processing the image data, worker will post a message to the detector with the results ● Detector will trigger an event in your code with the results var img = new Image(); img.onload = function() { var context = document.createElement("canvas").getContext("2d"); context.drawImage(img, 0, 0, img.width, img.height); var img_data = context.getImageData(0, 0, img.width, img.height); detector.process(img_data, 0); }; img.src = "http://example.com/some_image.jpg";
  • 6. Metrics @affectiva ● Attach an event listener to the detector and listen for onImageResultsSuccess() ● The faces object contains an array of faces found. ○ Currently, the JSSDK will only return metrics for 1 face ○ Future versions will return results for multiple faces ● Each face object will have 3 metric categories: Emotions, Expressions, Emoji ○ Feature point data is also available in the FeaturePoints category ● Get the "joy" emotion metric for the image that was just processed ● Metric value will be between 0 and 100 detector.addEventListener("onImagesResultsSuccess", function(faces, img, ts) { // metrics are in the 'faces' object }); var joy_value = faces[0]["emotions"]["joy"];
  • 7. Demos and sample code @affectiva ● Some simple demonstration applications on the Affectiva JSSDK Github page ○ https://github.com/Affectiva/js-sdk-sample-apps ● Detect emotions from a photo on your hard drive ○ https://jsfiddle.net/affectiva/h6p64vwg/show/ ● Detect emotions from your webcam ○ https://jsfiddle.net/affectiva/opyh5e8d/show/
  • 12. @affectiva Emotion-enable your own apps and digital experiences with our SDK Get started today: affectiva.com/SDK