-->
BLANTERWISDOM101

cara install dlib di raspberry pi 2

Monday, March 25, 2019
OS: raspbian
hardware: raspberry pi 2



CARA INSTALL DLIB DI RASPBERRY PI

STEP#1: Setting environment raspi, dengan Update swap file size, boot options, and memory split.
1a. naikkan swaf size ke 1024 mb
$ sudo nano /etc/dphys-swapfile

$ sudo /etc/init.d/dphys-swapfile stop
$ sudo /etc/init.d/dphys-swapfile start
$ free -m

1b. ubah boot options dari 'desktop autologin' ke 'console autologin'
1c. Update GPU/RAM split  dari 64 ke 16

STEP#2: Install dlib

#2a. install for prerequisites
$ sudo apt-get update
$ sudo apt-get install build-essential cmake
$ sudo apt-get install libgtk-3-dev
$ sudo apt-get install libboost-all-dev


#2b. install pip klo belum ada(kalo udah skip)
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py

$ mkvirtualenv py3_dlib -p python3
$ workon py3_dlib


#2c. install lib
$ pip install numpy
$ pip install scipy
$ pip install scikit-image
$ pip install dlib

#2d. testing dlib
$ python
Python 3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dlib
>>>

#2e. reset swaf size, boot option dan memory split
# swap to 100mb.
#boot option to
# memory split 64


test facial landmark
# import the necessary packages
from imutils import face_utils
import dlib
import cv2

# initialize dlib's face detector (HOG-based) and then create
# the facial landmark predictor
p = "shape_predictor_68_face_landmarks.dat"
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(p)

# load the input image and convert it to grayscale
image = cv2.imread("example.jpg")
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

# detect faces in the grayscale image
rects = detector(gray, 0)

# loop over the face detections
for (i, rect) in enumerate(rects):
    # determine the facial landmarks for the face region, then
    # convert the facial landmark (x, y)-coordinates to a NumPy
    # array
    shape = predictor(gray, rect)
    shape = face_utils.shape_to_np(shape)

    # loop over the (x, y)-coordinates for the facial landmarks
    # and draw them on the image
    for (x, y) in shape:
        cv2.circle(image, (x, y), 2, (0, 255, 0), -1)

# show the output image with the face detections + facial landmarks
cv2.imshow("Output", image)
cv2.waitKey(0)

SELAMAT MENCOBA
JOTECHNO

sumber: https://www.pyimagesearch.com/2017/05/01/install-dlib-raspberry-pi/
Share This :

0 comments