Taking photo every 66 milliseconds on Android phone for colour analysis (Heart Rate Monitor)
Asked Answered
R

1

6

I'm doing a final year project at university which involves making a medical application for Android, as a practice I have to make a heart rate monitor app.

I have worked out that the best way to do this is to look for colour changes in your blood when holding the camera against your finger with the flash switched on.

This is where the problems come into play, is it possible to take a photo every 66 milliseconds on the camera, then compare each pair of photos for any intensity changes in order to count a heart beat? or am I better off recording a video and analysing each frame looking for a change.

Heck is it even possible to just look at the video preview and compare each frame.

The questions I need answering for this problem are neatly listed below

  • What is the best method for this, taking photos, recording video or looking at the live preview.

  • Is there any posts or pages I can visit on the internet where people have attempted similar things

  • Anyone got a basic method I should do to get two images that I can compare within the time frame.

  • Lastly If I do take the basic take a picture every 66 milliseconds approach, what can I do to ensure the picture is taken at the correct time intervals

Reduction answered 6/9, 2011 at 12:45 Comment(3)
sweet idea. Maybe more realistic is to hold up a stethoscope to the microphone.Taddeusz
Hi Antony, I’m working on similar solution, I calculate average of an colour in the image and then I try to find some pattern and detect the frequency, however I found out that this is to simple and calculating average value of an colour in the image is not sufficient, do you have some other solution to this problem that you can share?Discreditable
Hey michael, I give up on this as my phone broke, however you do need to do some extra stuff to work out the heart rate, the main one bit is centered around converting the frequency changes in intensity values to a Hz frequency on a graph. to do this you can use a "fast fourier transform", I'm not too sure how though to use it though, however doing that will give you back the Hz which translates into heart rate :)Reduction
D
4

What is the best method for this, taking photos, recording video or looking at the live preview.

I would think that live preview would be the right answer. Taking photos is not -- they will not happen anywhere near that quickly. Recording video and post-processing it would be possible, but I fail to see how this will be applicable for a real-time heart monitor.

Is there any posts or pages I can visit on the internet where people have attempted similar things

You can examine the Barcode Scanner source code, which uses the live preview to scan for barcodes.

Lastly If I do take the basic take a picture every 66 milliseconds approach, what can I do to ensure the picture is taken at the correct time intervals

Android is not a hard RTOS. AFAIK it will be impossible for you to precisely time things to be 66 milliseconds.

Deservedly answered 6/9, 2011 at 15:11 Comment(4)
Fantastic thank you this is amazingly helpful, I completely forgot that I could look at the source code for the Bar Code scanner, Absolutely fantastic! Yes you are right I think ripping the images from the live preview would be fantastic way of doing it, as I would be able to detect a change in intensity right away, hence producing an accurate heart rate estimation. Any other Comments,Ideas or Support would be much welcome from anyone else or yourself. Also I have been meaning to get one of your books, which one do you think might be most useful to me? Thank you for your enlightenmentReduction
@Antony: "I would be able to detect a change in intensity right away" -- so long as 66ms isn't a hard requirement. I'm not quite sure where 66ms comes from, as at least my heart beats a bit faster than 16bps :-) "Also I have been meaning to get one of your books, which one do you think might be most useful to me?" -- My Advanced book covers the Camera class, but not the live preview API. If you have further questions about the books, hit me up on Twitter or email or something. (but thanks for your interest!)Deservedly
Hey CommonsWare, Just checked out your different books, all of them seem to have something that I might find useful in the near future. the $40 subscription might be one of the first things I spend my nice shiny student loan on. The private office hour also would be helpful if I become really stuck with something when I attempt the real medical app that I plan to do. Also I did some research online and noticed that the live preview returns a bitmap that uses an odd colour space, would you happen to know anything about converting it to RGB?Reduction
@Antony: "Also I did some research online and noticed that the live preview returns a bitmap that uses an odd colour space, would you happen to know anything about converting it to RGB?" -- afraid not. That's not my area of expertise. You might consider opening a fresh StackOverflow question if there are no existing answers on the topic. You are not the first one to use the live preview, so I would imagine that there is already some material on that written up somewhere... just not by me. :-)Deservedly

© 2022 - 2024 — McMap. All rights reserved.