Skip to content

Instantly share code, notes, and snippets.

import cv2
# Caso você tenha apenas 1 webcam, set device = 0, caso contrario, escolha seu device(webcam) de preferencia, 0, 1, 2 ,3 ...
cap = cv2.VideoCapture(0)
while True:
# Obtendo nossa imagem através da webCam e transformando-a preto e branco
_, image = cap.read()
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# Mostrando a imagem na tela
cv2.imshow("Output", image)
# import the necessary packages
from imutils import face_utils
import dlib
import cv2
# Vamos inicializar um detector de faces (HOG) para então
# fazer a predição dos pontos da nossa face.
#p é o diretorio do nosso modelo já treinado, no caso, ele está no mesmo diretorio
# que esse script
p = "shape_predictor_68_face_landmarks.dat"
import cv2
# if (you have only 1 webcam){ set device = 0} else{ chose your favorite webcam setting device = 1, 2 ,3 ... }
cap = cv2.VideoCapture(0)
while True:
# Getting our image by webcam and converting it into a gray image scale
_, image = cap.read()
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# show the gray image
cv2.imshow("Output", image)
from imutils import face_utils
import dlib
import cv2
# Vamos inicializar um detector de faces (HOG) para então
# let's go code an faces detector(HOG) and after detect the
# landmarks on this detected face
# p = our pre-treined model directory, on my case, it's on the same script's diretory.
p = "shape_predictor_68_face_landmarks.dat"
package main
func readFile(path string) (record [][]string) {
//Open the file
file, err := os.Open(path)
if err != nil {
log.Fatalln("Error: ", err)
return
}
//Close the file when this method finish
package main
func readFile(path string) (record [][]string) {
//[...]
return
}
func getCollum(elements [][]string, ColumnIndex int) (column []string) {
//for each []line in dataset
//get the the columIndex value
package main
//[...]
func main() {
//[...]
classes := distinct(getCollum(records, len(records[0])-1))
var train [][]string
var test [][]string
package main
//[...]
func getValuesByClass(records [][]string, class string) (newRecords [][]string) {
//make a new matrix instance with 0 lines
newRecords = make([][]string, 0)
//for each line in your matrix(records)
for l := range records {
//if the value in the last index of this line(that is the class) is iguals
//this method's parameter class
package main
//[...]
func divideInPercent(records [][]string, percent float32) (newRecords [][]string, residue [][]string) {
//multiply the number of lines by percent(float number that is < 1.0)
//"i" now is the lines quantity to get in the dataset (records)
i := float32(len(records)) * percent
//while i is bigger than 0
for i > 0 {
//so get the line index (i)
package main
//[...]
func main() {
//[...]
var train [][]string
var test [][]string