eclipse Android心率监测器代码解释
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28115049/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android heart rate monitor code explanation
提问by Sidd
I found this code online for a heart rate monitor and I'm planning to use it as part of my project. I'm, however, having trouble understanding most part of the code as I'm new to Android. I am currently attending a course on Android but it's still in the basics and I have a deadline for the project. I would, hence, appreciate a proper explanation regarding the working of this code (explanation for the java files in the src folder would suffice). Thanks.
我在网上找到了这个心率监测器的代码,我打算将它用作我项目的一部分。但是,由于我是 Android 新手,因此无法理解大部分代码。我目前正在参加一门关于 Android 的课程,但它仍处于基础阶段,我有一个项目的最后期限。因此,我将感谢有关此代码工作的正确解释(对 src 文件夹中的 java 文件的解释就足够了)。谢谢。
Link for code - https://github.com/phishman3579/android-heart-rate-monitor
代码链接 - https://github.com/phishman3579/android-heart-rate-monitor
回答by Yefi Damti
I took this code also for merging heart rate monitor in my application and can contribute with the following explanation:
There are 3 main parts in the project:
Part 1, HeartbeatView:It extends View and contains the small android icon on top that changes color between green and red (the color is updated from HeartRateMonitor class once the color tendency changes). This class and its usage can be removed and has no impact on the heart monitor process.
Part 2, HeartRateMonitor:The activity that does all the work... Occupies the camera and flash light. Calls the camera's startPreview() to start receiving frames (snapshots) from the camera (see onPreviewFrame()). The frames are sent for analyzing and decoding (see the 3rd part below) in order to measure the amount of red and its direction (getting lighter or darker red).
Part 3, ImageProcessing:The class has 2 functions that decode the frame and returns the amount of red from the given frame data.
我也将这段代码用于在我的应用程序中合并心率监测器,并且可以提供以下解释:项目中
有 3 个主要部分:
第 1 部分,HeartbeatView:它扩展了 View 并包含顶部的小 android 图标,可在两者之间更改颜色绿色和红色(一旦颜色趋势发生变化,颜色就会从 HeartRateMonitor 类更新)。这个类和它的用法可以被删除,并且对心脏监测器进程没有影响。
第 2 部分,心率监视器:完成所有工作的活动......占用相机和闪光灯。调用相机的 startPreview() 以开始从相机接收帧(快照)(参见 onPreviewFrame())。发送帧进行分析和解码(参见下面的第 3 部分),以测量红色的数量及其方向(红色变浅或变深)。
第 3 部分,图像处理:该类有 2 个函数,可对帧进行解码并从给定的帧数据中返回红色量。
Hope it helps... enjoy :)
希望它有帮助...享受:)