Author Topic: (lng, lat) <=> (x, y) photo pixel coordinates conversion  (Read 3834 times)


  • Guest
(lng, lat) <=> (x, y) photo pixel coordinates conversion
« on: December 10, 2017, 03:50:45 AM »
I'm trying to achieve two coordinate conversions:

1. Using (x, y) from a photo, determine the corresponding (lng, lat) coordinates.

For this part, I believe the code posted here should work:

Code: [Select]
chunk =
camera = chunk.cameras[0]
point2D = PhotoScan.Vector([imgX,imgY]) # coordinates of the point on the given photo
sensor = camera.sensor
calibration = sensor.calibration
x = chunk.point_cloud.pickPoint(, camera.transform.mulp(sensor.calibration.unproject(point2D)))


Code: [Select]
result =

I can't find the "pickPoint" function in the API Reference document, but would this return the expected result?

2. Using a (lng, lat) to determine the corresponding (x, y) pixel coordinates in each photo of the project.

For this case, I was thinking on creating a Marker to simplify the code

Code: [Select]
chunk =
pointWorld2D = PhotoScan.Vector([lng, lat])
x = crs.unproject(pointWorld2D)
chunk.addMarker(point = x)

and then loop over "marker.projections" to obtain the (x, y) pairs for each camera.

Am I on the correct path?


P.S: This post also gave me a couple of clues:


  • Guest
Re: (lng, lat) <=> (x, y) photo pixel coordinates conversion
« Reply #1 on: December 10, 2017, 06:25:15 AM »
Ok, I think I got it.

1. From (imX, imY) pixels on camera 0 to v_out_world = (lng, lat, alt) on world map

Code: [Select]
doc =
chunk = doc.chunk
camera = chunk.cameras[0]
point2D = PhotoScan.Vector([imX, imY])
sensor = camera.sensor
v = chunk.model.pickPoint(, camera.transform.mulp(sensor.calibration.unproject(point2D)))
v_t = chunk.transform.matrix.mulp(v)
v_t.size = 3
v_out_world =

2. From v_proj = (lng, lat, alt) on world map to camera v_out_pix = (x, y) pixels

Code: [Select]
v_unproj =
v_inv = chunk.transform.matrix.inv().mulp(v_unproj)
v_inv.size = 3
v_out_pix = sensor.calibration.project(camera.transform.inv().mulp(v_inv))