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

Pages: [1] 2
1
Python and Java API / Re: for loop image loading
« on: February 18, 2015, 08:07:16 PM »
ah  yes...

current working directory issue.  added"os.chdir(ImageDirectory)" after it found the images. thanks!

in case you were curious...here is the updated script;

Code: [Select]
import PhotoScan
import os
import sys

from PySide.QtGui import QPixmap, QApplication
import time

import getpass
import subprocess


def Zazzle():

# Define: Home Directory
path = os.getcwd()
print ("Home Directory: ", path)
print ("Script Location: C:\Program Files\Agisoft\PhotoScan Pro\scripts")
print ("Output Path: ", path+"\\raw\\output")

# append all of the sku names to the sku list
skus = []

for directory in os.listdir(path+"\\raw\\tiff"):
skus.append(directory)
print("skus found: "+directory)

for sku in skus:
ImageDirectory = os.path.join(path,"raw","tiff",sku)
# Load Image Files into Chunk Camera
print('adding images from directory: '+ImageDirectory)

# Set Application Objects
doc = PhotoScan.app.document

# Define Chunk
chunk = PhotoScan.app.document.addChunk()
chunk.label = str(sku)

imageFiles = []
for photo in os.listdir (ImageDirectory):
if photo.endswith('.tif'):
imageFiles.append(photo)
else:
print('other file found: ',photo)

if len(imageFiles)>0:
print(imageFiles)
if len(imageFiles)==0:
print('no images found!')

os.chdir(ImageDirectory)

chunk.addPhotos(imageFiles)
chunk.importMasks(path='',method='alpha')
camera = chunk.cameras[0]

# match Photos
chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy,preselection=PhotoScan.GenericPreselection, filter_mask=True)

# align Photos
chunk.alignCameras()

# Build Dense Cloud
chunk.buildDenseCloud(quality=PhotoScan.MediumQuality)

#Build Model
chunk.buildModel(surface=PhotoScan.Arbitrary,interpolation=PhotoScan.EnabledInterpolation)

# Build UVs
chunk.buildUV(mapping=PhotoScan.GenericMapping)

# Build Texture
chunk.buildTexture(blending=PhotoScan.MosaicBlending, size=4096)

# Decimate Model
chunk.decimateModel(100000)

modelname = path+"\\output\\"+sku+".obj"

#Export Model & Save Doc
chunk.exportModel(modelname,texture_format="tif", texture=True,format="obj")

time.sleep(5)
doc.save(sku+".psz")
time.sleep(5)
sys.exit()
quit()

return 1

label = "Zazzle/Run"
PhotoScan.app.addMenuItem(label, Zazzle, "r")

print("Zazzle Menu Added")
print ("press r to run")

2
Python and Java API / Re: for loop image loading
« on: February 18, 2015, 07:37:43 PM »
seems like its failing at chunk.addPhotos(imageFiles)

I added the console output to my original post.

3
Python and Java API / for loop image loading [solved]
« on: February 18, 2015, 07:28:34 PM »
Not sure why this works

Code: [Select]
import PhotoScan
import os
import sys

from PySide.QtGui import QPixmap, QApplication
import time

import getpass
import subprocess


# Get User
username = getpass.getuser()

def Zazzle():

# Define: Home Directory
path = os.getcwd()
print ("Home Directory: ", path)

ImageDirectory = path+"\\raw\\tiff\\"
os.chdir(ImageDirectory)
print ("Image Directory: ", ImageDirectory)

# Set Application Objects
doc = PhotoScan.app.document
print ("Processing Images...")

# Define Chunk
chunk = PhotoScan.app.document.addChunk()
chunk.label = "MainChunk"

# Find Images
ImageFiles = []
for photo in os.listdir (ImageDirectory):
if photo.endswith('.tif'):
ImageFiles.append(photo)

if len(ImageFiles)>0:
print(ImageFiles)
if len(ImageFiles)==0:
print('no images found!')

print("Zazzle Running")
print ("Script Location: C:\Program Files\Agisoft\PhotoScan Pro\scripts")

# Load Image Files into Chunk Camera
chunk.addPhotos(ImageFiles)
chunk.importMasks(path='',method='alpha')
camera = chunk.cameras[0]

# match Photos
chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy,preselection=PhotoScan.GenericPreselection, filter_mask=True)

# align Photos
chunk.alignCameras()

# Build Dense Cloud
chunk.buildDenseCloud(quality=PhotoScan.MediumQuality)

#Build Model
chunk.buildModel(surface=PhotoScan.Arbitrary,interpolation=PhotoScan.EnabledInterpolation)

