Ask Your Question
0

calculating how many times white pixels appear form frame difference

asked 2015-12-06 05:40:43 -0600

tofi gravatar image

Hi

I'm now working on this steps to detect blinks

  1. calculate Frame difference = current frame - previous frame using (cv2.absdiff)

  2. convert the result of Frame difference to binary image (threshold cv2.threshold) and cv2.countNonZero() ) .

  3. Eroding and Dilating (cv2.morphologyEx (openmorphologyEx )

with these steps the result is when the eyes blinks there is white pixels like the image below :

image description

.

when the eyes open there is not whote pixels only black output like image below

image description

Now I want to calculate rate of blinks based on white pixels when eyes blinks . for example a counter that counts

how many these white pixels detected . thanks for help

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-12-06 09:53:08 -0600

Brandon212 gravatar image

You can use countNonZero() which returns an int of how many nonzero pixels are in a frame. To account for noise you could use some kind of minimum score that's required before you count the eyes as present, but just put that in your loop and you'll be set.

edit flag offensive delete link more

Comments

I have used countNonZero() like this :

delta_count = cv2.countNonZero(frame_delta) print delta_count it shows different numbers like : 1151 878 751 891 868 I don't know how to classify them . is there any other ways like contours ?

tofi gravatar imagetofi ( 2015-12-06 10:03:28 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-12-06 05:40:43 -0600

Seen: 564 times

Last updated: Dec 06 '15