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

Pages: [1]
1
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!

2
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.

3
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


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

5
Python and Java API / Meet Talus... plus some questions
« on: January 08, 2015, 06:44:33 PM »
Hello everyone

I would like you to meet Talus...who has many talents.  :)
One of which is providing us with very accurate camera array.

The Shoe image provided below is one of our first tests and the results are exciting.





As you can imagine, having a robot means we are trying to automate as much of our pipeline as possible. I've been putting together a bunch scripts to interact with various other aspects of our pipeline (most of which are proprietary). Eventually we would like to have a single click to photograph & process all of our data but for now we are really happy to just see things up and running properly.

I do have a few questions regarding the python API...I've been hitting some walls. The Script seems to get as far as chunk.matchPhotos() but then fails when it gets into photo alignment. If anyone has ideas on ways I can improve this I would very much appreciate it.

I am using Agisoft PhotoScan Professional Edition version 1.1.0 build 2004 (64)

Here is my current script...:

Code: [Select]
import os
import PhotoScan

# Define: Home Directory
Home = "C:\\raw\\tiff\\"
os.chdir(Home)
print ("home: " + Home)

# Set Application Objects
doc = PhotoScan.app.document
print ("Script Started")

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

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

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

# Match Photos
chunk.matchPhotos()

# Align Photos
chunk.photoAlign()

# Build Dense Cloud
chunk.buildDenseCloud()

#Build Model
chunk.buildModel()

# Build UVs
chunk.buildUV()

# Build Texture
chunk.buildTexture()
doc.save()




Anyways thanks everyone...and special thanks to the agisoft team for being so responsive.
Take Care!

-nick-

Pages: [1]