Fixed Windows error on blink detection demo

This commit is contained in:
esimov
2022-11-09 16:03:01 +02:00
parent 48642d9828
commit 0388e93ed9
2 changed files with 2 additions and 10 deletions

View File

@@ -68,8 +68,7 @@ typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
extern "C" { extern "C" {
#endif #endif
extern __declspec(dllexport) GoUintptr FindFaces(GoSlice pixels);
extern GoUintptr FindFaces(GoSlice p0);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -1,14 +1,11 @@
from ctypes import * from ctypes import *
import subprocess
import numpy as np import numpy as np
import os import os
import cv2 import cv2
import time
os.system('go build -o blinkdet.so -buildmode=c-shared blinkdet.go') os.system('go build -o blinkdet.so -buildmode=c-shared blinkdet.go')
pigo = cdll.LoadLibrary('./blinkdet.so') pigo = cdll.LoadLibrary('./blinkdet.so')
os.system('rm blinkdet.so')
MAX_NDETS = 2024 MAX_NDETS = 2024
ARRAY_DIM = 6 ARRAY_DIM = 6
@@ -38,7 +35,7 @@ def process_frame(pixs):
if data_pointer : if data_pointer :
buffarr = ((c_longlong * ARRAY_DIM) * MAX_NDETS).from_address(addressof(data_pointer.contents)) buffarr = ((c_longlong * ARRAY_DIM) * MAX_NDETS).from_address(addressof(data_pointer.contents))
res = np.ndarray(buffer=buffarr, dtype=c_longlong, shape=(MAX_NDETS, 5,)) res = np.ndarray(buffer=buffarr, dtype=c_longlong, shape=(ARRAY_DIM, 5,))
# The first value of the buffer aray represents the buffer length. # The first value of the buffer aray represents the buffer length.
dets_len = res[0][0] dets_len = res[0][0]
@@ -54,10 +51,6 @@ cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640) cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480) cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
# 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)
show_pupil = True show_pupil = True
show_eyes = False show_eyes = False
face_posy = 0 face_posy = 0