मैं अपने स्कूल प्रोजेक्ट के लिए छात्र पहचान कर रहा हूं। पाइथन संस्करण 3.4.2 और ओपनसीवी 3.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.findContours(closed, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)
drawing = np.copy(image)
cv2.drawContours(drawing, contours, -1, (255, 0, 0), 2)
for contour in contours:
area = cv2.contourArea(contour)
bounding_box = cv2.boundingRect(contour)
extend = area/(bounding_box[2] * bounding_box[3])
# reject the contours with big extend
if extend > 0.8:
continue
# calculate countour center and draw a dot there
m = cv2.moments(contour)
if m['m00'] != 0:
center = (int(m['m10']/m['m00']), int(m['m01']/m['m00']))
cv2.circle(drawing, center, 3, (0, 255, 0), -1)
# fit an ellipse around the contour and draw it into the image
try:
ellipse = cv2.fitEllipse(contour)
cv2.ellipse(drawing, box=ellipse, color=(0, 255, 0))
except:
pass
# show the frame
cv2.imshow("Drawing", drawing)
...
इनपुट छवि।:
आउटपुट छवि:
ऊपर दिखाए गए अनुसार, उस छवि के उन हिस्सों को कैसे हटाया जा सकता है जो छात्र से संबंधित नहीं हैं?
उत्तरों के अलावा, किसी भी संकेत का भी स्वागत है।
संबंधित: [numpy में vectorized आँख ट्रैकिंग एल्गोरिथ्म बढ़ाता है] (https://stackoverflow.com/questions/35996257/speeding-up-vectorized-eye-tracking-algorithm-in-numpy) । आप परिपत्र की जांच भी कर सकते हैं ([उदाहरण कोड] (https://github.com/Itseez/opencv/blob/3.1.0/modules/features2d/src/blobdetector.cpp#L222))। – Catree
अन्य विकल्प: [HoughCircles] (http://docs.opencv.org/3.1.0/dd/d1a/group__imgproc__feature.html#ga47849c3be0d0406ad3ca45db65a25d2d) के साथ सीधे सर्कल का पता लगाएं और/या यदि अंदर का क्षेत्र गहरा है तो केवल समोच्च रखें बाहर। यदि आंख हमेशा केंद्रित होती है और उसी दूरी पर, आप रुचि के क्षेत्र (आरओआई) को भी परिभाषित कर सकते हैं + क्षेत्र का उपयोग करें। – Catree
मैं बाइनरी छवि पर [erode] (http://docs.opencv.org/2.4/modules/imgproc/doc/filtering.html?highlight=erode#erode) का उपयोग करूंगा और फिर बस [HoughCircles] (http: //docs.opencv.org/2.4/doc/tutorials/imgproc/imgtrans/hough_circle/hough_circle.html) छवि में सबसे महत्वपूर्ण सर्कल का पता लगाने के लिए। – 0x90