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 - gchaprnka

Pages: [1]
1
For the benefit of anyone finding this in the future, the golden ticket was the order things happened. ImportMarkers coming after addPhotos, before matchPhotos.
Code: [Select]
pics = ["1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg","7.jpg","8.jpg","9.jpg","10.jpg","11.jpg","12.jpg","13.jpg","14.jpg","15.jpg"]
chunk = doc.addChunk()
chunk.addPhotos(pics, strip_extensions = False)
chunk.importMarkers(markerPath)
chunk.matchPhotos(accuracy=Metashape.HighAccuracy, generic_preselection=True,reference_preselection=False)
chunk.alignCameras()

edit: Alexey is right, I also had "strip_extensions = False" added to the addPhotos in my final code. Good catch!

2
Attached is the markers XML. I've emailed you the PSZ of the same scan, with both manual and automatic chunks.

3
Thanks for the quick reply! Unfortunately, adding the "strip_extensions = False" has not fixed my issue (See attachment). Any other thoughts?

4
I've been working on a short script to process a batch of photo sets taken with a small camera rig (15 cameras). Manually, the process works fine, but I'm noticing a difference when writing the script. First, the manual process:

1) Add Photos
2) Import markers (exported from a photoset of a calibration object with a set of known markers)
3) Align photos

The process continues, but at this point I have a sparse point butt of the subject, aligned to my coordinate system and scaled appropriately.

The code that I'm using to replicate this process (I've set the cwd to the directory with the pics in it already):
Code: [Select]
pics = ["1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg","7.jpg","8.jpg","9.jpg","10.jpg","11.jpg","12.jpg","13.jpg","14.jpg","15.jpg"]
chunk = doc.addChunk()
chunk.importMarkers(markerPath)
chunk.addPhotos(pics)
chunk.matchPhotos(accuracy=Metashape.HighAccuracy, generic_preselection=True,reference_preselection=False)
chunk.alignCameras()

When running the script, I get a sparse butt and the targets exist, but are not where I'd expect them to be (relative to the cameras) based on the manual process. I've attached a pair of screenshots showing the different results from manual vs. script. As a side note - manually, it does not matter if markers are imported before or after cameras are aligned, it works either way. Neither way works in the script.

5
Python and Java API / Re: Loading Masks in Photoscan 1.3.0
« on: June 14, 2017, 11:53:04 PM »
I'm having similiar issues here - 1.3.2. I'm trying to apply masks with identical filenames, just located in a folder called "mask".
Code: [Select]
maskPath = "C:\Temp\IMAGES\1Agisoft\mask\{filename}.jpg"

chunk.importMasks(path = maskPath, source=PhotoScan.MaskSourceBackground, operation=PhotoScan.MaskOperationDifference, tolerance=20)

It works in the gui with template "{filename}.jpg" after I pick the right /mask folder. Thoughts?

6
General / Re: Telecentric lens settings (Focus Stacking)
« on: January 19, 2016, 11:23:12 PM »
I'm working on a similar issue! Anyone have ideas?

7
Python and Java API / How to split calibration groups in python?
« on: January 05, 2016, 03:25:30 AM »
In some instances I've noticed improved processing by splitting cameras into individual calibration groups (1 per camera) instead of the default grouping (based on a non-exact focal length). I've been looking through the documentation, and the only thing that stands out as being similar is cameraGroups, but it does not seem to be separating them. Is there a way to "split camera calibration"?

In the GUI, Tools>Camera Calibration>right click on a group and "Split Groups" is what I'm looking to do.

8
Python and Java API / Re: Error in 1.2.0 addChunk
« on: December 18, 2015, 12:12:11 AM »
I'm testing completely in 1.2.1 right now (but I am testing with the same raw photo set that I have run through 1.1.6 successfully, with different results.

Code: [Select]
gradualFlag = int(float(numPoints) * 80) #80 is 80% - our target number of points to keep
reprojectionError = float(10)
currentPoints = numPoints

