Skip to content

Commit e47f83e

Browse files
committed
[KTECH-2900] added updated Ruby docs; tweaks to php and python demos
1 parent 8ac897a commit e47f83e

File tree

120 files changed

+9085
-295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+9085
-295
lines changed

go-demo/Makefile

-166
This file was deleted.

go-demo/assets/docs/emotion/Emotion.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ The colors for the indivdual emotion charts are found on the emotion.html page:
4646
});
4747
```
4848
### Video display
49-
At the same time that the highcharts graph is created, the selected video is rendered in an HTML5 tag inside the `#selected-video` div. The example video is hosted on S3:
50-
`https://media.kairos.com/emodemo/videos/video_1.mp4`
49+
At the same time that the highcharts graph is created, the selected video is rendered in an HTML5 tag inside the `#selected-video` div.
5150

5251
Tools are provided so that the user can play, pause or scrub the video.
5352

go-demo/public/views/emotion.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<div class="row">
2020
<div class="col-xs-12 col-sm-12 col-md-6 main-video-container">
2121
<div class="video-wrapper">
22-
<video id="video" width="100%" mediaId="video_1" src="https://media.kairos.com/demo/emotion/videos/video_1.mp4" muted playsinline></video>
22+
<video id="video" width="100%" mediaId="video_1" src="https://media.kairos.com/demo/videos/video_1.mp4" muted playsinline></video>
2323
<div class="video-controls">
2424
<a href="/" class="play" id="play-pause"></a>
2525
<div id="progress">

php-demo/emotion/README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ An example video is presented to the user, and an analysis begins immediately up
2424

2525
In order to render the analysis of the example video, you must enter a Media ID into the config.php file. To get the Media ID for the example video, run this script at your command prompt:
2626

27-
`curl -v -X POST -H "app_id: {your app_id}" -H "app_key: {your app_key}" http://api.kairos.com/v2/media?source=https://media.kairos.com/demo/emotion/videos/video_1.mp4`
27+
`curl -v -X POST -H "app_id: {your app_id}" -H "app_key: {your app_key}" http://api.kairos.com/v2/media?source=https://media.kairos.com/demo/videos/video_1.mp4`
2828

2929
This should return something similar to this:
3030

@@ -47,8 +47,7 @@ To accomplish this analysis, an AJAX script in the `emoDemoApp.js` file POSTS to
4747
The colors for the indivdual emotion charts are found inside `config.php`.
4848

4949
### Video display
50-
At the same time that the highcharts graph is created, the selected video is rendered in an HTML5 tag inside the `#selected-video` div. The example video is hosted on S3:
51-
https://media.kairos.com/emodemo/videos/video_1.mp4
50+
At the same time that the highcharts graph is created, the selected video is rendered in an HTML5 tag inside the `#selected-video` div.
5251

5352
Tools are provided so that the user can play, pause or scrub the video.
5453

php-demo/emotion/index.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<div class="row">
2929
<div class="col-xs-12 col-sm-12 col-md-6 main-video-container">
3030
<div class="video-wrapper">
31-
<video id="video" width="100%" mediaId="video_1" src="https://media.kairos.com/demo/emotion/videos/video_1.mp4" muted playsinline></video>
31+
<video id="video" width="100%" mediaId="video_1" src="videos/video_1.mp4" muted playsinline></video>
3232
<div class="video-controls">
3333
<a href="/" class="play" id="play-pause"></a>
3434
<div id="progress">

php-demo/emotion/videos/video_1.mp4

12.1 MB
Binary file not shown.

python-demo/app.py

+15-24
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,17 @@
99
from flask import Flask, render_template, request, json
1010
app = Flask(__name__)
1111

