Forum

Author Topic: Calculating the camera normal vector  (Read 3435 times)

dobedobedo

  • Newbie
  • *
  • Posts: 31
    • View Profile
Calculating the camera normal vector
« on: November 16, 2017, 09:47:22 AM »
Hi,

I want to make sure I don't do any mistake in the camera vector calculation.
As far as I know, the normal vector of a camera in chunk coordinate system can be calculated by:

Code: [Select]
principal_pixel = PhotoScan.Vector(camera.sensor.width/2+camera.sensor.calibration.cx, camera.sensor.height/2+camera.sensor.calibration.cy)
normal_vector = camera.transform.mulv(camera.sensor.calibration.unproject(principal_pixel))

Then it should work to transform the vector to world coordinate system by

Code: [Select]
world_vector = chunk.transform.matrix.mulv(normal_vector)
and I can also get the camera rotation matrix in the world by
Code: [Select]
T = chunk.transform.matrix
m = chunk.crs.localframe(T.mulp(camera.center))
R= m * T * camera.transform * PhotoScan.Matrix().Diag([1, -1, -1, 1])
R = R.rotation()

I would like to know that whether the vector's direction is defined as y axis to north, x axis to east, and xy plane is parallel to the horizon, or is it based on the camera orientation. If it is based on camera orientation, can I transform it by multiply the transpose rotation matrix?
Appreciated for your help to make it clear!
« Last Edit: November 20, 2017, 03:06:17 AM by dobedobedo »

dobedobedo

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Calculating the camera normal vector
« Reply #1 on: November 22, 2017, 02:51:37 AM »
Hi,
I just figured out that the normal vector in the geocentric system should be just
Code: [Select]
R.t() * PhotoScan.Vector([0.0, 0.0, 1.0])and the y should have a negative sign since the axis is toward south.
Please correct me if I mis-understood.
Cheers,
« Last Edit: November 22, 2017, 06:43:01 AM by dobedobedo »