This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import sys | |
import os | |
import random | |
import time | |
colArr= videoArr() | |
play=False | |
playing=False; | |
#cascade for face finding |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def videoArr(): | |
colArr=[0 for x in range(4)] | |
colArr[0]= "blue.MP4" | |
colArr[1]= "green (1).MP4" | |
colArr[2]= "pink.MP4" | |
colArr[3]= "white.MP4" | |
return colArr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def randomVideo(colArr): | |
rand= random.randint(0,2) | |
answer= colArr[rand] | |
return answer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def videoPlay(str): | |
try: | |
os.startfile(str) | |
except Exception, e: | |
print str(e) | |
#closes VLC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def selectionSort(arr): | |
for i in range(len(arr)): | |
minId= i | |
for j in range(i+1, len(arr)): | |
if(arr[minId][0]>arr[j][0]): | |
minId=j | |
arr[i], arr[minId]= arr[minId], arr[i] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def colorAnswer(r,g,b): | |
colArr= colorArray() | |
for i in range(len(colArr)): | |
colArr[i]= (colorDifference(r,g,b,colArr[i][0], colArr[i][1],colArr[i][2]),colArr[i][3]) | |
selectionSort(colArr) | |
return(colArr[0][1]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def colorArray(): | |
colArr=[[0 for x in range(3)] for y in range(12)] | |
#these colors are from darkest to lightest skin tone. The number at the end is to tell which value we are considering after sorting | |
#black skin | |
colArr[0]=[117,85,61,0] | |
colArr[1]=[159,136,121,1] | |
#bronze Skin | |
colArr[2]=[156,115,69,2] | |
colArr[3]=[182,157,69,3] | |
#medium brown skin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def colorDifference(r,g,b,r1,g1,b1): | |
red= abs((r-r1)**2) | |
blue= abs((b-b1)**2) | |
green= abs((g-g1)**2) | |
answer=math.sqrt(red+blue+green) | |
return answer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (x,y,w,h) in faces: | |
pic = cv.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2) | |
gray= cv.rectangle(gray,(x,y),(x+w,y+h),(0),2) | |
roi_gray = gray[y:y+h, x:x+w] | |
roi_color = img[y:y+h, x:x+w] | |
cv.imshow('pic',pic) | |
cv.waitKey(0) | |
cv.destroyAllWindows() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 as cv | |
import math | |
face_cascade= cv.CascadeClassifier('C:\Program Files\opencv\sources\data\haarcascades\haarcascade_frontalface_default.xml') | |
#direct path to the haarcascade, which is included in openCV | |
pic= cv.imread('face.jpg') | |
#the path to one image that OpenCV will convert to a numpy array | |
gray= cv.imread('face.jpg,0) |
NewerOlder