Forum

Author Topic: projection of 2D pixel  (Read 2694 times)

arafat

  • Newbie
  • *
  • Posts: 28
    • View Profile
projection of 2D pixel
« on: January 13, 2022, 03:59:40 PM »
Hi all, rookie question here so bare with me

I have a marker and I can get the position by marker.position
I want to calculate the Euclidian distance between this marker and a projection of a 2D pixel.
I use camera.unproject(2D pixel) to project a vector and then calculate the distance.

My question: is this the correct way or do marker.position and camera.unproject generate vectors in the same coordinate system??

thanks in Advance

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14843
    • View Profile
Re: projection of 2D pixel
« Reply #1 on: January 13, 2022, 04:37:11 PM »
Hello arafat,

Do you mean to project the 2D pixel on the existing surface and get that coordinates? Or you are planning to calculate the distance between the marker.position and the ray that goes through the camera.center and 2D pixel of the corresponding image?
Best regards,
Alexey Pasumansky,
Agisoft LLC

arafat

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: projection of 2D pixel
« Reply #2 on: January 13, 2022, 04:39:14 PM »
I mean the first

thanks for responding

arafat

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: projection of 2D pixel
« Reply #3 on: January 13, 2022, 04:54:22 PM »
update: I was able to do it using this code

Code: [Select]
                        coords_2D = Metashape.Vector([x, y])
                        sensor = camera.sensor
                        pc_pred = custom_chunk.point_cloud.pickPoint(camera.center, camera.transform.mulp(sensor.calibration.unproject(coords_2D)))
                        pc_pred.size = 4
                        pc_pred[3] = 1.
                        v=custom_chunk.crs.project((custom_chunk.transform.matrix*pc_pred)[0:3])

Jordan Pierce

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: projection of 2D pixel
« Reply #4 on: November 13, 2022, 04:12:34 AM »
Hello arafat,

Do you mean to project the 2D pixel on the existing surface and get that coordinates? Or you are planning to calculate the distance between the marker.position and the ray that goes through the camera.center and 2D pixel of the corresponding image?

Hi Alexey Pasumansky, I would be interested in knowing how to do the latter.
« Last Edit: November 13, 2022, 04:29:11 AM by Jordan Pierce »