12-
# get environment variables
13-
try:
14-
demo_env = os.environ["STAGE"]
15-
except:
16-
demo_env = "dev"
17-
18-
try:
19-
api_url = os.environ["API_URL"]
20-
except:
21-
api_url = "https://api.kairos.com"
22-
23-
try:
24-
app_id = os.environ["APP_ID"]
25-
except:
26-
app_id = "YOUR_APP_ID"
27-
28-
try:
29-
app_key = os.environ["APP_KEY"]
30-
except:
31-
app_key = "YOUR_APP_KEY"
12+
# set variables (currently dev version)
13+
api_url = "https://api.kairos.com"
14+
app_id = "YOUR_APP_ID"
15+
app_key = "YOUR_APP_KEY"
16+
demo1_id = "GENERATE_VIDEO_ID" # see documentation
17+
18+
headers = {
19+
# "Content-Type": "application/json",
20+
"app_id": app_id,
21+
"app_key": app_key
22+
}
3223

3324
headers = {
3425
# "Content-Type": "application/json",
@@ -43,7 +34,7 @@ def RenderMainIndex():
4334

4435
@app.route('/detect')
4536
def renderDetect():
46-
return render_template("detect.html", APP_ID=app_id, APP_KEY=app_key, API_URL=api_url, CACHE_BUSTER=CacheBuster())
37+
return render_template("detect.html", APP_ID=app_id, APP_KEY=app_key, API_URL=api_url)
4738

4839
@app.route('/detect/send-to-api', methods=['POST'])
4940
def sendToApiDetect():
@@ -54,7 +45,7 @@ def sendToApiDetect():
5445

5546
@app.route('/emotion')
5647
def renderEmotion():
57-
return render_template("emotion.html", APP_ID=app_id, APP_KEY=app_key, API_URL=api_url, CACHE_BUSTER=CacheBuster())
48+
return render_template("emotion.html", APP_ID=app_id, APP_KEY=app_key, API_URL=api_url, DEMO1_ID=demo1_id)
5849

5950
@app.route('/emotion/send-to-api', methods=['POST'])
6051
def sendToApiEmotion():
@@ -115,7 +106,7 @@ def sendToApiEmotion():
115106
return fileUpload.content
116107
@app.route('/recognize')
117108
def renderRecognize():
118-
return render_template("recognize.html", APP_ID=app_id, APP_KEY=app_key, API_URL=api_url, CACHE_BUSTER=CacheBuster())
109+
return render_template("recognize.html", APP_ID=app_id, APP_KEY=app_key, API_URL=api_url)
119110

120111
@app.route('/recognize/send-to-api', methods=['POST'])
121112
def sendToApiRecognize():
@@ -132,7 +123,7 @@ def sendToApiRecognize():
132123

133124
@app.route('/verify')
134125
def renderVerify():
135-
return render_template("verify.html", APP_ID=app_id, APP_KEY=app_key, API_URL=api_url, CACHE_BUSTER=CacheBuster())
126+
return render_template("verify.html", APP_ID=app_id, APP_KEY=app_key, API_URL=api_url)
136127

137128
@app.route('/verify/send-to-api', methods=['POST'])
138129
def sendToApiVerify():

python-demo/static/docs/emotion/Emotion.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ To accomplish this, an AJAX script in the `emoDemoApp.js` file POSTS to the rout
4949
The colors for the indivdual emotion charts are found inside `config.php`.
5050

5151
### Video display
52-
At the same time that the highcharts graph is created, the selected video is rendered in an HTML5 tag inside the `#selected-video` div. The example video is hosted on S3:
53-
https://media.kairos.com/demo/videos/video_1.mp4
52+
At the same time that the highcharts graph is created, the selected video is rendered in an HTML5 tag inside the `#selected-video` div.
5453

5554
Tools are provided so that the user can play, pause or scrub the video.
5655

python-demo/templates/emotion.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ <h4>Options</h4>
157157
"pollTimeout":300,
158158
"mediaPath": "static/",
159159
"demoMedia":[
160-
{"video_1":"17b62ed9921ab34c7deb9a33"}
160+
{"video_1":"{{DEMO1_ID}}"}
161161
],
162162
"apiCredentials":true
163163
});