while (currentPoints > gradualFlag):
reprojectionError -= .25
newChunk = chunk.copy()
newChunk.buildPoints(error = reprojectionError)
currentPoints = len(newChunk.point_cloud.points)

9
Python and Java API / Re: Error in 1.2.0 addChunk
« on: December 17, 2015, 07:42:34 PM »
Thanks Alexey - I've also noticed that it seems gradual selection is working differently between 1.1.6 and 1.2.0 (and 1.2.1). I used to iteratively lower my threshold until I had ~80% of the original points, and that was working well with a .25 step per iteration. Now it seems that I never get any data with those values - because I get to .25 and still above 80%, and the next step is 0. Was there some fundamental change in how gradual selection works in the update?

10
Python and Java API / Re: Error in 1.2.0 addChunk
« on: December 17, 2015, 12:36:41 AM »
automated processing of shots from my camera array. This snippet was previously taking the last of a series of copied chunks (adjusting gradual selection until a certain % of original data is left, iteratively), and copying the final chunk to a new doc ("doc2"), and saving just that doc out.

Code: [Select]
...
doc2 = PhotoScan.Document()
doc2.addChunk(chunk.copy())
doc2.save(C:\\Path\\to\\file.psz")

However, addChunk now seems to exclusively make new chunks, and chunk.copy doesn't seem to put the copy in the new doc. I can't seem to find the method to copy the active chunk into a new "Document".

11
Python and Java API / Error in 1.2.0 addChunk
« on: December 11, 2015, 09:17:33 PM »
Script was running well in 1.1.6, but now crashes in 1.2.0. I updated other calls as shown in http://www.agisoft.com/forum/index.php?topic=4588, but this fails too.


2015-12-11 11:59:34     doc2.addChunk(chunk.copy())
2015-12-11 11:59:34 TypeError: addChunk() takes no arguments (1 given)

12
Python and Java API / Re: Import Cameras/Build Points?
« on: April 13, 2015, 08:20:46 PM »
I'm still having trouble with this. Here's my code right now:
Code: [Select]
import sys
import operator
import os
import PhotoScan
import math

label = "My Test"
cameraPath = "C:\\Test Shots\\myCameras.xml" #C:\\agi_temp"
workingPath = os.path.dirname(os.path.realpath(__file__)) + "\\" #updates to whereever this file is placed.

doc = PhotoScan.app.document
chunk = PhotoScan.Chunk()
chunk.label = label
doc.addChunk(chunk)

files = os.listdir(workingPath)
file_list=[]
for file in files:
if file.endswith("JPG"):
filePath = workingPath + file
file_list.append(filePath)

chunk.addPhotos(file_list)

chunk.importCameras(cameraPath)
# chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, preselection=PhotoScan.Preselection.NoPreselection, filter_mask=False, keypoint_limit=40000, tiepoint_limit=1000)
chunk.matchPhotos()

chunk.detectMarkers(PhotoScan.TargetType.CircularTarget12bit, 20)

sb = chunk.addScalebar(chunk.markers[7],chunk.markers[8])
sb.reference.distance = .11
chunk.markers[7].reference.location = PhotoScan.Vector((-0.002399,-0.050127,0.000000))
chunk.markers[1].reference.location = PhotoScan.Vector((-0.047861,0.034190,0.000000))
chunk.markers[10].reference.location = PhotoScan.Vector((0.056992,0.001284,0.000000))

# region selection
reg = chunk.region
print(reg.size, reg.center)

if not chunk.transform:
print("no transform")
trans = PhotoScan.Matrix().diag([1,1,1,1])
else:
print("has transform")
trans = chunk.transform

print("trans ", trans)
#<---- Rotation ---->
rot_untransformed = PhotoScan.Matrix().diag([1,1,1,1])
print("rot_untransformed ", rot_untransformed)
rot_temp = trans.matrix * rot_untransformed 

s = math.sqrt(rot_temp[0, 0]**2 + rot_temp[0, 1]**2 + rot_temp[0, 2]**2)
R = PhotoScan.Matrix( [[rot_temp[0,0],rot_temp[0,1],rot_temp[0,2]], [rot_temp[1,0],rot_temp[1,1],rot_temp[1,2]], [rot_temp[2,0],rot_temp[2,1],rot_temp[2,2]]])
R = R * (1.0 / s)

#<---- Size ---->
inter_size = PhotoScan.Vector([0, 0, 0])
geo_size = PhotoScan.Vector([.2, .2, .3])
inter_size = geo_size / s 

#<---- Center ---->
geo_cen = PhotoScan.Vector([0, 0, 0.1])
inter_cen = trans.matrix.inv().mulp(geo_cen)

reg = PhotoScan.Region()
reg.rot = R.t()
reg.size = inter_size
reg.center = inter_cen

chunk.region = reg

chunk.buildDenseCloud(quality=PhotoScan.HighQuality,filter = PhotoScan.AggressiveFiltering) # quality=PhotoScan.HighQuality
chunk.buildModel(surface=PhotoScan.Arbitrary, interpolation=PhotoScan.DisabledInterpolation,face_count=PhotoScan.MediumFaceCount) # face_count=PhotoScan.MediumFaceCount) # interpolation=PhotoScan.EnabledInterpolation
chunk.smoothModel(passes=2)
chunk.buildUV(mapping=PhotoScan.GenericMapping)
chunk.buildTexture(blending=PhotoScan.MosaicBlending, size=2048) # size=4096)
doc.save(workingPath + label + ".psz")

chunk.exportModel(workingPath + label + ".obj",binary=True,texture_format='jpg',normals=True,colors=False,cameras=False, format='obj')

What's odd is that it doesn't build any of the model I'm looking for, but it does get decent model of the area around it (the flat surface it's sitting on). The "myCameras.xml" is actually an export from the same exact scan that was aligned using the gui and exported manually. When I run through the steps manually in the software it works but never via the script.

