Forum

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - s093294

Pages: [1] 2
1
Python and Java API / Re: Loops and Sleeps in Python startup script
« on: January 18, 2016, 03:32:31 PM »
Hi _mARCel_

Could you provide a minimal example of this?

Am i understanding it correct that you succesfull have an auto loaded script that runs in startup and then it loops checking for "jobs" in a queue.


2
Python and Java API / Long Running background process in python
« on: July 03, 2015, 12:07:24 PM »
Is it possible to have a process running in the background doing http requests from within a python script added at startup;

I made the following to test if I could get an accessToken using a external command call, which works perfectly.

def signin():
   print("Testing");
   print(os.getcwd());
   #call(["C:/Users/pksorensen/AppData/Local/Agisoft/PhotoScan Pro/scripts/S-Innovations.DevOpt.OpenIdConnect.exe"])
   process = subprocess.Popen(["C:/Users/pksorensen/AppData/Local/Agisoft/PhotoScan Pro/scripts/S-Innovations.DevOpt.OpenIdConnect.exe"], stdout=subprocess.PIPE)

   accessToken = process.communicate()[0]
   print(accessToken)



PhotoScan.app.addMenuItem("AscendXYZ/Sign in", signin)

I would like to spawn a loop that every 5 mins checks for jobs using a HTTP endpoint. Is this possible, or would the user have to click a button everytime it should check?

3
Python and Java API / Potree Generation Information
« on: March 07, 2015, 09:43:19 PM »
I was not 100% sure where to post this question. Might not be directly related to python scripting but more general scripting.

