OpenCV, Kivy and Android.

778 views
Skip to first unread message

Carlos Pereira

unread,
Apr 12, 2017, 1:06:26 PM4/12/17
to Kivy users support
hi guys i have code to capture faces and make a dataset to use as face recognition database, but i want to use this code in an android device, but I dont know how to do it this in python and I dont know java (i dont like java too - haha)
how can i port my python code to android using kivy -  i have seen this page:http://cadernodelaboratorio.com.br/2016/05/24/opencv-e-video-com-o-kivy/, but i dont know how to make my own version of this. (sorry for my english guys... and thanks everyone)

import cv2, sys, numpy, os
haar_file = 'haarcascade_frontalface_default.xml'
datasets = 'datasets'  #All the faces data will be present this folder
sub_data = raw_input ('your name')     #These are sub data sets of folder, for my faces I've used my name

path = os.path.join(datasets, sub_data)
if not os.path.isdir(path):
    os.mkdir(path)
(width, height) = (130, 100)    # defining the size of images 


face_cascade = cv2.CascadeClassifier(haar_file)
webcam = cv2.VideoCapture(0) #'0' is use for my webcam, if you've any other camera attached use '1' like this

# The program loops until it has 100 images of the face.
count = 1
while count < 101: 
    (_, im) = webcam.read()
    gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
    faces = face_cascade.detectMultiScale(gray, 1.3, 4)
    for (x,y,w,h) in faces:
        cv2.rectangle(im,(x,y),(x+w,y+h),(255,0,0),2)
        face = gray[y:y + h, x:x + w]
        face_resize = cv2.resize(face, (width, height))
        cv2.imwrite('%s/%s.png' % (path,count), face_resize)
    count += 1

    cv2.imshow('OpenCV', im)
    key = cv2.waitKey(10)
    if key == 27:
        break


camilo diaz

unread,
May 27, 2020, 12:27:03 PM5/27/20
to Kivy users support
hola amigo no es tan facil de realizarlo estoy trabajando en un proyecto parecido pero es complicado realizarlo el ejemplo que realiza en el link que comprtes ayuda mucho pero toca tener un enfoque hacia donde se quiere llegar tiene que estudiar python avanzado
Reply all
Reply to author
Forward
0 new messages