# Build UVs
chunk.buildUV(mapping=PhotoScan.GenericMapping)

# Build Texture
chunk.buildTexture(blending=PhotoScan.MosaicBlending, size=4096)

# Decimate Model
chunk.decimateModel(100000)

modelname = path+"\\output\\model.obj"

#Export Model & Save Doc
chunk.exportModel(modelname,texture_format="tif", texture=True,format="obj")

time.sleep(5)
doc.save("AgisoftProject.psz")
time.sleep(5)
sys.exit()
quit()

return 1

label = "Zazzle/Run"
PhotoScan.app.addMenuItem(label, Zazzle, "r")

print("Zazzle Menu Added")
print ("press r to run")


But then this does not

Code: [Select]
import PhotoScan
import os
import sys

from PySide.QtGui import QPixmap, QApplication
import time

import getpass
import subprocess


def Zazzle():

# Define: Home Directory
path = os.getcwd()
print ("Home Directory: ", path)
print ("Script Location: C:\Program Files\Agisoft\PhotoScan Pro\scripts")
print ("Output Path: ", path+"\\raw\\output")

# append all of the sku names to the sku list
skus = []

for directory in os.listdir(path+"\\raw\\tiff"):
skus.append(directory)
print("skus found: "+directory)

for sku in skus:
ImageDirectory = path+"\\raw\\tiff\\"+sku
# Load Image Files into Chunk Camera
print('adding images from directory: '+ImageDirectory)

# Set Application Objects
doc = PhotoScan.app.document

# Define Chunk
chunk = PhotoScan.app.document.addChunk()
chunk.label = str(sku)

imageFiles = []
for photo in os.listdir (ImageDirectory):
if photo.endswith('.tif'):
imageFiles.append(photo)
else:
print('other file found: ',photo)

if len(imageFiles)>0:
print(imageFiles)
if len(imageFiles)==0:
print('no images found!')

chunk.addPhotos(imageFiles)
chunk.importMasks(path='',method='alpha')
camera = chunk.cameras[0]

# match Photos
chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy,preselection=PhotoScan.GenericPreselection, filter_mask=True)

# align Photos
chunk.alignCameras()

# Build Dense Cloud
chunk.buildDenseCloud(quality=PhotoScan.MediumQuality)

#Build Model
chunk.buildModel(surface=PhotoScan.Arbitrary,interpolation=PhotoScan.EnabledInterpolation)

# Build UVs
chunk.buildUV(mapping=PhotoScan.GenericMapping)

# Build Texture
chunk.buildTexture(blending=PhotoScan.MosaicBlending, size=4096)

# Decimate Model
chunk.decimateModel(100000)

modelname = path+"\\output\\"+sku+".obj"

#Export Model & Save Doc
chunk.exportModel(modelname,texture_format="tif", texture=True,format="obj")

time.sleep(5)
doc.save(sku+".psz")
time.sleep(5)
sys.exit()
quit()

return 1

label = "Zazzle/Run"
PhotoScan.app.addMenuItem(label, Zazzle, "r")

print("Zazzle Menu Added")
print ("press r to run")



essentially what im trying to do is to check a directory for subdirectories... each subdirectory would be equal to a new product or sku which would load as an seperate chunk.

