Esempio n. 1
0
def get_emojis():
    emojis_folder = 'hand_emo/'
    emojis = []
    for emoji in range(len(os.listdir(emojis_folder))):
        print(emoji)
        emojis.append(cv2.inread(emojis_folder+str(emoji)+'.png',-1))
    return emojis
Esempio n. 2
0
 def __getitem__(self, idx):
     img = cv2.inread(self.all_train_label_list[idx], cv2.IMREAD_GRAYSCALE)
     img = np.expand_dims(img, 0)
     img = (img/255.).astype(np.float32)
     label = self.all_train_label_list[idx]
     label = np.eye(self.n_classes)[label].astype(np.float32)
     return img, label
Esempio n. 3
0
import cv2
import numpy as np
image1 = cv2.inread("1.jpg")
image2 = cv2.inread("2.jpg")

difference = cv2.subtract(image1, image2)
result = not np.any(difference)

if result is True:
    print("the images are the same")
else:
    cv2.imwrite("result.jpg", difference)
    print("the images are different")
Esempio n. 4
0
from google.colab.patches import cv2_imshow
import cv2
img = cv2.inread('/image.jpg')

cv2_inshow(img)
Esempio n. 5
0
import cv2
im_g = cv2.inread('smallgray.png', )
Esempio n. 6
0
# Need install OpenCV
# pip install opencv-python

import cv2

# Load the cascade
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')

#Read the input image
img = cv2.inread('test.jpg')

# Convert into gravyscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# Detect faces
faces = face_cascade.detectMultiScale(gray, 1.1, 4)

# Draw rectangle around the faces
for (x, y, w, h) in faces:
    cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)

# Display the output
cv2.imshow('img', img)
cv2.waitKey()