Thoughts?

13
Python and Java API / Re: Import Cameras/Build Points?
« on: April 06, 2015, 10:31:54 PM »
I see. Is there a reason this is so different than using the GUI? If I understand correctly the process in the GUI is:
1)make new chunk
2)add photos
3)import cameras
4)build point cloud
5+)build dense cloud/model, etc.

but in python:
1)make new chunk
2)add photos
3)import cameras
4)match photos
5)build point cloud
6+)dense clould, etc.

14
Python and Java API / Import Cameras/Build Points?
« on: April 04, 2015, 01:12:01 AM »
I'm trying to automate the processing of data from a small camera array, and take advantage of the import cameras feature. heres the code I'm using:

Code: [Select]
import sys
import operator
import os
import PhotoScan
import math

label = "Scan 010"
workingPath = "C:\\Test Shots\\Scan 010" + "\\"
cameraPath = "C:\\Test Shots\\cameras.xml"

doc = PhotoScan.app.document
chunk = PhotoScan.Chunk()
chunk.label = label #"My Chunk"
doc.addChunk(chunk)

files = os.listdir(workingPath)
file_list=[]
for file in files:
if file.endswith("JPG"):
filePath = workingPath + file
file_list.append(filePath)

chunk.addPhotos(file_list)

chunk.importCameras(cameraPath)
chunk.buildPoints()

and it goes on to do the processing. I previously had it working with:
Code: [Select]
chunk.detectMarkers()
chunk.matchPhotos(accuracy=PhotoScan.MediumAccuracy, preselection=PhotoScan.Preselection.NoPreselection)
chunk.alignCameras()

It doesn't seem that the BuildPoints step is happening. If I stop the script at that point, I have aligned cameras but no points. Did the syntax change in the latest version? (I updated today to 1.1.4 build 2021(64bit))

Pages: [1]