Forum

Author Topic: Definition of image coordinate space: Origin == Center??  (Read 10312 times)

ju523m

  • Guest
Definition of image coordinate space: Origin == Center??
« on: February 09, 2012, 09:16:12 PM »
Hi all,

I have a question concerning ps.photo.projetct(point), which projects a 3D coordinate into a position on the image plane.
It returns a tuple like (image_x, image_y).

Is it correct, that the center of the image is the origin of the image coordinate system?

Am I doing something wrong, when I try to back-project  a projected 3D Coordinate from Map space  onto the
 image plane in the following way:

currentChunk = ps.app.document.activeChunk
gr_control = currentChunk.ground_control
geopro = gr_control.projection
point_geocentric = geopro.unproject(a_projected_point)
a_local_frame = geopro.localframe(point_geocentric)
point_geocentric.size = 4
point_geocentric.w = 1
point_local = a_local_frame * point_geocentric
point_local.size = 3
(image_x, image_y )= a_photo.project(point_local)


Thanks for your help and comments.

Cheers
Thomas

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15650
    • View Profile
Re: Definition of image coordinate space: Origin == Center??
« Reply #1 on: February 10, 2012, 05:24:46 PM »
Hello Thomas,

Image coordinate system (if you mean 2D photo as image) starts from the upper left corner.


And as for the back-projecting script, I think it should be something like the following example (you need to convert point coordinates from geocentric system into camera local coordinates using camera and chunk coordinate system transformation matrices):


Code: [Select]
currentChunk  = PhotoScan.app.document.activeChunk
point_geocentric = currentChunk.projection.unproject(a_projected_point)
point_geocentric.size = 4
point_geocentric[3] = 1

transform_matrix = currentChunk.transform * a_photo.transform
point_local = transform_matrix.t() * point_geocentric
point_local.size = 3
(image_x, image_y) = a_photo.project(point_local)
Best regards,
Alexey Pasumansky,
Agisoft LLC

s093294

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Definition of image coordinate space: Origin == Center??
« Reply #2 on: September 27, 2014, 11:10:40 PM »
I am not sure if the above code snippet is correct or its me that is doing something wrong.

(new to photoscan)

point_geocentric = currentChunk.projection.unproject(PhotoScan.Vector((676762.785,6123462.136,30)))

where the point above is x,y selected from imu log for thte first camera.

full code:

currentChunk  = PhotoScan.app.document.activeChunk
point_geocentric = currentChunk.projection.unproject(PhotoScan.Vector((676762.785,6123462.136,30)))
point_geocentric.size = 4
point_geocentric[3] = 1

a_camera = currentChunk.cameras[0];
transform_matrix = currentChunk.transform * a_camera.transform
point_local = transform_matrix.t() * point_geocentric
point_local.size = 3
(image_x, image_y) = a_camera.project(point_local)


where image coordinates are calculated to 0,0, which seem to be wrong as i expect them to be somewhat under my camera (photo taken towatch earth from a airplane with a hole in the buttom).


Documentation writes, camera.transformation as 4x4 matrix describing photo location in the chunk coordinate system. Is this the the transformation matrix for moving a pixel point to the chunk coordinate system or a chunk coordinates to pixel coordinates?

Same question for chunk transformation, is that for geocentric coordinates to chunk or the other way?

in any case, should transform_matrix.t() be the inverse of the matrix instead or is transpose and inverse the same thing here ? (my linear alg is alittle rusty)