mapbox / mapbox-vision-android

Other
50 stars 43 forks source link

Is it possible to add POI details on the Example AR navigation project? #221

Closed estherooi closed 4 years ago

estherooi commented 4 years ago

Hi, I am a student doing my final year project, I managed to run the AR navigation project, however I would like to add visual context to the AR navigation, can anyone provide me step by step guidance in this? thanks a lot!

kiryldz commented 4 years ago

Hi @estherooi . What do you mean by visual context? Basically there are now two types of AR objects: lane and maneuver fence. API is present to customize them a bit. Please take a look at this link for a small sample video and at API reference.

estherooi commented 4 years ago

img

Hi @kiryldz what I mean by POI was the little icon showing the details of the particular building. Is that possible to create it? Thanks!

kiryldz commented 4 years ago

If we assume that POI objects are 2D you could do the following. Input: POI's latitude (poiLat), POI's longitude (poiLon), POI's ground offset in meters (poiOffset).

  1. Get POI's frame coordinates
    var worldPos = VisionManager.geoToWorld(GeoCoordinate(poiLat, poiLon))
    worldPos.z += poiOffset
    val pixelCoords = VisionManager.worldToPixel(worldPos)
  2. Rough scale of POI should be inversely proportional to worldPos.x:
    val poiScale = if (worldPos.x >= 1) 1.0f / worldPos.x else 0.0f
  3. As a result you have POI's frame coordinates (x, y taken from VideoSourceListener.onNewFrame()) and scale. This should be enough for you to implement custom view of frame size and display frame itself + POI on it.
estherooi commented 4 years ago

@kiryldz alright, i will try to it. Thanks a lot!

estherooi commented 4 years ago

hi @kiryldz how to create 2D marker at destination when user arrive?

  1. I tried to use the code that you mention var worldPos = VisionManager.geoToWorld(GeoCoordinate(poiLat, poiLon)) worldPos.z += poiOffset val pixelCoords = VisionManager.worldToPixel(worldPos) but I don't really understand in kotlin. Is there any Java version?
  2. WorldCoordinate worldPos = VisionManager.geoToWorld(new GeoCoordinate(Rlat, Rlong)); double z = worldPos.getZ(); PixelCoordinate pixelCoord = VisionManager.worldToPixel(worldPos); Is it like this if the code is in Java?
  3. Is there any Java project that I can use it as a reference? I can't find it although I already search through internet. Thank you
kiryldz commented 4 years ago

Hi @estherooi - please check POI 2D example.

https://github.com/mapbox/mapbox-vision-android/blob/dev/Examples/src/main/java/com/mapbox/vision/examples/POIActivity.java

kiryldz commented 4 years ago

Closing due to inactivity.

yunikkk commented 4 years ago

I'd also added that we now have detailed tutorial about drawing POIs, https://docs.mapbox.com/help/tutorials/android-vision-poi-drawing/