[mousetrap/gnome3-wip: 64/240] Refactor - extracting magic numbers into constants.
- From: Heidi Ellis <heidiellis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mousetrap/gnome3-wip: 64/240] Refactor - extracting magic numbers into constants.
- Date: Mon, 8 Sep 2014 15:17:55 +0000 (UTC)
commit 435fde373a78366d0b5c96ef3ce36d60c1247d84
Author: Stoney Jackson <dr stoney gmail com>
Date: Wed Jun 11 09:45:17 2014 -0400
Refactor - extracting magic numbers into constants.
run.py | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/run.py b/run.py
index 7a421cd..ec64705 100644
--- a/run.py
+++ b/run.py
@@ -1,7 +1,6 @@
import cv2
import os
import sys
-
from mousetrap.vision import Camera, HaarLoader, ImageConverter
@@ -10,7 +9,15 @@ class TrackerSample(object):
def run(self):
# Initialize the camera and get the frame
- camera = Camera(-1, 400, 300)
+ SEARCH_FOR_DEVICE = -1
+ DEVICE_INDEX = SEARCH_FOR_DEVICE
+ CAMERA_WIDTH = 400
+ CAMERA_HEIGHT = 300
+
+ camera = Camera(
+ device_index=SEARCH_FOR_DEVICE,
+ width=CAMERA_WIDTH,
+ height=CAMERA_HEIGHT)
image = camera.read_image()
@@ -26,10 +33,14 @@ class TrackerSample(object):
}
# Detect faces using the cascade
+
# Use a 1.5 scale to ensure the head is always found
+ SCALE = 1.5
+
# Requiring 5 neighbors helps discard invalid faces
+ REQUIRED_NEIGHBORS = 5
- faces = cascades["face"].detectMultiScale(gray, 1.5, 5)
+ faces = cascades["face"].detectMultiScale(gray, SCALE, REQUIRED_NEIGHBORS)
# Fail early if there were no faces
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]