mpetroff / pannellum

Pannellum is a lightweight, free, and open source panorama viewer for the web.

Home Page:https://pannellum.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can measurement distance between two point on the panorama?

samedadl opened this issue · comments

Hi everybody,

I have a problem. How to measure the distance between two points in the panorama? I have camera coordinates (latitude, longitude, altitude). How can I find the distance of the points I click on the picture to the camera? As far as I've researched, the pannellum does not add a point cloud to the background and measure distance. Can we integrate a point cloud in .las format with Pannellum?

image

If I know the distance of the points p1 and p2 to the camera, I think I can calculate the distance using the angular distance and cosine theorem. Waiting for your recommendations.

Best regards.

You are correct that Pannellum does not support point clouds.

However, a point cloud would not be very helpful on its own. To determine distance from the camera, you need a surface to cast a ray to, so you first need to create a mesh from your point cloud using a technique such as Poisson reconstruction. If you then loaded this mesh into the browser with something such as three.js (and possibly three-mesh-bvh for better performance), you could do the necessary ray casting using the camera position and the yaw and pitch of the click location in the panorama. If you were to take such an approach, I would use Draco to compress the mesh, since it's a much more efficient format to deal with in web browsers than LAS.

An alternate approach, which I would tend to use instead, would be to take the mesh and render equirectangular depth maps for each panorama. I would store these as PNGs. If 8-bit fixed-precision depth information is sufficient, this could be stored in a grayscale image. If more precision is necessary, you could use a grayscale image with transparency for 16 bits (either integer or half-precision floating point). After loading this depthmap into a <canvas> element, retrieving the depth at a given yaw and pitch is as simple as converting to x / y coordinates, which is a trivial operation for equirectangular images, and looking up the color of that pixel in the <canvas>.