I was amazed by the potree exports of photoscan and I have been trying to generate potree files myself (https://github.com/potree/potree) but have not been able to get similar details from my exported point clouds from photoscan.

Are you using the same tools to generate them as on the github? Would you be able to share alittle input on what kind of arguments is needed to get similar detailed results as coming out of photoscan directly.

Can we extract them from python also?

4
General / Re: Issue with orthomaps in urban areas
« on: November 10, 2014, 03:57:42 PM »
Thanks for the input.

We have a external DTM avaible for where we have taken photos. Its also used to get georencing heights for aligning.

Would it be as simple to import this as a mesh when generating the orthophoto instead of using the point cloud generated within argisoft.

Is it possible to import a DTM ? (guess it first need to be converted to a mesh).

5
Python and Java API / Extracing OrthoPhotos to a known grid
« on: November 05, 2014, 09:44:51 PM »
In our mapping pipeline right now we are extracing orthophotos in tiles of 16384 x 16384 pxs from photoscan and then we are recutting all the tiles to fit into a known grid.

We have defined a known grid based on a extent of the grid, (typical taken from epsg.io), such that given the extract resolution can be used to define extent for each tile in the grid. We then combine all tiles from photoscan, and recut them to this defined grid.  It simply means we are shifting all tiles alittle bit left or right and up or down to fit the grid.

We could save some compute time if we could make photoscan create tiles starting at this specific world coordinate grid.

In principal we just need to be able to tell photoscan when extracting the orthophotos that it should start creating tiles at this world coordinate [easting,northing] for resolution [r_x,r_y] Is this possible with python?


6
General / Issue with orthomaps in urban areas
« on: November 05, 2014, 12:23:17 PM »
We are creating aerial photos and exploring options to get better maps.

Our main issue is that our maps turns out with warply/blurry objects when there are objects on the map like houses and trees.

One solution is to get even more overlap and a better 3d model for it to generate the orthophoto. I rather not go this way.

When inspecting bing maps and other map solutions it looks more to me like a image stiching process where each pixel is not painted onto a 3d model of the surface, but instead the original images are possitioned based on the image aligmnent, such there wont be these blurry lines.

We have experimented with creating meshes with lower amount of vertexes to support this idea of a simpler model of the earth would create better results, and it looks to improve the urban areas, but the map in general looks worse because of the simpler mesh.

So my question is, have anyone done some good looking maps of urban areas with a lot of houses/trees with standard argisoft process, or is there other tools that can be used together with photoscan to create even better maps.




7
Python and Java API / Re: Python Feature Request: Processing window
« on: October 20, 2014, 04:43:30 PM »
Thanks.

My issue was because i tried a QWebView which is not included.

 

8
Python and Java API / Re: Python Feature Request: Processing window
« on: October 20, 2014, 02:43:06 PM »
I tried the follwoing:

from PySide import QtWebKit
Traceback (most recent call last):
  File "<console>", line 1, in <module>
ImportError: cannot import name QtWebKit


I wanted to try open a browser window.  Do you have some examples using PySide together with Photoscan. I am new to PySide, so might the issue for me.

9
Python and Java API / Updating image paths.
« on: October 20, 2014, 01:44:56 AM »
I have a project file where the images have been moved to new paths and i was hoping I could fix it with python but

Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: attribute 'path' of 'PhotoScan.Camera' objects is not writable

when trying to set

chunk.cameras[1].path = 'newpath'

Is something like that possible or what is the best way to fix. I could write out the list of image paths and then copy all images into the expected position before opening photoscan.

10
Python and Java API / Re: Python Feature Request: Processing window
« on: October 18, 2014, 07:06:27 PM »
Thanks. I will read up about that.


11
Python and Java API / Python Feature Request: Processing window
« on: October 17, 2014, 04:56:50 PM »
I am toying with a few extensions that i will provide from python. You already have some nice functions to get user intput.

I think it would be good with a method that could open the processing in progress while I do a heavy background task.

12
I would like from python to get the coordinate (world coordinate system) of the marker I just ented by right clicking in an image and create marker. (It could be just the selected marker).

For this just assume we have a marker. How do i calculate its estimated position.

I had this code from prior that took me from a world coordinate to pixel coordinate.

currentChunk  = PhotoScan.app.document.activeChunk
point_geocentric = currentChunk.projection.unproject(PhotoScan.Vector((676762.785,6123462.136,30)))
point_geocentric.size = 4
point_geocentric[3] = 1

a_camera = currentChunk.cameras[0];
transform_matrix = currentChunk.transform * a_camera.transform
point_local = transform_matrix.inv() * point_geocentric
point_local.size = 3
(image_x, image_y) = a_camera.project(point_local)

So basicly I would want to do it the reverse instead.


transform_matrix = chunk.transform * camera.transform
point = PhotoScan.Vector([6886,46])
local = camera.unproject(point)
geocentric = transform_matrix * local;

but the problem is that there is no such thing as camera.unproject

I am fine with an assumption that the image region is a estimate flat surface and estimating the height of the camera so i tried this:

point = PhotoScan.Vector([6886,46])
point1 = camera.calibration.unproject(point)
point1*1800 //my estimated height of 1800.

Vector([816.3781192185984, -612.216430096838, 1800.0])

This means that the marker is placed estimated 800 x -600 meters from camera. I am getting alittle stuck here, not sure if this is the way to go.

I basicly just want to be able to write out estimated world coordinate from a marker thats not yet been given a coordinate such I can look up the precise location in GIS application




13
Python and Java API / Re: Placeing markers for georeferencing with python.
« on: September 28, 2014, 04:27:33 PM »
One step closer.


currentChunk  = PhotoScan.app.document.activeChunk
currentChunk.ground_control.locations.items()  #All cameras have a location in given CRS

#create marker
nmark = PhotoScan.Marker()
nmark.label = "hello"
nmark.projections[(currentChunk.cameras[0],0)]= (0,0) # set pixel coordinates


# Add ground controll location for the given marker.
currentChunk.ground_control.locations.add(nmark)
currentChunk.ground_control.locations[nmark].coord = (0,0,0)
currentChunk.ground_control.locations[nmark].enabled = True

# Add it at the end, then its enabled.
currentChunk.markers.add(nmark)



Its now enabled. Only thing missing is that the flag is blue in the UI and it only turns green when its moved with the mouse. Not sure if it needs to be green or not yet.

14
Python and Java API / Re: Placeing markers for georeferencing with python.
« on: September 28, 2014, 04:07:42 PM »
Have progressed alittle bit.

When photos have been loaded the location of them is in the ground_control object.

currentChunk  = PhotoScan.app.document.activeChunk
currentChunk.ground_control.locations.items()  #All cameras have a location in given CRS


#Then a new marker can be created.
#create marker
nmark = PhotoScan.Marker()
nmark.label = "hello"
currentChunk.markers.add(nmark)

#Then it can be enabled and its world coordinate can be set in the projection used.
# Add ground controll location for the given marker.
currentChunk.ground_control.locations.add(nmark)
currentChunk.ground_control.locations[nmark].coord = (0,0,0)
currentChunk.ground_control.locations[nmark].enabled = True

But sadly, setting it to enabled do not trigger update in UI. (Not sure if its needed or not, as i am automating it anyway).

15
I have found a way but it involves looping over all the faces (worked okay in a model of 10 images).

In our own setup we used to do this by simply solving the linear system when camera projection is know and the height. I can see why this is smarter as it dont need the height as its found by the model here. Its abit shower but more robust, so i think i am happy with this for now.

Code was adapted from one of your other posts.


steps = [(0,0), (camera.width,0),(camera.width,camera.height),(0,camera.height)]

for x,y in steps:
   
   point = PhotoScan.Vector([x, y])
   point = camera.calibration.unproject(point)
   point = camera.transform.mulv(point)
   vect = point
   p = PhotoScan.Vector(camera.center)

   for face in faces:

      v = face.vertices
   
      E1 = PhotoScan.Vector(vertices[v[1]].coord - vertices[v[0]].coord)
      E2 = PhotoScan.Vector(vertices[v[2]].coord - vertices[v[0]].coord)
      D = PhotoScan.Vector(vect)
      T = PhotoScan.Vector(p - vertices[v[0]].coord)
      P = cross(D, E2)
      Q = cross(T, E1)
   
      result = PhotoScan.Vector([Q * E2, P * T, Q * D]) / (P * E1)
   
      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.mulp(u + v_ + t)
         res = chunk.crs.project(res)
         print("{:>04d}".format(x + 1) + "\t" + "{:04d}".format(y + 1) + "\t" + "{:.4f}".format(res[0]) + "\t" + "{:.4f}".format(res[1]) + "\t" + "{:.4f}".format(res[2]) + "\n")         
         break #finish when the first intersection is found



Pages: [1] 2