Skip to content

Instantly share code, notes, and snippets.

import cv2
import dlib
import numpy as np
initial_image = cv2.imread('images/image9.jpg')
initial_image_in_rgb = cv2.cvtColor(initial_image, cv2.COLOR_BGR2RGB)
reference_image = initial_image_in_rgb.copy()
classifier_path = dlib.shape_predictor('classifier/shape_predictor_68_face_landmarks.dat')
frontal_face_detector = dlib.get_frontal_face_detector()
import cv2
group_of_people_image = cv2.imread('images/image7.jpg')
frontal_face_classifier = cv2.CascadeClassifier('classifier/haarcascade_frontalface_default.xml')
image_in_gray_scale = cv2.cvtColor(group_of_people_image, cv2.COLOR_BGR2GRAY)
faces = frontal_face_classifier.detectMultiScale(image=image_in_gray_scale, scaleFactor=1.3, minNeighbors=6)
for (x_axis, y_axis, weight, height) in faces:
cv2.rectangle(group_of_people_image, (x_axis, y_axis), (x_axis + weight, y_axis + height), (255, 0, 0), 2)
f = open('workfile' ,'w')
new_content = 'someContent'
f.write(new_content)
f.flush()
...
f = open('workfile' ,'w')
new_content = 'someContent'
f.write(new_content)
f.seek(0)
line = f.readline()
print line
>> someContent
f = open('workfile' ,'w')
new_content = 'someContent'
f.write(new_content)
file_content = open('dados/some_sb.csv', encoding='utf-8', mode='w')
new_content = '1,someContent'
file_content.write(new_content)
f = open('workfile' ,'r')
f.readline()
f.readlines()
f.read()
file_content = open('dados/some_sb.csv', encoding='utf-8', mode='w')
new_content = '1,someContent'
file_content.write(new_content)
f = open('workfile' ,'r', encoding='utf-8')
import elasticsearch
import elasticsearch_dsl
from elasticsearch_dsl.connections import connections, get_connection
import config as config_module
config = config_module.get_config()