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

Pages: 1 2 [3]
31
Python and Java API / How to use removecomponents
« on: December 30, 2015, 03:42:48 PM »
Hi  guys,

I'm trying to integrate removeComponents into my workflow but I can't get in to work.

This is the code I'm using:

Code: [Select]
def removethecrap(chunk):

    doc = PhotoScan.app.document
    chunk = doc.chunk
   
    if chunk.model:
        chunk.removeComponents(40000)
        print("Crap removed.")
        return 1
    else:
        print("No model. Script aborted.")
        return 0

It seems to run when I use this code, but I don't get any result. I would expect this to remove components smaller than 40k polygons, but no matter what I set this threshold to nothing really gets removed. Anyone have any suggestions as to what I'm doing wrong here?

32
Python and Java API / Set updateregion as a function of a scalebar size
« on: November 10, 2015, 01:56:23 PM »
Hi everyone,

I'm trying to do something fairly simple: set the update region in my project as a function of a scalebar size instead of using standard integers as these give different results for each project.
The syntax I'm using is this:

Code: [Select]
updateregion.size = [ab.distance*10,ab.distance*5,ab.distance*5]
The scalebar size is set previously as such:

Code: [Select]
for camera in chunk.cameras:
        if camera.label == '101.jpg':
            c1 = camera
        if camera.label == '102.jpg':
            c2 = camera
   
    ab = chunk.addScalebar(c1, c2)
    ab.reference.distance = 0.366

This doesn't seem to work, the script breaks down at this step yet it works if I use standard sizes like this for the updateregion:

Code: [Select]
updateregion.size = [12,4,4]
Am I just using the wrong syntax in "ab.distance*10" ? I've been over the documentation for this and I can't figure this out.

Thanks!

33
Hi guys,

I'm trying to do what it says in the title ;)

I can load the images no problem, but then I would like to apply for each image a mask made from the background image with the same name. I con't figure out why photoscan doesn't like my function that defines the path to each background image, does anyone have any clues?

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

label = "Script scan"
projectionImagePath = PhotoScan.app.getExistingDirectory("Please choose the folder with projection image files:") + "//"
backgroundImagePath = PhotoScan.app.getExistingDirectory("Please choose the folder with background image files:") + "//"


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

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

chunk.addPhotos(file_list)

backgrounds = os.listdir(backgroundImagePath)
background_list=[]
for file in backgrounds:
if file == camera.label:
backgroundFilePath = backgroundImagePath + file
chunk.importMasks (path='backgroundFilePath', method='background', tolerance=12)


The error that I get when running the script is :
"Can't load image:
backgroundFilePath"

Thanks!

Pages: 1 2 [3]