how to indentify finger is on the camera lens or not in android?

2.5k views Asked by At

I am trying to measure Heart Beat using the camera in android device.

As far as i see, Placing your finger tip on the camera lens and watching the changes in frames in camera. I have tried the application here but it does not seem to be correct.

2

There are 2 answers

1
hims_3009 On BEST ANSWER

Please check This Post on Google Code

http://code.google.com/p/android-heart-rate-monitor/issues/detail?id=1#c22

It Explains how to check finger is on the camera or not.

"For anyone interested, I figured out how to detect whether the user has his finger placed on the camera or not. In the imageProcessing.java, in the decodeYUV420SPtoRedAvg() method, we calculate the average value of the pixels of the red color. Doing a small experiment, I found out that when the user has his finger placed on the camera lens, the average has a value of > 200. In other cases, the average value is <200. thus, in the HeartRateActivity you can add an if statement after the call of the decodeYUV420SPtoRedAvg(), to find whether the value returned is >200 or < 199. You can use this to display an alert box or something similar to guide the user to place his finger on the camera lens."

0
Gaurav On

One Solution

In android, We can open camera in background so we can check colour or RGB when we cover entire camera using our finger tap.

When we get colour same colour at that time we know that camera totally cover with finger tap and now you can measure heart rate.

Other solution

  1. Grab image frame from camera
  2. Compare image metrics of frame to previous frame. You need to figure out what metrics to use: brightness, color, etc.
  3. If metrics are significantly different in one direction, then you have a heartbeat.
  4. Pause some indeterminate amount of time.
  5. Go to 1

Other demo for heart rate if useful HeartRate Demo

All you have to do is open the HeartRateMonitor App and then hold the tip of your index finger over the camera lens of your phone. The entire camera preview image should be red with a lighter area where the tip of your finger is touching. Do not press too hard or you will cut off circulation which will result in an inaccurate reading.

After a second or two, you should see the Android icon on the top of the screen start to flash red when it senses a heart beat. After ten seconds it will compute your heart rate and update the number next to the Android icon. It'll take between ten and thirty seconds to get an accurate heart rate.