Windows pyinstaller compatibilities
This commit is contained in:
parent
9d1b523c56
commit
cf88f3a8ee
3 changed files with 49 additions and 11 deletions
|
@ -229,7 +229,7 @@ def process1_hog(in_q, out_q):
|
|||
face_detector = dlib.get_frontal_face_detector()
|
||||
|
||||
visualisation_factor = 1
|
||||
detection_factor = .4
|
||||
detection_factor = .3
|
||||
|
||||
|
||||
process_this_frame = True
|
||||
|
@ -239,7 +239,7 @@ def process1_hog(in_q, out_q):
|
|||
frame = in_q.get()
|
||||
|
||||
frame = cv2.cvtColor(src=frame, code=cv2.COLOR_BGR2GRAY)
|
||||
viz_frame = cv2.resize(frame, (0, 0), fx=visualisation_factor, fy=visualisation_factor)
|
||||
# viz_frame = cv2.resize(frame, (0, 0), fx=visualisation_factor, fy=visualisation_factor)
|
||||
det_frame = cv2.resize(frame, (0, 0), fx=detection_factor, fy=detection_factor)
|
||||
|
||||
start = time.time()
|
||||
|
@ -371,16 +371,20 @@ def process3_haar(in_q, out_q, cascade_file, library_filename = None):
|
|||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
lib_path = os.path.join(dir_path, "..", "visualhaar", "target", "release")
|
||||
so_path = os.path.join(lib_path, "libvisual_haarcascades_lib.so")
|
||||
dll_path = os.path.join(lib_path, "visual_haarcascades_lib.dll")
|
||||
possible_paths = [
|
||||
os.path.join(lib_path, "libvisual_haarcascades_lib.so"),
|
||||
os.path.join(lib_path, "visual_haarcascades_lib.dll"),
|
||||
os.path.join(dir_path, "..", "visual_haarcascades_lib.dll"),
|
||||
]
|
||||
|
||||
if os.path.exists(so_path):
|
||||
C = ffi.dlopen(so_path)
|
||||
elif os.path.exists(dll_path):
|
||||
C = ffi.dlopen(dll_path)
|
||||
else:
|
||||
existing_paths = [p for p in possible_paths if os.path.exists(p)]
|
||||
|
||||
if not len(existing_paths):
|
||||
raise RuntimeError("Visual haarcascades library is not found")
|
||||
|
||||
|
||||
logger.debug(f"Using library: {existing_paths[0]}")
|
||||
C = ffi.dlopen(existing_paths[0])
|
||||
|
||||
# print(C.test(9))
|
||||
# i = Image.open("Marjo.jpg")
|
||||
# width = i.size[0]
|
||||
|
|
32
face_recognition/tools.py
Normal file
32
face_recognition/tools.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
from PIL import ImageFont, ImageDraw, Image
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
text_to_show = "The quick brown fox jumps over the lazy dog"
|
||||
|
||||
# Load image in OpenCV
|
||||
image = cv2.imread("Me.jpg")
|
||||
|
||||
# Convert the image to RGB (OpenCV uses BGR)
|
||||
cv2_im_rgb = cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
|
||||
|
||||
# Pass the image to PIL
|
||||
pil_im = Image.fromarray(cv2_im_rgb)
|
||||
|
||||
draw = ImageDraw.Draw(pil_im)
|
||||
|
||||
# Draw the text
|
||||
draw.text((10, 700), text_to_show, font=font)
|
||||
|
||||
# Get back the image to OpenCV
|
||||
cv2_im_processed = cv2.cvtColor(np.array(pil_im), cv2.COLOR_RGB2BGR)
|
||||
|
||||
cv2.imshow('Fonts', cv2_im_processed)
|
||||
cv2.waitKey(0)
|
||||
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
def get_font(filename, size):
|
||||
return ImageFont.truetype(filename, size)
|
||||
|
||||
def draw_text(img, ):
|
|
@ -1,9 +1,11 @@
|
|||
import argparse
|
||||
import face_recognition.comparison
|
||||
import cv2
|
||||
|
||||
from multiprocessing import freeze_support
|
||||
|
||||
if __name__ == '__main__':
|
||||
freeze_support() # support pyinstaller on Windows
|
||||
|
||||
parser = argparse.ArgumentParser(description='Visualise face recognition algorithms.')
|
||||
parser.add_argument('--camera', '-c', type=int, default=0,
|
||||
help='Numeric id of the camera')
|
||||
|
|
Loading…
Reference in a new issue