Forum

Author Topic: How to go from marker location to pixel coordinates?  (Read 3326 times)

nickponline

  • Newbie
  • *
  • Posts: 38
    • View Profile
How to go from marker location to pixel coordinates?
« on: January 25, 2017, 01:44:04 AM »
I have PhotoScan project where I have estimated the camera positions and now want to add some markers to it. I am struggling to understand the sequence of transformations that move a 3D marker position to a pixel in an image?

I tried:

camPos3D = camera.sensor.calibration.transform * chunk.transform *  markerPos3d

which should give the position of the marker relative to the camera, and then:

camera.project(camPos3D)


but it doesn't work?

In particular what is the purpose of the chunk transform. The cameras position are estimated in world coordinates right or are they relative to the chunk which is relative to the world?

Ultimately I want to add a marker manually and then run a script that will try and project that marker into each image and if it can output the pixel in the image that corresponds to the marker projection.
« Last Edit: January 25, 2017, 02:14:10 AM by nickponline »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14855
    • View Profile
Re: How to go from marker location to pixel coordinates?
« Reply #1 on: January 25, 2017, 07:15:51 AM »
Hello nickponline,

Have oyu checked the following script sample:
http://www.agisoft.com/forum/index.php?topic=6053.msg29355#msg29355

It contains the code part that can be used to project the 3D point in real world coordinates (if the chunk is georeferenced) to 2D photo.
Best regards,
Alexey Pasumansky,
Agisoft LLC

nickponline

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: How to go from marker location to pixel coordinates?
« Reply #2 on: January 25, 2017, 09:40:50 AM »
Thanks Alexey that's helpful, but what is the difference between mulv and using *

for example why do:

v = PhotoScan.Vector([0.3, 0.6, 0.9])
camera.transform.mulv(v)

and

v_homog = PhotoScan.Vector([0.3, 0.6, 0.9, 1.0]) #homogenous version of v
camera.transform * v_homog

Give different results?

nickponline

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: How to go from marker location to pixel coordinates?
« Reply #3 on: January 25, 2017, 09:52:39 AM »
Also does camera.project(v) internally perform K * [camera.rotation | camera.translation] * v ?

Thanks so much for the help! Really appreciate it :)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14855
    • View Profile
Re: How to go from marker location to pixel coordinates?
« Reply #4 on: January 25, 2017, 11:16:39 AM »
Hello nickponline,

The second code that you provided should be the same as camera.transform.mulp(v) and to replicate .mulv() you need to set the fourth component as "zero". Also note that result of mulp() and mulv() is a three component vector - the fourth component is removed.
Best regards,
Alexey Pasumansky,
Agisoft LLC