I have captured each frame of a video .Then I have used background subtraction to eliminate the background .Now I have the people with their bounding boxes.I have to compare the colour features of this person with the features of the same person in another video. The person will be wearing the same dress in every video. I am developing this in opencv 2.4 and python 2.7
Here it the background subtraction code I have used:
import numpy as np
import cv2
cap = cv2.VideoCapture('test.mp4')
fgbg = cv2.BackgroundSubtractorMOG()
j=0
count = int(cap.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT))
while j<count:
ret, frame = cap.read()
cmask = fgbg.apply(frame)
fgmask = cmask.copy()
floodfill =cmask.copy()
(cnts, _) = cv2.findContours(cmask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
cnts = sorted(cnts, key = cv2.contourArea, reverse = True)
if(len(cnts)!=0):
h, w = floodfill.shape[:2]
mask = np.zeros((h+2, w+2), np.uint8)
cv2.floodFill(floodfill, mask, (0,0), 255)
floodfill_inv = cv2.bitwise_not(floodfill)
fgmask=fgmask|floodfill_inv
# screenCnt = None
print "K="+str(j)
j+=1
for cnt in cnts:
x,y,w,h = cv2.boundingRect(cnt)
cv2.rectangle(fgmask,(x,y),(x+w,y+h),255,4)
if(len(cnts)!=0):
cv2.imshow('frame',fgmask)
k = cv2.waitKey(30) & 0xff
if k == 27:
break
cap.release()
cv2.destroyAllWindows()
Is there any method for comparing objects based on the colour?
I have not used face recognition because I don't have pictures of the people in the video
Any help would be appreciated