22

Is it possible to draw a line from Point A(where user touched first) and Point B(where user touched second) in android over a camera.

The user can touch first point and rotate his camera in other direction to tap second point.

I am using gyroscope, accelerometer and magnetometer (Sensor Fusion) and I get x,y,z co-ordinates on touch.

But can we draw a 3D image on canvas where ever the user touches. Something similar to what MagicPlan app is doing.

Dropkick54
  • 283
  • 1
  • 2
  • 9
  • 1
    i suggest you use openGL for 3D drawings. – chipopo Feb 18 '15 at 10:30
  • Thanks @chipopo but the real concern is, is it possible to actually draw a line between two points given by gyroscope sensor. – Dropkick54 Feb 18 '15 at 10:32
  • Exactly what i need, just like MagicPlan app. but for iOS. :) – Akshit Zaveri Jun 04 '15 at 03:57
  • If you can use the gyroscope to record the rate of rotation and you know the time elapsed you should be able to calculate the total amount of rotation that took place and determine the distance between two points. ie, average rotation speed of 90 degrees/sec * 1500 ms = 135 degrees of rotation. Does this help? – JustWannaFly Jun 09 '15 at 15:34
  • @jdkorv11, but that is feasible only if the user rotates the device. If the user moves the device from one point to another, would this solution still work? – Akshit Zaveri Jun 10 '15 at 07:03
  • 3
    not for translation - you would have to double integrate the (accellerometer - estimated gravity vector) to get position. That data operates accurately for high frequencies, but poorly for zero tracking at low frequency, meaning the integration often introduces drift. Since you integrated twice, you get the drifting squared. – Henrik Jun 10 '15 at 11:51
  • How does one get the distance? Does MagicPlan use the autofocus tool built into the phones camera system? – zipzit Jun 10 '15 at 14:56
  • I dont know. @zipzit I am asking people, a lot of people, but no one can find the appropriate answer. Not even a hint.!!!!!!!! – Akshit Zaveri Jun 22 '15 at 13:11
  • Thinking about it for awhile.. I'm guessing the phone records its orientation at the time of the photograph. And with that knowledge (and the fact that floors of rooms are level) you can determine the distance to the corner. I doubt its an autofocus feature. Remember the target is a corner at the floor. You do have to know how tall the user is (camera height above floor) but I believe that is a setup input req'd to using MagicPlan. Isn't trigonometry awesome? – zipzit Jun 22 '15 at 17:44

1 Answers1

1

Thanks @chipopo but the real concern is, is it possible to actually draw a line >between two points given by gyroscope sensor.

Short answer,no. Gyroscope is a rate sensor, not a position sensor. You need to do math to get Points.

Since your in Android, I would recommend Orientation once you have this you need to decide on a radius that best fits your use case and also establish a reference orientation. Once you grab two orientations its up to you how to map shperical points to a 2d canvas.

One method I have used in the past is just plotting the delta pitch on Y and the delta heading on X, however you may need to think about what roll means to you in the context of what your app is trying to do.

You should probably use openGL, but you probably want a drawing library of some sort.

Andros
  • 95
  • 8
  • Correction: I forgot in the context of an Android phone, with the camera pointing out you are probably most interested in roll (user turns about vertical body) and pitch (user tilts up or down). in this case heading will be the angle that you will need to handle with care cause it might be meaningless or not depending on what your trying to do – Andros Jul 21 '15 at 23:14