Clone or download the directory
git clone https://github.com/cosanlab/affectiva-api-app.git
Directions for processing images using affectiva_emotion_detector_photo.html
Double click the
affectiva_emotion_detector_photo.htmlin Finder or File Browser which should launch a web browser such as Chrome or Firefox.
Wait until you see the
dectector reports initializedin the logs, and you will see a
Choose Filesbutton appear.
Choose a file or files with the button. The images will be processed as soon as you click Open.
Results of the detector will be combined into
output.jsonfile which will be automatically downloaded once processing is complete.
You can edit the
affectiva_emotion_detector_photo.htmlto change the output file name, toggle verbosity of logs, or use different detectors (e.g., small or large face).
Directions for processing video using affectiva_emotion_detector.html
affectiva_emotion_detector.htmlin your favorite text editor (e.g. Atom, Sublime) and replace the filename at
var filename = 'data/sample_vid.mp4';with the name of your video filename. It's easies if you have the videos in the
secs: (default: 0) Beginning time of your video to start feature extraction.
sec_step: (default: .1) Increment of the video to extract features. The default of .1 indicates it would process a frame every 100ms.
stop_sec: (default: undefined) If you want to process only a portion of your video set stop_sec to the timestamp you wish to stop.
verbose: (default: true) When true, the frame being processed, timestamp, and success will be printed on page.
Start a webserver on your computer. If using a MAC, open up your terminal. Navigate to the
affectiva-api-appfolder then start a webserver using
python -m SimpleHTTPServer 8000
- Now open your favorite browser (e.g. Chrome, FireFox) and type the following to the address bar
You should now see a list of the files in the
affectiva-api-appdirectory. Click on affectiva_emotion_detector.html and the processing will begin.
When processing is finished, the browser will automatically download the results file in json format.
Read in files An easy way to read in the json files using the following code. You need to add
lines=Trueparameter or it will throw a trailing lines error.
import pandas as pd df = pd.read_json('~/Downloads/data_sample_vid.json',lines=True)
- Wrapper function / file grabber that can run the extraction for a list of video files.
- Frame-level extraction (currenly analyzes for each second).
- Asynchronous method? (currently recursive until finishes but async/parallel may speed up)
- Electron App?