Forum

Author Topic: Setting mapping region  (Read 36031 times)

ppkong

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: Setting mapping region
« Reply #30 on: October 20, 2014, 09:45:38 AM »
Thanks Alexey!
Another question is about GPU&CPU,Before “buildDenseCloud” I switch GPU on and switch of all CPU core.
Code: [Select]
PhotoScan.app.cpu_cores_inactive=16
PhotoScan.app.gpu_mask=1
When the buildDenseCloud is completed do I need to switch back to CPU in the python script for "chunk.buildModel"?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14818
    • View Profile
Re: Setting mapping region
« Reply #31 on: October 20, 2014, 09:51:45 AM »
Hello ppkong,

You do not need to switch the number of CPU cores back after dense cloud generation stage. Currently these two mentioned keys are used only during buildDenseCloud stage.
Best regards,
Alexey Pasumansky,
Agisoft LLC

ppkong

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: Setting mapping region
« Reply #32 on: October 20, 2014, 09:56:33 AM »
Hello ppkong,

Reuse depth maps option is only available if depth maps have been estimated earlier and were kept in the project (corresponding option in Advanced tab of PhotoScan Preferences window should be selected).

But this option could not be used properly if the camera positions have changed relatively to the moment when the depth maps have been calculated.
Thanks,Alexey!
Your means is if I modify the region range, the position of the camera will change?I don't know much about depth map, but I also want to improve efficiency in this step.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14818
    • View Profile
Re: Setting mapping region
« Reply #33 on: October 20, 2014, 10:04:34 AM »
Hello ppkong,

Changing the region may be the case if at first you've generated dense cloud for the small region and then extended the bounding box to fit all the scene.
Best regards,
Alexey Pasumansky,
Agisoft LLC

ppkong

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: Setting mapping region
« Reply #34 on: October 20, 2014, 11:22:10 AM »
 ;D Ha-ha,you're right.
I use this function for aero images process,And I think it is useful for process aero images.
When build Depth maps of area 1(Blue boundary of area), The program is generated for every entire image(Selected red boundary of images) that contain area 1.Then I think it can be reuse for process area 2,3,4.
« Last Edit: October 20, 2014, 11:41:27 AM by ppkong »

AndyC

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Setting mapping region
« Reply #35 on: November 27, 2014, 01:23:38 PM »
I'm also trying to use the API to prescribe a reconstruction region.

Can anyone explain how to determine the parameter values needed for the MapRegionVec array as described by jmsuomal? (My chunk is in the geographic coordinate system ESPG::4326).

Thanks, Andy

r0xx

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: Setting mapping region
« Reply #36 on: December 08, 2014, 06:53:37 PM »
Hello

I am using the following code:

Code: [Select]
# Get the coordinates from the user
  coord_x = app.getFloat("x coordinate:")
  coord_y = app.getFloat("y coordinate:")
 
  mySize = 9
 
  # Define: Map region
  # MapRegionVec = [CenterX, CenterY, SizeX0, SizeY0, ZRotationDeg]
  MapRegionVec = [coord_x, coord_y, mySize, mySize, 0.0]

  # Select the project
  doc = PhotoScan.app.document

  # Get the current chunk
  chunk  = doc.chunk

  # Set Bounding Box
  # create new region object
  newregion = PhotoScan.Region()

  # Set region center
  centerUTM = PhotoScan.Vector([MapRegionVec[0], MapRegionVec[1], 0])
  centerGEO = chunk.crs.unproject(centerUTM)
  centerGEO.size = 4
  centerGEO.w = 1
  centerLocal = chunk.transform.matrix.inv() * centerGEO
  newregion.center = PhotoScan.Vector([centerLocal[0], centerLocal[1], chunk.region.center[2]])

  # Set region size
  newregion.size = PhotoScan.Vector([MapRegionVec[2], MapRegionVec[3], chunk.region.size[2]])

  # Set region rotation
  # build rotation matrix in our coordinate system
  RotZDeg = -MapRegionVec[4]
  SinRotZ= math.sin(math.radians(RotZDeg))
  CosRotZ= math.cos(math.radians(RotZDeg))
  RotMat = PhotoScan.Matrix([[CosRotZ,-SinRotZ,0,0],[SinRotZ,CosRotZ,0,0],[0,0,1,0],[0,0,0,1]])

  #  Rotate region bounding box
  T = chunk.transform.matrix
  v = PhotoScan.Vector( [0,0,0,1] )
  v_t = T * v
  v_t.size = 3
  m = chunk.crs.localframe(v_t)
  m = m * T
  m = RotMat*m
  s = math.sqrt(m[0,0]**2 + m[0,1]**2 + m[0,2]**2) #scale factor
  R = PhotoScan.Matrix( [[m[0,0],m[0,1],m[0,2]], [m[1,0],m[1,1],m[1,2]], [m[2,0],m[2,1],m[2,2]]])
  R = R * (1. / s)
  newregion.rot = R.t()

  # Put newregion to chunk
  chunk.region = newregion

But I have 2 problems.
The first thing is that the size argument is wrong because if I enter 9.0 (as above) this is ca. 500 meters (But if I enter 500 in the size argument it's waaayyy to huge -> about 30km). How can I fix this?
And also the center coordinates that I'm entering are also not in the center of this. I'm using EPSG:21781 for my calculations. How can I really use them with center coordinates?
Or is it just the script that is wrong?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14818
    • View Profile
Re: Setting mapping region
« Reply #37 on: December 09, 2014, 04:17:56 PM »
Hello r0xx,

When using real-world scales for the bounding box size you need to divide them by the scale factor s, calculated during rotation estimation.

As for the region center coordinates, you need to use all three point coordinates X, Y and Z, otherwise centerGEO vector in geocentric coordinates will be calculated incorrectly due to zero altitude above ellipsoid using in the script provided.
Best regards,
Alexey Pasumansky,
Agisoft LLC

r0xx

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: Setting mapping region
« Reply #38 on: December 09, 2014, 06:41:32 PM »
Adding a Z coordinate and dividing the size by scale factor fixed the problems! Thanks alot!