Esempio n. 1
0
def getIris(frame):
	iris = []
	copyImg = cv.CloneImage(frame)
	resImg = cv.CloneImage(frame)
	grayImg = cv.CreateImage(cv.GetSize(frame), 8, 1)
	mask = cv.CreateImage(cv.GetSize(frame), 8, 1)
	storage = cv.CreateMat(frame.width, 1, cv.CV_32FC3)
	cv.CvtColor(frame,grayImg,cv.CV_BGR2GRAY)
	cv.Canny(grayImg, grayImg, 5, 70, 3)
	cv.Smooth(grayImg,grayImg,cv.CV_GAUSSIAN, 7, 7)
	circles = getCircles(grayImg)
	iris.append(resImg)
	for circle in circles:
		rad = int(circle[0][2])
		global radius
		radius = rad
		cv.Circle(mask, centroid, rad, cv.CV_RGB(255,255,255), cv.CV_FILLED)
		cv.Not(mask,mask)
		cv.Sub(frame,copyImg,resImg,mask)
		x = int(centroid[0] - rad)
		y = int(centroid[1] - rad)
		w = int(rad * 2)
		h = w
		cv.SetImageROI(resImg, (x,y,w,h))
		cropImg = cv.CreateImage((w,h), 8, 3)
		cv.Copy(resImg,cropImg)
		cv.ResetImageROI(resImg)
		return(cropImg)
	return (resImg)
Esempio n. 2
0
def lighting_quality(img):
	try:
		img2, out_dict = region_of_interest(img)
		img3 = cv2.GetSubRect(img,GetImageROI(img2))
		img4 = cv2.cvtColor(img2, cv2.COLOR_BGR2LAB)
		roi = cv2.cvtColor(img3, cv2.COLOR_BGR2LAB)
		background = cv2.Sub(img2,roi) # There may be an issue with the arrays not being of the same size.
		b_background = np.mean(background[:,:,0]) # Mean might not be completely correct, mean of an array with many 0s in it, which are counted in the mean.
		b_roi = np.mean(ROI[:,:,0])
		lighting_measure = abs(np.log(b_roi/b_background))
		out_dict = {"name" : "lighting_quality", "value" : lighting_measure}
	except:
		out_dict = {}
		raise
	return out_dict
Esempio n. 3
0
def simplicity(img, gamma=0.1):
  #NOTE Probably f****d up.
	try:
		img2, out_dict = region_of_interest(img)
		img3 = cv2.GetSubRect(img,cv2.GetImageROI(img2))
		background = cv2.Sub(img2,ROI) # There may be an issue with the arrays not being of the same size.
		# Need to quantize the image into 16 channels.
		hist,_binedges = np.histogram(background, bins=4096)
		max_bound = max(list(hist))
		color_div = 0.0
		for item in list(hist):
			if item >= gamma*max_bound:
				color_div += item*item
		simplicity_measure = np.sqrt(color_div)/4.096 
		out_dict = {"name" : "simplicity", "value" : simplicity_measure}
	except:
		out_dict = {}
		raise
	return out_dict
Esempio n. 4
0
 def process(self, img, ctx):
     tmp = ctx[self.name]
     sub = cv2.Sub(img, tmp)
     return sub