here is the console;
Code: [Select]
Agisoft PhotoScan Version: 1.1.2 build 2014 (64 bit)
OpenGL Vendor: ATI Technologies Inc.
OpenGL Renderer: AMD FirePro W7000 (FireGL V)
OpenGL Version: 4.3.12823 Compatibility Profile Context FireGL 13.352.1019.0
Maximum Texture Size: 16384
Quad Buffered Stereo: not enabled
ARB_vertex_buffer_object: supported
ARB_texture_non_power_of_two: supported
Zazzle Menu Added
press r to run
Loading project...
loaded project in 0.016 sec
Finished processing in 0.016 sec (exit code 1)
Home Directory:  C:\Users\nicholas.culpin\Desktop\PhotoGramExample\assets
Script Location: C:\Program Files\Agisoft\PhotoScan Pro\scripts
Output Path:  C:\Users\nicholas.culpin\Desktop\PhotoGramExample\assets\raw\output
skus found: selve
skus found: selveTwo
skus found: Thumbs.db
adding images from directory: C:\Users\nicholas.culpin\Desktop\PhotoGramExample\assets\raw\tiff\selve
['snap_0001.tif', 'snap_0002.tif', 'snap_0003.tif', 'snap_0004.tif', 'snap_0005.tif', 'snap_0006.tif', 'snap_0007.tif', 'snap_0008.tif', 'snap_0009.tif', 'snap_0010.tif', 'snap_0011.tif', 'snap_0012.tif', 'snap_0013.tif', 'snap_0014.tif', 'snap_0015.tif', 'snap_0016.tif', 'snap_0017.tif', 'snap_0018.tif', 'snap_0019.tif', 'snap_0020.tif', 'snap_0021.tif', 'snap_0022.tif', 'snap_0023.tif', 'snap_0024.tif', 'snap_0025.tif', 'snap_0026.tif', 'snap_0027.tif', 'snap_0028.tif', 'snap_0029.tif', 'snap_0030.tif', 'snap_0031.tif', 'snap_0032.tif', 'snap_0033.tif', 'snap_0034.tif', 'snap_0035.tif', 'snap_0036.tif', 'snap_0037.tif', 'snap_0038.tif', 'snap_0039.tif', 'snap_0040.tif', 'snap_0041.tif', 'snap_0042.tif', 'snap_0043.tif', 'snap_0044.tif', 'snap_0045.tif', 'snap_0046.tif', 'snap_0047.tif', 'snap_0048.tif', 'snap_0049.tif', 'snap_0050.tif', 'snap_0051.tif', 'snap_0052.tif', 'snap_0053.tif', 'snap_0054.tif', 'snap_0055.tif', 'snap_0056.tif', 'snap_0057.tif', 'snap_0058.tif', 'snap_0059.tif', 'snap_0060.tif', 'snap_0061.tif', 'snap_0062.tif', 'snap_0063.tif', 'snap_0064.tif', 'snap_0065.tif', 'snap_0066.tif', 'snap_0067.tif', 'snap_0068.tif', 'snap_0069.tif', 'snap_0070.tif', 'snap_0071.tif', 'snap_0072.tif', 'snap_0073.tif', 'snap_0074.tif', 'snap_0075.tif', 'snap_0076.tif', 'snap_0077.tif', 'snap_0078.tif', 'snap_0079.tif', 'snap_0080.tif', 'snap_0081.tif', 'snap_0082.tif', 'snap_0083.tif', 'snap_0084.tif', 'snap_0085.tif', 'snap_0086.tif', 'snap_0087.tif', 'snap_0088.tif', 'snap_0089.tif', 'snap_0090.tif', 'snap_0091.tif', 'snap_0092.tif', 'snap_0093.tif', 'snap_0094.tif', 'snap_0095.tif', 'snap_0096.tif', 'snap_0097.tif', 'snap_0098.tif', 'snap_0099.tif', 'snap_0100.tif', 'snap_0101.tif', 'snap_0102.tif', 'snap_0103.tif', 'snap_0104.tif', 'snap_0105.tif', 'snap_0106.tif', 'snap_0107.tif', 'snap_0108.tif', 'snap_0109.tif', 'snap_0110.tif', 'snap_0111.tif', 'snap_0112.tif', 'snap_0113.tif', 'snap_0114.tif', 'snap_0115.tif', 'snap_0116.tif', 'snap_0117.tif', 'snap_0118.tif', 'snap_0119.tif', 'snap_0120.tif', 'snap_0121.tif', 'snap_0122.tif', 'snap_0123.tif', 'snap_0124.tif', 'snap_0125.tif', 'snap_0126.tif', 'snap_0127.tif', 'snap_0128.tif']
Loading photos...
Can't load photos
Finished processing in 0.015 sec (exit code 0)
Generating masks...
Finished processing in 0 sec (exit code 1)
>>>

thanks!

4
Python and Java API / Re: BuildTexture Fails on Update
« on: February 10, 2015, 05:33:58 PM »
Hey Alexey...There were no printed console errors for this.

I was able to figure it out though, I think it was missing the (interpolation=PhotoScan.EnabledInterpolation) from the buildModel line. It didnt have anything to do with buildTexture.

5
Python and Java API / BuildTexture Fails on Update [solved]
« on: February 10, 2015, 12:54:39 AM »
I am getting positive feedback telling me that the texture is being built but the viewport does not reflect the status.  Only started to occur after I updated to 1.1.2, unless i missed something?


Here is my code;

Code: [Select]
import PhotoScan
import os
import sys

from PySide.QtGui import QPixmap, QApplication
import time

import getpass
import subprocess


# Get User
username = getpass.getuser()

def Custom():

# Define: Home Directory
path = os.getcwd()
print ("Home Directory: ", path)

ImageDirectory = path+"\\raw\\tiff\\"
os.chdir(ImageDirectory)
print ("Image Directory: ", ImageDirectory)

