检测用户是否在汽车中移动 [英] Detecting if a user is moving in a car

查看:219
本文介绍了检测用户是否在汽车中移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


通知:此问题最初是在Apple在iOS SDK中引入运动检测硬件和相关API之前发布的。然而,这个问题的答案仍然相关。

NOTICE: This question was originally posted before Apple introduced motion-detection hardware and associated APIs in the iOS SDK. Answers to this question, however, remain relevant.






我正在创建一个iPhone iOS应用程序,涉及跟踪用户的跑步和/或步行。用户跑步和散步的记录结果保持诚实非常重要。我需要一种方法来捕捉可能在使用汽车时作弊(或意外地离开跟踪器)的用户。


I'm creating an iPhone iOS app which involves tracking a user's running and / or walking. It is very important that the recorded results of the users runs and walks remain honest. I need a way to catch a user who may be cheating (or accidentally have left the tracker on) when using a car.

检查用户是否正在驾驶或骑车在车里我首先考虑过这两个检查,但是确实都不能确定用户是否在车内(到某一点)。

To check if the user is driving or riding in a car I first thought of these two checks, however neither can really determine if the user is in a car or not (to a point).


  1. 使用以下方法检查用户的当前速度。如果用户旅行速度超过20英尺MPH,那么我可以假设用户在车内:

  1. Check the user's current speed in the following method. If the user is traveling faster than 20-ish MPH, then I could assume that the user is in a car:

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
      CLLocation *recentLocation = [locations lastObject];
      recentLocation.speed; //If speed is over 20 MPH, assume the user is not on their feet.

然而,我不确定这是否真的是一个很好的检查,因为人们已被记录下去比之前更快。这是一个很好的检查还是我应该使用其他东西?

However, I'm not sure if this is really a good check because people have been recorded to go faster than that before. Is this a good check or should I use something else?

确定用户使用核心动作框架。如果用户加速超过一定的费率,那么我可以假设用户正在车内旅行。

Determine how fast the user is accelerating using the Accelerometer and Motion APIs provided with the Core Motion Framework. If the user accelerates over a certain rate, then I could assume the user is traveling in a vehicle.

这些是假设是否正确?我想我真正的问题是:有没有更好的方法来检测用户是否在车内移动 - 如果是这样的话?。如果没有,那么这些检查是否适用于这种情况,或者这对于实际 快速的某些用户来说是否会烦恼? CoreMotion是否适合用它来执行此操作?

Are these assumptions correct? I guess my real question is this: Is there any better way to detect if the user is moving in a vehicle - if so how?. And if not, then are these checks suitable for this case or would this just be annoying to some users who are actually that fast? Is CoreMotion the proper API to do this with?

编辑:新的iPhone 5S M7协处理器提供更准确的移动检测。任何人都可以解释如何使用新的M7 API吗?

The new iPhones 5S M7 Coprocessor provides more accurate movement detection. Could anyone explain how to use the new M7 APIs?

推荐答案

关于猜测的智慧(或缺乏智慧)的所有建议来自位置数据的运动状态仍然适用。但关于Core Motion和M7的更新......

All the advice about the wisdom (or lack thereof) in guessing about motion states from location data still applies. But regarding your update about Core Motion and M7...

是的,您可以在具有M7,M8,M9等运动协处理器(*)的设备上使用Core Motion了解用户是否可能正在驾驶。

Yes, you can use Core Motion on devices with an M7, M8, M9, etc motion coprocessor(*) to get an indication of whether the user might be driving.


  1. 创建 CMMotionActivityManager 对象(使用其类方法后) isActivityAvailable 确定您是否拥有M7(+)功能,并启动活动更新或查询最近的活动。

  2. 检查返回的 CMMotionActivity 对象'汽车属性,以查看iOS是否认为该用户是/在车内。

  3. 没有第三步。

  1. Create a CMMotionActivityManager object (after using its class method isActivityAvailable to determine whether you you have M7(+) features), and either start activity updates or query it for recent activities.
  2. Check the returned CMMotionActivity objects' automotive property to see if iOS thinks the user is/was in a car.
  3. There's no step three.

然而,就像GPS的推论一样,你仍然应该把这些信息带到一块盐。 CoreMotion API为您提供iOS对用户活动的最佳猜测,但不能保证它100%准确。 (例如,我不确定乘坐火车是否可以算作汽车。另请注意,不同的活动类型并不相互排斥。)对您的应用来说最好检查您感兴趣的活动类型,而不是尝试排除您不想要的活动类型。

Like the GPS inferences, though, you should still take this information with a grain of salt. CoreMotion APIs give you iOS' best guess as to the user's activity, but there's no guarantee it's 100% accurate. (For example, I'm not sure if riding a train might count as automotive. Also note that the different activity types are not mutually exclusive.) It's better for your app to check for the activity types you're interested in than to try to exclude the ones you don't want.

( *)M7设备是带有A7 SoC的设备:iPhone 5s,iPad Air,iPad mini 2. M8是A8,M9是A9等。简而言之,自2013年秋季以来推出的每款iOS设备都不包括iPhone 5c。

(*) M7 devices are those with the A7 SoC: iPhone 5s, iPad Air, iPad mini 2. M8 is A8, M9 is A9, etc. In short, every iOS device introduced since Fall 2013, excluding iPhone 5c.

这篇关于检测用户是否在汽车中移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