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.


Topics - reperry

Pages: [1]
1
Hello,

I would appreciate your help. I wrote two scripts:
(1) one orients the model and sets the bounding box
(2) the other resets the viewpoint to something nice with the z-axis up (see below)

I found that if I run these consecutively as separate scripts, then both objectives are reached! Unfortunately when I call them from within the same script the second one doesn't happen. The viewpoint stays the same as if (2) never even ran. However, if I include a save function in between the two scripts, then both steps are successfully completed.

I'm including a minimal example below. In place of my script (1) I am doing chunk.updateTransform() which produces the same inconsistency. Please try running the code below on a project with a completed model in a chunk. Then uncomment the doc.save() line. Hopefully you will also see the resulting view depends on doc.save().

Why do I need the doc.save() command for the script to carry out the rotate() function afterwards?

I am using Agisoft PhotoScan Professional Version 1.3.3 build 4827 (64 bit)


Code: [Select]
import PhotoScan

def rotate():
    doc = PhotoScan.app.document
    chunk = doc.chunks[-1]

    T = chunk.transform.matrix
    PhotoScan.app.viewpoint.coo = T.mulp(PhotoScan.Vector([0,0,0]))
    PhotoScan.app.viewpoint.rot = chunk.transform.rotation
    PhotoScan.app.viewpoint.mag = 1000
   
if __name__ == "__main__":

    doc = PhotoScan.app.document
    chunk = doc.chunks[-1]
    chunk.updateTransform()
   
    #doc.save()
    rotate()

2
Python and Java API / Normal Vectors of Cameras
« on: March 23, 2017, 09:38:01 PM »
I am interested in scripting based on the camera angles. Specifically, I would like the cameras' normal vectors in the chunk coordinate system. These normals would be parallel or anti-parallel to the sticks displayed coming out of the blue rectangles.

How can I calculate these camera normal vectors?

I know the cameras each have chunk.cameras[0].transform.rotation(), but how do I go from this rotation matrix to a normal vector?

Any assistance would be greatly appreciated!

3
If I pick a vertex in a model (e.g. vert = chunk.model.vertices[0]), how can I quickly get a list of the vertices it is connected to via edges?

The only approach I can think of is to cycle through all the faces and check if that vertex is part of that face. If it is, then I can add the other vertices from that face to a list. This is not very elegant though. Is there a faster method to access the vertices that a specific vertex is connected to?

Thanks

4
Python and Java API / Naming the Model within an FBX File
« on: November 30, 2016, 07:45:28 PM »
When I save as .fbx, and then load the model into 3ds Max the model is always called "Model" even though the .fbx file has a more meaningful name, "horse_statue.fbx" for example. Is there any way I can get Agisoft to name the model within the .fbx file something more meaningful. I assume "Model" is being used because that is what the object is called within Agisoft:

doc = PhotoScan.app.document
chunk = doc.chunks[0]
chunk.model returns <Model '20000 faces, 100084 vertices'>

It would help me if I could name the model itself because .fbx is just a container for a model. When the model is imported into other software, it no longer has a reference to the logically-named file it came from.

I know this is an edge case, but thought I'd ask in case anyone else wants this feature too or there is a work-around.

5
Hello,

Is there any way to return the number of points within the bounding box? Agisoft clearly knows which are in and which are out for the later processing steps.

I suppose the time intensive way would be to calculate whether the coordinates of each point are in the bounding box as defined by its center, size, and rotation. I think my point coordinates are in a different reference frame than my bounding box, though. Perhaps I would need to transform them first.

Thank you,
Rebecca

6
I would like to use the number of connected components in my script to decide whether or not to remove any components. I can see the number of connected components by manually going:
Tools --> Mesh ---> View mesh statistics...

But, I can't figure out how to get the number of connected components from within my script.

Here's what I have in mind:

numtriangles = 1000
connectedComponets = chunk.model.GET CONNECTED COMPONENT COUNT
while connectedComponents > 1:
    chunk.model.removeComponents(numtriangles)
    connectedComponents = chunk.model.GET CONNECTED COMPONENT COUNT
    numtriangles+=1000

Thanks for your help!

7
Python and Java API / Changing Size of Region Does More than That
« on: February 18, 2016, 01:13:46 AM »
I am trying to reduce the size of the bounding region along one axis. When I use the following code (output included), the bounding region changes along all three dimensions and rotates as well. Can anyone duplicate this behavior? Am I misunderstanding what region.size is?

Code: [Select]
doc = PhotoScan.app.document
chunk = doc.chunks[0]
chunk.region.size
>>> Vector([20.0,20.0,20.0])

newregion = chunk.regionnewregion.size = Photoscan.Vector([20.0,20.0,20.0])
chunk.region = newregion
>>> Vector([20.0,20.0,10.0])

Thanks!

Pages: [1]