print("Running")
print ("Script Location: C:\Program Files\Agisoft\PhotoScan Pro\scripts")

# Set Application Objects
doc = PhotoScan.app.document
print ("Processing Images...")

# Define Chunk
chunk = PhotoScan.app.document.addChunk()
chunk.label = "MainChunk"

# Find Images
ImageFiles = []
for photo in os.listdir (ImageDirectory):
if photo.endswith('.tif'):
ImageFiles.append(photo)
if len(ImageFiles)>0:
print(ImageFiles)
if len(ImageFiles)==0:
print('no images found!')

# Load Image Files into Chunk Camera
chunk.addPhotos(ImageFiles)
chunk.importMasks(path='',method='alpha')
camera = chunk.cameras[0]

# match Photos
chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy,preselection=PhotoScan.GenericPreselection, filter_mask=True)

# align Photos
chunk.alignCameras()

# Build Dense Cloud
chunk.buildDenseCloud(quality=PhotoScan.MediumQuality)

#Build Model
chunk.buildModel(surface=PhotoScan.Arbitrary,interpolation=PhotoScan.EnabledInterpolation)

# Build UVs
chunk.buildUV(mapping=PhotoScan.GenericMapping)

# Build Texture
chunk.buildTexture(blending=PhotoScan.MosaicBlending, size=4096)

# Decimate Model
#chunk.decimateModel(100000)

modelname = path+"\\output\\model.obj"

#Export Model & Save Doc
chunk.exportModel(modelname,texture_format="tif", texture=True,format="obj")

time.sleep(5)
doc.save("AgisoftProject.psz")
time.sleep(5)
sys.exit()
quit()

return 1

label = "Custom/Run"
PhotoScan.app.addMenuItem(label, Custom, "r")

print("Custom Menu Added")
print ("press r to run")

any help would be greatly appreciated... not sure what I missed or broke.

6
You cant access external libraries for Photoscan, the scripts need to be executed from the Photoscan console with the application opened.

I was able to create a work around for this... Write your script and set it up so that the script is in the "start directory" and assign a hot key for it...( run at start directory is usually; user\AppData\Local\Agisoft\PhotoScan Pro\scripts) then write another script to open agisoft and press the hot key associated with the start up script. i used win32 library for the hot key selection. This allows you to do things before and after Photoscan does its thing.

hope that helps...

7
Python and Java API / Re: Python scripts collection?
« on: February 06, 2015, 08:07:41 PM »
NICE, thanks Alexey!

8
Python and Java API / Re: Start up script folder with multiple users
« on: January 22, 2015, 10:27:55 PM »
that worked thanks!

9
Python and Java API / Start up script folder with multiple users
« on: January 22, 2015, 07:51:24 PM »
Im running into an issue where agisoft app data directory does not exist across multiple user accounts? is there a way to fix this? It only exists with my own account from which agisoft was installed. I am using windows 7 64. thanks


10
Feature Requests / Re: viewport image export
« on: January 16, 2015, 06:48:26 PM »
is the current viewport vectors saved somewhere? can i position the camera within the main viewport and copy the settings out to code?

11
Feature Requests / Re: viewport image export
« on: January 16, 2015, 06:26:40 PM »
got it. thanks.

12
Feature Requests / Re: viewport image export
« on: January 16, 2015, 06:20:42 PM »
Also I cant seem to find "PhotoScan.app.viewpoint." in the docs: http://www.agisoft.com/pdf/photoscan_python_api_1_1_0.pdf

What are the parameters for this?

13
Feature Requests / Re: viewport image export
« on: January 16, 2015, 06:13:58 PM »
yea i was thinking I could do that. For our own purposes I was looking for a 2048 x 2048 image.thanks!

14
Feature Requests / viewport image export
« on: January 15, 2015, 09:34:52 PM »
I am working on automatic reporting features within agisoft python 1.1 api.

I would like to be able to export a viewport camera perspective as an image. The idea is to be able to email previews after the model is completed rather than opening an external 3d application and re-rendering. Perhaps export all the "predefined views" (top,bottom,left,right,front,back)

I am asking for a feature because currently the only option for preview images is through othrophoto export... while this is great is not ideal for anything but geography. perspective camera is more ideal for any other use case (product phtography for example)


thanks!!!

15
Python and Java API / Re: Meet Talus... plus some questions
« on: January 12, 2015, 11:24:21 PM »
@ keisel - thanks! This is certainly a work in progress. It is still an option to move the product over the camera but the set up isn't just used as a photogrammetry platform so it needed to be flexible enough to photograph a large range of product. (lots of shapes and sizes)


Pages: [1] 2