mirror of
https://github.com/esimov/pigo.git
synced 2025-10-14 12:23:45 +08:00
fix: resolved Python demos error on Windows #58
This commit is contained in:
@@ -8,7 +8,6 @@ import time
|
||||
|
||||
os.system('go build -o pigo.so -buildmode=c-shared pigo.go')
|
||||
pigo = cdll.LoadLibrary('./pigo.so')
|
||||
os.system('rm pigo.so')
|
||||
|
||||
MAX_NDETS = 2048
|
||||
|
||||
@@ -35,7 +34,7 @@ def process_frame(pixs):
|
||||
|
||||
if data_pointer :
|
||||
buffarr = ((c_longlong * 3) * MAX_NDETS).from_address(addressof(data_pointer.contents))
|
||||
res = np.ndarray(buffer=buffarr, dtype=c_longlong, shape=(MAX_NDETS, 3,))
|
||||
res = np.ndarray(buffer=buffarr, dtype=c_longlong, shape=(3,3))
|
||||
|
||||
# The first value of the buffer aray represents the buffer length.
|
||||
dets_len = res[0][0]
|
||||
@@ -45,15 +44,12 @@ def process_frame(pixs):
|
||||
return dets
|
||||
|
||||
width, height = 640, 480
|
||||
|
||||
# initialize the camera
|
||||
cap = cv2.VideoCapture(0)
|
||||
cap.set(cv2.CAP_PROP_FRAME_WIDTH, width)
|
||||
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
|
||||
|
||||
# Changing the camera resolution introduce a short delay in the camera initialization.
|
||||
# For this reason we should delay the object detection process with a few milliseconds.
|
||||
time.sleep(0.4)
|
||||
|
||||
while(True):
|
||||
ret, frame = cap.read()
|
||||
pixs = np.ascontiguousarray(frame[:, :, 1]).flatten()
|
||||
@@ -64,10 +60,10 @@ while(True):
|
||||
if dets is not None:
|
||||
for det in dets:
|
||||
mask = np.zeros((height, width, 3), dtype=np.uint8)
|
||||
mask = cv2.circle(mask, (int(det[1]), int(det[0])), int(det[2]/1.8), np.array([255, 255, 255]), -1)
|
||||
mask = cv2.circle(mask, (int(det[1]), int(det[0])), int(det[2]/2.0), (255, 255, 255), -1)
|
||||
frame = np.where(mask!=np.array([255, 255, 255]), frame, cv2.blur(frame, (30, 30), 0))
|
||||
|
||||
cv2.imshow('', frame)
|
||||
cv2.imshow('Faceblur demo', frame)
|
||||
|
||||
if cv2.waitKey(5) & 0xFF == ord('q'):
|
||||
break
|
||||
|
Reference in New Issue
Block a user