ruby-demo/README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
These demo apps showcase the Kairos APIs by giving the user a means to quickly get up and running with our Emotion Analysis and Facial Recognition / Detection APIs.
55

66
## Running the App
7-
The demo app can easily be run using Docker with the included Dockerfile and docker-compose.yml or locally from your command prompt.
87

98
The app is basically a single page application, which is viewed at index.html.
109

@@ -27,18 +26,30 @@ Point your browser to `http://127.0.0.1:4567/`
2726

2827
### Detect
2928
The Detect Demo uses Kairos Face Recognition API to detect a human face in an existing photo, or a snapshot from the user's webcam.
29+
3030
[Documentation](/ruby-demo/public/docs/detect/Detect.md)
3131

32+
[Tutorial](/ruby-demo/public/docs/detect/tutorial/Detect_API_Ruby_Tutorial.md)
33+
3234
### Emotion
3335
The Emotion Demo showcases the Kairos Emotion API by giving the user three methods for analyzing human emotions in a video stream.
36+
3437
[Documentation](/ruby-demo/public/docs/emotion/Emotion.md)
3538

39+
[Tutorial](/ruby-demo/public/docs/emotion/tutorial/Emotion_API_Ruby_Tutorial.md)
40+
3641
### Recognize
3742
The Recognize Demo uses Kairos Face Recognition API to recognize human faces from previously enrolled faces by the user.
43+
3844
[Documentation](/ruby-demo/public/docs/recognize/Recognize.md)
3945

46+
[Tutorial](/ruby-demo/public/docs/recognize/tutorial/Recognize_API_Ruby_Tutorial.md)
47+
4048
### Verify
4149
Using the Kairos Face Recognition API, the Verify Demo compares two photos, and verifies that the two photos are of the same individual.
50+
4251
[Documentation](/ruby-demo/public/docs/verify/Verify.md)
4352

53+
[Tutorial](/ruby-demo/public/docs/verify/tutorial/Verify_API_Ruby_Tutorial.md)
54+
4455

ruby-demo/app.rb

+4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
require "base64"
55
require "httparty"
66

7+
# set variables (currently dev version)
78
api_url = "https://api.kairos.com"
89
app_id = "YOUR_APP_ID"
910
app_key = "YOUR_APP_KEY"
11+
demo1_id = "GENERATE_VIDEO_ID" # see documentation
1012

1113
headers = {
14+
"Content-type" => "application/json",
1215
"app_id" => app_id,
1316
"app_key" => app_key
1417
}
@@ -34,6 +37,7 @@
3437
@API_URL = api_url
3538
@APP_ID = app_id
3639
@APP_KEY = app_key
40+
@DEMO1_ID = demo1_id
3741
erb :emotion
3842
end
3943

ruby-demo/public/css/detect/detect.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
width: 500px;
104104
height: 500px;
105105
margin: 0 auto;
106-
background: transparent url('/images/face_overlay.png') no-repeat;
106+
background: transparent url('../../images/icons/face_overlay.png') no-repeat;
107107
background-size: 50%;
108108
background-position: 45% 45%;
109109
z-index: 10;
@@ -179,13 +179,13 @@
179179
width: 50px;
180180
height: 50px;
181181
margin: 0 auto;
182-
background: transparent url('/images/spinner.gif') no-repeat;
182+
background: transparent url('../../images/icons/spinner.gif') no-repeat;
183183
}
184184
.sad-face {
185185
width: 50px;
186186
height: 50px;
187187
margin: 0 auto;
188-
background: transparent url('../images/sad_face.png') no-repeat;
188+
background: transparent url('../../images/icons/sad_face.png') no-repeat;
189189
}
190190
.message-container{
191191
font-size: 14px;

0 commit comments

Comments
 (0)