You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// starting regions for localization are initialized based on the face bounding box
103
+
// (parameters are set empirically)
104
+
// first eye
105
+
r=dets[i][0] -0.075*dets[i][2];
106
+
c=dets[i][1] -0.175*dets[i][2];
107
+
s=0.35*dets[i][2];
108
+
[r, c] =do_puploc(r, c, s, 63, image)
109
+
if(r>=0&&c>=0)
110
+
{
111
+
ctx.beginPath();
112
+
ctx.arc(c, r, 1, 0, 2*Math.PI, false);
113
+
ctx.lineWidth=3;
114
+
ctx.strokeStyle='red';
115
+
ctx.stroke();
116
+
}
117
+
// second eye
118
+
r=dets[i][0] -0.075*dets[i][2];
119
+
c=dets[i][1] +0.175*dets[i][2];
120
+
s=0.35*dets[i][2];
121
+
[r, c] =do_puploc(r, c, s, 63, image)
122
+
if(r>=0&&c>=0)
123
+
{
124
+
ctx.beginPath();
125
+
ctx.arc(c, r, 1, 0, 2*Math.PI, false);
126
+
ctx.lineWidth=3;
127
+
ctx.strokeStyle='red';
128
+
ctx.stroke();
129
+
}
130
+
131
+
// At this point, we already know that the human face is detected in webcam. So, We'll simply create an image from canvas that is displaying the webcam result in real-time.
132
+
varcan=document.getElementsByTagName('canvas')[0]
133
+
varimg=newImage();
134
+
img.src=can.toDataURL('image/jpeg', 1.0);
135
+
136
+
// Now, we will send the image to server and process it using PHP. Also, we have to save its path in MySQL database for later use.
This code was taken from https://github.com/cbrandolino/camvas and modified to suit our needs
3
+
*/
4
+
/*
5
+
Copyright (c) 2012 Claudio Brandolino
6
+
7
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
+
9
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+
11
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
+
*/
13
+
// The function takes a canvas context and a `drawFunc` function.
14
+
// `drawFunc` receives two parameters, the video and the time since
15
+
// the last time it was called.
16
+
functioncamvas(ctx,callback){
17
+
varself=this
18
+
this.ctx=ctx
19
+
this.callback=callback
20
+
21
+
// We can't `new Video()` yet, so we'll resort to the vintage
22
+
// "hidden div" hack for dynamic loading.
23
+
varstreamContainer=document.createElement('div')
24
+
this.video=document.createElement('video')
25
+
26
+
// If we don't do this, the stream will not be played.
27
+
// By the way, the play and pause controls work as usual
28
+
// for streamed videos.
29
+
this.video.setAttribute('autoplay','1')
30
+
this.video.setAttribute('playsinline','1')// important for iPhones
31
+
32
+
// The video should fill out all of the canvas
33
+
this.video.setAttribute('width',1)
34
+
this.video.setAttribute('height',1)
35
+
36
+
streamContainer.appendChild(this.video)
37
+
document.body.appendChild(streamContainer)
38
+
39
+
// The callback happens when we are starting to stream the video.
0 commit comments