mpetroff / pannellum

Pannellum is a lightweight, free, and open source panorama viewer for the web.
https://pannellum.org/
MIT License
4.27k stars 723 forks source link

How to turn the azimuth values of nearby points to the hotspot view inside the panoramic view. #1227

Closed OlivierLeal closed 1 month ago

OlivierLeal commented 3 months ago

Helllo there, how are you doing? I'm currently facing an issue: I have a GIS system, in which i've installed 360º view with Panellum. When using a tool and clicking a point in the mapp it shows up the picture related to that specific point, but I intend to create a hotspot of views to navigate between other pictures. Currently I can return the points within 5 meters of the middle point and the azimuth needed to know their positions. Captura de tela de 2024-07-26 09-51-51

My top point according to my azimuth calculation is at 46º and my bottom point is at 208º in relation to my middle point. I wish it to set the hotspots in this position as soon as I enter the panoramic photo. The yaw value is 0 by default, since its centered in the direction of the car so I don't know if it's possible to transfer the "world's" position to the 360º view.

In my PostGIS database, I have yaw, roll and pitch of each picture according to real North, as you can check in the following screenshot. Captura de tela de 2024-07-26 09-55-35

Captura de tela de 2024-07-26 10-11-20 Captura de tela de 2024-07-26 10-11-41

Thank you in advance :)

mpetroff commented 3 months ago

This sounds like a question for the developer of whatever GIS software plugin you're using. I have no idea what GIS software you're using, what plugin you're using, or how they work together. Combining the panorama's yaw value and the hot spot's azimuth should be simple arithmetic.

OlivierLeal commented 3 months ago

Do you have any idea about this arithmetic question? I would just pass this azimuth value from my nearby points into my 360 view so that they are aligned. It's just GIS-WEB software with Postgis database and openlayers for layer visualization.

mpetroff commented 3 months ago

Do you have any idea about this arithmetic question?

It's probably point headingpanorama yaw, but that makes assumptions about sign convention and assumes that the panorama yaw is referenced to the center of the image. The general form is point heading + panorama yaw + offset; if an offset is required, it's probably 180°, and it's possible that either the point heading or panorama yaw need a sign flip.

OlivierLeal commented 3 months ago

my car is at 206° degrees to the north, and has 2 points close together. One is 46° to the north of my point and the other is 208°. Values ​​like 46° or 208° are displaced, if I do 206 - 46 = 160, it is also displaced. I'm racking my brain over this.

mpetroff commented 3 months ago

Working under the assumption that the center of your panorama corresponds to your car's heading, the center of your panorama would be facing due north if your car was driving due north, i.e., it had a heading of 0°. In this case, hot spot yaw values would correspond directly to headings, e.g., a point at a heading of 5° would be to the right, and a point at a heading of 355° (−5°) would be to the left.

Now assume your car is heading due east, so it has a heading of 90°. Now the point to the right would have a heading of 95°, and the point to the left would have a heading of 85°. These points would still be ±5° from the center of the panorama, so the hot spot yaw values would again be 5° for the point to the right and 355° (−5°) for the point on left, i.e., point headingpanorama yaw, as previously stated.

For the example you gave, with a car heading of 206° and points at 46° and 208°, the hot spot yaw values would be 46° − 206° = −160° (mod 360 = 200°) and 208° − 206° = 2°, respectively.

OlivierLeal commented 3 months ago

Good morning friend, how are you? Yesterday, after several tests, I ended up discovering that my equation was only working incorrectly when the yaw is negative, I will check your comment and try to correct this today. I also encountered another problem, I was trying to iterate to make a hotspot for each point present within 5 meters but when using the hotspot view it breaks, I will show it in the following image.

image For each value present in my array, it would create a new hotspot.

image But in fact it happens that he doesn't add the points and ends up with this + symbol in yaw 0.

I'm programming in CoffeeScript.

carregarFoto: (url) =>
    yaw_hotspot = [10, 20]
    pannellum.viewer 'panorama',
    title: '07/2024'
    type: 'equirectangular'
    panorama: "http://localhost:8000/#{url}"
    autoLoad: true
    compass: true
    hotSpots: [
      for yaw in yaw_hotspot
        {
          pitch: 2,
          yaw: yaw,  
          type: 'scene',
          text: "Azimuth 182",
          URL: "http://localhost:3000"
        }
    ]

image

When I place my array and indicate the position it works perfectly. Example: yaw[0]

mpetroff commented 3 months ago

The plus symbol appears when the hotSpotDebug parameter evaluates as true. I'm not familiar with CoffeeScript, so I have no idea why your code is doing this. If you run the viewer's getConfig() method, it will return the configuration. I assume there's something malformed about it.

OlivierLeal commented 3 months ago

Ok friend, I managed to solve my problem. I'm now trying to show the yaw value on my screen so that it is updated as the user moves the panoramic photo, like this: image