Showing
2 changed files
with
2 additions
and
2 deletions
... | @@ -127,7 +127,7 @@ function processVideo() { | ... | @@ -127,7 +127,7 @@ function processVideo() { |
127 | let point2 = new cv.Point(face.x + face.width, face.y + face.height); | 127 | let point2 = new cv.Point(face.x + face.width, face.y + face.height); |
128 | cv.rectangle(dst, point1, point2, [255, 0, 0, 255], 8); | 128 | cv.rectangle(dst, point1, point2, [255, 0, 0, 255], 8); |
129 | let cropped = new cv.Mat(); | 129 | let cropped = new cv.Mat(); |
130 | - let rect = new cv.Rect(face.x, face.y, face.width, face.height); | 130 | + let rect = new cv.Rect(Math.max(face.x-face.width/4, 0), Math.max(face.y-face.height/2, 0), Math.min(face.width+face.width/2, src.cols), Math.min(face.height*2, src.rows)); |
131 | cropped = src.roi(rect); | 131 | cropped = src.roi(rect); |
132 | let tempCanvas = document.createElement("canvas"); | 132 | let tempCanvas = document.createElement("canvas"); |
133 | cv.imshow(tempCanvas,cropped); | 133 | cv.imshow(tempCanvas,cropped); | ... | ... |
... | @@ -61,7 +61,7 @@ function detect_face() | ... | @@ -61,7 +61,7 @@ function detect_face() |
61 | let point1 = new cv.Point(face.x, face.y); | 61 | let point1 = new cv.Point(face.x, face.y); |
62 | let point2 = new cv.Point(face.x + face.width, face.y + face.height); | 62 | let point2 = new cv.Point(face.x + face.width, face.y + face.height); |
63 | cv.rectangle(dst, point1, point2, [255, 0, 0, 255], 8); | 63 | cv.rectangle(dst, point1, point2, [255, 0, 0, 255], 8); |
64 | - let rect = new cv.Rect(Math.max(face.x-face.width/4, 0), Math.max(face.y-face.height/2, 0), Math.min(face.width+face.width/2, src.cols), Math.min(face.height+face.height/2, src.rows)); | 64 | + let rect = new cv.Rect(Math.max(face.x-face.width/4, 0), Math.max(face.y-face.height/2, 0), Math.min(face.width+face.width/2, src.cols), Math.min(face.height*2, src.rows)); |
65 | let cropped = src.roi(rect); | 65 | let cropped = src.roi(rect); |
66 | cv.imshow(tempCanvas,cropped); | 66 | cv.imshow(tempCanvas,cropped); |
67 | } | 67 | } | ... | ... |
-
Please register or login to post a comment