Forum

Author Topic: Image footprints in world coordinate system  (Read 5858 times)

b3059651

  • Newbie
  • *
  • Posts: 25
    • View Profile
Image footprints in world coordinate system
« on: February 06, 2015, 03:35:15 PM »
Hi all,

Following a previous thread (http://www.agisoft.com/forum/index.php?topic=2666.0) I would like to ask 1) what is the purpose of the if statement, as seen in the attached script:

if (0 < result[1]) and (0 < result[2]) and (result[1] + result[2] <= 1):
         t = (1 - result[1] - result[2]) * vertices[v[0]].coord
         u = result[1] * vertices[v[1]].coord
         v_ = result[2] * vertices[v[2]].coord
         
         res = chunk.transform.matrix.mulp(u + v_ + t)
         res = chunk.crs.project(res)



and 2) do you know if the result of the transform.matrix.mulp is the transformation of pixels to image coordinate frame after the intersection with the actual TIN?

As I a understood without the if statement the process is running for ever but still I cannot find an explanation for the conditional if. Can you please give me a feedback on that?

This script seems really useful and important because it shows the footprint but I cannot make it work with my dataset.  :(
Thanks a lot for the script, anyway.

b3059651

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Image footprints in world coordinate system
« Reply #1 on: February 06, 2015, 04:01:28 PM »
Hi all again,

I would like to add a comment, maybe you can help me to understand better.

Throughout the whole process while we try to determine the 3D coordinates of the image borders there is a sequence of transformations:

1. pixel coordinates of each individual image borders to image camera coordinates (according to intrinsic camera parameters)
2. from camera coordinates to chunk frame (a frame of the image block) and then
3. from chunk frame to world (3d) frame

Is this right? In the meantime intersection with the generated surface (TIN) is computed.

I hope you can help me on clarifying this.

Thanks in advance
 :)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15067
    • View Profile
Re: Image footprints in world coordinate system
« Reply #2 on: February 06, 2015, 04:14:11 PM »
Hello b3059651,

It's one of the implementations of tracing the intersection of vector (ray) and triangle:
http://www.cs.virginia.edu/~gfx/Courses/2003/ImageSynthesis/papers/Acceleration/Fast%20MinimumStorage%20RayTriangle%20Intersection.pdf
http://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm


chunk.transform.matrix.mulp() converts the vector from the internal chunks' coordinate system into world coordinates.

Maybe you can send the project file to our support e-mail, so that we could check what is wrong?
Best regards,
Alexey Pasumansky,
Agisoft LLC

b3059651

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Image footprints in world coordinate system
« Reply #3 on: February 09, 2015, 01:05:32 PM »
Thank you so much for your help. I will do another trial today and if it doesn't work I will let you know.

Regards,
b3059651

b3059651

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Image footprints in world coordinate system
« Reply #4 on: February 10, 2015, 03:31:42 PM »
Hi,

I have sent the project with a link via sendspace and I added two photos together with the python script to help you find  the mistake.

Thanks a lot in advance :)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15067
    • View Profile
Re: Image footprints in world coordinate system
« Reply #5 on: February 10, 2015, 04:59:24 PM »
Hello b3059651,

Thank you for sending the data.

The script really works not so fast, due to only one CPU core used by Python, so the working time depend on the number of images, number of polygons and number of steps (just four corners or intermediate positions).

However, on our side the script has finished in five minutes.

The only change I've made was fixing the indent for loops and conditions - just one "tab" instead of two somehow appeared in your script version. And also corrected the dimensions of image for "steps":  steps=[(0,0), (3648-1,0), (3648-1,2736-1), (0,2736-1)]

I think that the main problem is in fact that you are writing "result" into Console - it slows down the process as the print operation is performed for every polygon of the model multiple times!

Also I can suggest to put file.flush() line after the information is written to the file.
Best regards,
Alexey Pasumansky,
Agisoft LLC