mirror of
https://github.com/undera/pylgbst.git
synced 2020-11-18 19:37:26 -08:00
Proper example folder
This commit is contained in:
parent
d889a50aab
commit
a18808374b
@ -1,5 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
@ -42,7 +43,7 @@ class FaceTracker(MoveHub):
|
|||||||
bodies, rejects, weights = self.face_cascade.detectMultiScale3(self.cur_img, 1.5, 5, outputRejectLevels=True)
|
bodies, rejects, weights = self.face_cascade.detectMultiScale3(self.cur_img, 1.5, 5, outputRejectLevels=True)
|
||||||
return bodies, weights
|
return bodies, weights
|
||||||
|
|
||||||
def _find_heli(self):
|
def _find_color(self):
|
||||||
# from https://www.pyimagesearch.com/2015/09/14/ball-tracking-with-opencv/
|
# from https://www.pyimagesearch.com/2015/09/14/ball-tracking-with-opencv/
|
||||||
# and https://thecodacus.com/opencv-object-tracking-colour-detection-python/#.W2DHFd_IQsM
|
# and https://thecodacus.com/opencv-object-tracking-colour-detection-python/#.W2DHFd_IQsM
|
||||||
|
|
||||||
@ -50,13 +51,9 @@ class FaceTracker(MoveHub):
|
|||||||
hsv = cv2.cvtColor(blurred, cv2.COLOR_BGR2HSV)
|
hsv = cv2.cvtColor(blurred, cv2.COLOR_BGR2HSV)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open("/tmp/1.json") as fhd:
|
# having color values in file allows finding values easier
|
||||||
|
with open(os.path.join(os.path.dirname(__file__), "color.json")) as fhd:
|
||||||
data = json.loads(fhd.read())
|
data = json.loads(fhd.read())
|
||||||
level = int(time.time()) % 51
|
|
||||||
level *= 5
|
|
||||||
logging.info("%s", level)
|
|
||||||
# data[0][0] = level
|
|
||||||
# data[1][0] = level + 5
|
|
||||||
lower = tuple(data[0])
|
lower = tuple(data[0])
|
||||||
upper = tuple(data[1])
|
upper = tuple(data[1])
|
||||||
except:
|
except:
|
||||||
@ -67,8 +64,8 @@ class FaceTracker(MoveHub):
|
|||||||
mask = cv2.erode(mask, None, iterations=2)
|
mask = cv2.erode(mask, None, iterations=2)
|
||||||
mask = cv2.dilate(mask, None, iterations=2)
|
mask = cv2.dilate(mask, None, iterations=2)
|
||||||
|
|
||||||
if not (int(time.time()) % 2):
|
# if not (int(time.time()) % 2):
|
||||||
self.cur_img = mask
|
# self.cur_img = mask
|
||||||
|
|
||||||
cnts = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
cnts = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
||||||
cnts = cnts[0] if imutils.is_cv2() else cnts[1]
|
cnts = cnts[0] if imutils.is_cv2() else cnts[1]
|
||||||
@ -109,7 +106,8 @@ class FaceTracker(MoveHub):
|
|||||||
|
|
||||||
cur_face = (0, 0, 0, 0)
|
cur_face = (0, 0, 0, 0)
|
||||||
while thr.isAlive():
|
while thr.isAlive():
|
||||||
bodies, weights = self._find_faces()
|
bodies, weights = self._find_color()
|
||||||
|
#bodies, weights = self._find_faces()
|
||||||
|
|
||||||
if len(bodies):
|
if len(bodies):
|
||||||
logging.debug("Bodies: %s / Weights: %s", bodies, weights)
|
logging.debug("Bodies: %s / Weights: %s", bodies, weights)
|
4
examples/tracker/color.json
Normal file
4
examples/tracker/color.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[
|
||||||
|
[95, 64, 128],
|
||||||
|
[100, 255, 255]
|
||||||
|
]
|
Loading…
x
Reference in New Issue
Block a user