Things used in this project

Hardware components:
1434509556 android phone color
Android device
×1
Pi 3 02
Raspberry Pi 3 Model B
×1
11868 00a
Raspberry Pi Camera module
×1
Bledongle
mbientLab Bluetooth to USB Dongle
×1
Realsense
Intel RealSense Camera
×1
1063 00
Adafruit Microphone Amplifier Breakout
×1
Sonos
Sonos speakers
×1
Cloudwatch
Amazon Web Services AWS CloudWatch
×1
Software apps and online services:
Logo things yummo7uv2y
Google Android Things

Schematics

Bluetooth module
bluetooth_jtfeodhBUQ.fzz

Code

get face from cameraPython
import cv2
import os
import sys
import random

out_dir = './my_faces'
if not os.path.exists(out_dir):
    os.makedirs(out_dir)



def relight(img, alpha=1, bias=0):
    w = img.shape[1]
    h = img.shape[0]
    #image = []
    for i in range(0,w):
        for j in range(0,h):
            for c in range(3):
                tmp = int(img[j,i,c]*alpha + bias)
                if tmp > 255:
                    tmp = 255
                elif tmp < 0:
                    tmp = 0
                img[j,i,c] = tmp
    return img


cv2.CascadeClassifier('haarcascade_frontalface_default.xml')


camera = cv2.VideoCapture(0)

n = 1
while 1:
    if (n <= 10000):
        print('It`s processing %s image.' % n)
        success, img = camera.read()

        gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        faces = haar.detectMultiScale(gray_img, 1.3, 5)
        for f_x, f_y, f_w, f_h in faces:
            face = img[f_y:f_y+f_h, f_x:f_x+f_w]
            face = cv2.resize(face, (64,64))
            '''
            if n % 3 == 1:
                face = relight(face, 1, 50)
            elif n % 3 == 2:
                face = relight(face, 0.5, 0)
            '''
            face = relight(face, random.uniform(0.5, 1.5), random.randint(-50, 50))
            cv2.imshow('img', face)
            cv2.imwrite(out_dir+'/'+str(n)+'.jpg', face)
            n+=1
        key = cv2.waitKey(30) & 0xff
        if key == 27:
            break
    else:
        break

Credits

B635044c59b8e69ebbee29ce26d2910b
aliceding
1 project • 1 follower
graduate student
Contact
Photo
Zhang Uranus
1 project • 1 follower
Contact
14938203 328778664168273 6318821603867275874 n
Xubin Ni
1 project • 1 follower
Contact
C956c417a0610abbbe60de2a1c61eceb
sheng
1 project • 1 follower
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login