1

Guyz, I need to show the locations(ex restaurants, theaters, banks etc) on the camera preview when I move the camera around me. I know how to get the locations (ex from foursquare or Google maps) and I also know how to open the camera preview. I just don't know how to link these two. I googled it, but did not get a helpful post maybe because my english is not good.

So guys I need your help, if you know any post regarding this issue please be kind enough to comment it.

Thanks in advance.

EDIT: Real Time Camera Preview

------------------------------------------------------------------------------
|                                                      Theater                              |
|                                                                                                |
|    Bank                                                                                    |
|                                                                      Restaurant         |
|                                                                                                |
|                                                                                                |
|                                                                                                |
|                                                                                                |
|                                                                                                |
------------------------------------------------------------------------------


Pardon me I am less than 10 reputations, so can not upload images.
Hope this will help to understand my question.

Cham
  • 787
  • 3
  • 11
  • 25
  • It's not clear what it is you are trying to do. Please be more descriptive so that we can help. – dani Mar 09 '13 at 07:25
  • I want to build an android application when the user start the app it opens the camera preview and shows the locations(banks, restaurants etc) around him when he/she moves the camera. Simply I want to show him/her what places around him/her. – Cham Mar 09 '13 at 07:37

3 Answers3

5

I did a similar thing on Android, too. Let's assume that what you want to print on preview is called target.

You definitely know what's the coordinate of those targets including latitude longitude and altitude. Assuming those coordinates are tx, ty and tz, respectively, and the current location of the device is x, y and z.

Based on colinearity equations in photogrammetry, the screen coordinates of the target (sx, sy) are:


sx = f*{[m11(x-tx)+m12(y-ty)+m13(z-tz)]/[m31(x-tx)+m32(y-ty)+m33(z-tz)]}

sy = f*{[m21(x-tx)+m22(y-ty)+m23(z-tz)]/[m31(x-tx)+m32(y-ty)+m33(z-tz)]}


where f is focal length, and m11 ~ m33 are values in rotation matrix based on device orientation. Screen coordinates must be applied with an affine transformation to turn them into screen column and rows for printing usages.

This is what I was trying to do, but I found out that focal length never changed after autofocus is applied. So I do it in an alternative way.

  1. Get the screen size(or preview size) and camera horizontal and vertical angle of your device.
  2. Calculate the Azimuth and Inclination angle between device and the target.
  3. Interpolate the screen coordinates based on these angles and screen sizes.
  4. Print targets on screen. I set up a set of imageviews and textviews to do the same thing.

For real time updates of these targets, try to update them in onSensorChanged()

Hope these help. :)

高崇軒
  • 117
  • 2
  • 8
  • 1
    can you please proved me an example. – Sai Aug 24 '16 at 13:05
  • So it's more or less mathematical calculations. Interesting. I will dig deep into this and get back to you although now we have advanced modules like augmented reality which also provides solutions for the same. – Tushar Gogna Jun 05 '19 at 12:42
2

The faq clearly says that you shouldn't ask poorly scoped questions. What you are asking is not 'how to link them' because what you need is by no means a short and answerable question.

But I can recommend you to buy this book, it is pretty nice explained and guides the reader to accomplish almost exactly what you want to do: http://www.apress.com/9781430239451

Don't forget to download the several source projects the author included. Start from there and if you need help in more specific problems start a new and concise question.

Have a nice day.

0

You may be looking for a SurfaceView. I haven't made extensive use of it myself but I know that this is how the ZXing Barcode Scanner superimposes images over the camera preview. Checkout the developer guide:

http://developer.android.com/reference/android/view/SurfaceView.html

and also the ZXing source code for a real application:

https://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/CaptureActivity.java

dani
  • 237
  • 3
  • 7