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

Pages: 1 ... 7 8 [9]
121
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?

122
Python and Java API / Re: Set updateregion as a function of a scalebar size
« on: November 25, 2015, 01:11:11 AM »
Hi Alexey,

I can't get the scaling to work so I'm trying to add markers to use the first system that you suggested, but I only get one marker added to the scene when I use this code:

Code: [Select]
    chunk.addMarker()
    m = chunk.markers[0]
    m.position = c1.center
   
    chunk.addMarker()
    u = chunk.markers[1]
    u.position = c6.center
   

    newregion = chunk.region
    newregion.center = PhotoScan.Vector([x,y,z])
    dist = chunk.markers[1].position - chunk.markers[0].position
    dist = dist.norm()
    newregion.size = PhotoScan.Vector([dist, dist,dist])

Do you have any idea what I'm doing wrong?

thanks!

123
Python and Java API / Re: Set updateregion as a function of a scalebar size
« on: November 10, 2015, 11:50:07 PM »
Hi Alexey,

Thanks for the quick reply!

I'm trying to implement the second solution that you proposed as my cameras that I'm using to define the scalebar don't have markers attached, however I get a syntax error here:
Code: [Select]
if chunk.crs:
                ^
SyntaxError: invalid syntax

Would this be due to another part of my code ?

Thanks!

124
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!

125
Python and Java API / Re: Adding masks
« on: September 24, 2015, 01:12:48 AM »
Thanks for your help!
I've been trying to get it to work with the code below and it looks like the conditions are all verified as the "print" function is applied and the listed file names are displayed, but now no masks are applied to any cameras. Is it possible that I'm not passing the list in the right format to "cameras="?

Code: [Select]
for background in backgrounds_list:
if ("jpg" in background.lower()) or ("jpeg" in background.lower()) or ("JPEG" in background.lower()) or ("JPG" in background.lower()):
for file in os.listdir(path_photos):
list1 = list()
list1.append (file)
print (list1[0])
if list1[0] == background.lower():
chunk.importMasks(path = path_masks + "\\" + background, method='background', tolerance=tolerance, cameras=list1)
del list1[0]

126
Python and Java API / Re: Adding masks
« on: September 21, 2015, 05:53:27 PM »
Hi Alexey,

Thanks but that's where I can't figure it out. No matter whether I pass a list or a single entity name to the "cameras" argument I always get all of the "mask" files applied to each camera in the chunk. I'm going to spend some more time on this ans try to figure it out as I think I must be missing something simple...

Cheers!

127
Python and Java API / Re: Adding masks
« on: September 21, 2015, 02:48:47 PM »
Same problem here, I've been trying to use the importMasks command to load a series of images to be used as masks but each image is applied to each image in the chunk and I can't figure out how to match up images as pairs only based on file name.

Is it possible I'm not using the "cameras" attribute correctly?

Code: [Select]
#loading backgrounds
backgrounds_list = os.listdir(path_masks)
for background in backgrounds_list:
if ("jpg" in background.lower()) or ("jpeg" in background.lower()) or ("JPEG" in background.lower()) or ("JPG" in background.lower()):
chunk.importMasks(path = path_masks + "\\" + background, method='background', tolerance=tolerance, cameras=['0'])

print("stop here to check masking")

128
That was stupid: I left the quotes on "backgroundFilePath", that was the problem. Is still isn't working as it's not doing the process correctly and matching file names but I'll figure that out and pst the results ;)

129
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 ... 7 8 [9]