我正在为我的学校项目做学生检测。这是我第一次使用OpenCV和Python,使用Python version 3.4.2和opencv3.1.0。
我用的是覆盆子皮黑相机,我得到了很好的图像。
但我不能很好地察觉瞳孔(因为有闪光、睫毛和阴影)。
我在网上引用了一些代码,下面是代码的一部分。...
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (5, 5))
# capture frames from the camera
for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):
image = frame.array
cv2.imshow("image", image)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
retval, thresholded = cv2.threshold(gray, 80, 255, 0)
cv2.imshow("threshold", thresholded)
closed = cv2.erode(cv2.dilate(thresholded, kernel, iterations=1), kernel, iterations=1)
#closed = cv2.morphologyEx(close, cv2.MORPH_CLOSE, kernel)
cv2.imshow("closed", closed)
thresholded, contours, hierarchy = cv2.findC