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 - SamC-E

Pages: [1]
1
That worked, thank you for your help Alexey! So simple,  I've made the change and now I am able to run the script straight through with automatic scaling and rotation as well. :)

Thankyou for all your help.

Sam

2
Yes it detects the four markers I have (coded 12bit circular targets 1, 9, 4,8), but there is no scalebar created so neither is a reference distance created and the script does not continue past the creating scalebar section.

3
Yes, this is the script from the start to the scalebar point where it stops.

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

def main():

#Photoscan Python Full Process Automation
#PhotoScan version 1.1.5

# DEFINE PROCESSING SETTINGS
print("---Defining processing settings...")

#Photo Folder Directory
AgisoftPhotos = "/home/sam3d/Documents/AgisoftPhotos/"

#Import Environment Variables
filename = '/home/sam3d/Documents/AgisoftScannerConfig/Variable_File.txt'
fin=open(filename, 'r')
USER =fin.readline()
NAME =fin.readline()
AA =fin.readline()
DPQ =fin.readline()
MQ =fin.readline()

print("Variables transferred.")
print(USER)
print(NAME)
print(AA)
print(DPQ)
print(MQ)

NAME = NAME[:-1]

#Define: Camera calib file
#CalibFile = "/home/sam3d/Documents/AgisoftScannerConfig/CalibrationFile.xml"
#Define Cameras
CamerasFile = "/home/sam3d/Documents/AgisoftScannerConfig/ScannerCamerasCalibration.xml"
#Define: PhotoScan Project File
PhotoScanProjectFile = "/home/sam3d/Documents/Agisoft_Photoscan_Projects/"
#Model Directory
ModelDirec = ("/home/sam3d/Documents/AgisoftModels/"+NAME+"/")
#Define Photo_List
pdstring= ('/home/sam3d/Documents/AgisoftPhotos/' + NAME + "/*.jpg")
#pdstring = PhotoScan.app.getExistingDirectory("Choose desired scan folder")
#pdstring += "/"
photo_list = glob.glob(pdstring)
#Naming Script
label = NAME

#Script Start
#Get main app objects
doc = PhotoScan.app.document
app = PhotoScan.Application()

# create chunk
chunk = PhotoScan.Chunk()
chunk.label = "chunk"
doc.addChunk(chunk)

#Load Images
print("---Loading Images---")
print(photo_list)
chunk.addPhotos(photo_list)

# SAVE PROJECT
print("---Saving project...")
print("File: " + PhotoScanProjectFile + label + ".psz")
if not(doc.save(PhotoScanProjectFile + label + ".psz")):
   app.messageBox("Saving project failed!")

#Marker Detection
#Detect Markers
print("---Detecting Markers---")
chunk.detectMarkers(PhotoScan.TargetType.CircularTarget12bit, 50)

ab = chunk.addScalebar(chunk.markers[1], chunk.markers[9])
ab.reference.distance = 0.4243

"""bc = chunk.addScalebar(chunk.markers[9], chunk.markers[4])
bc.reference.distance = 0.4243

cd = chunk.addScalebar(chunk.markers[4], chunk.markers[8])
cd.reference.distance = 0.4243

da = chunk.addScalebar(chunk.markers[8], chunk.markers[1])
da.reference.distance = 0.4243

ac = chunk.addScalebar(chunk.markers[1], chunk.markers[4])
ac.reference.distance = 0.60

bd = chunk.addScalebar(chunk.markers[9], chunk.markers[8])
bd.reference.distance = 0.60"""

"""chunk.markers[1].reference.location = PhotoScan.Vector((0,0,0.3))
chunk.markers[9].reference.location = PhotoScan.Vector((0.3,0,0))
chunk.markers[4].reference.location = PhotoScan.Vector((0,0,-0.3))
chunk.markers[8].reference.location = PhotoScan.Vector((-0.3,0,0))"""

I have put the other markers in comments in the script at present so I can just test creating one first.

This is the console pane output:

Code: [Select]
Agisoft PhotoScan Version: 1.1.5 build 2034 (64 bit)
OpenGL Vendor: X.Org
OpenGL Renderer: Gallium 0.4 on AMD OLAND
OpenGL Version: 3.0 Mesa 10.3.2
Maximum Texture Size: 16384
Quad Buffered Stereo: not enabled
ARB_vertex_buffer_object: supported
ARB_texture_non_power_of_two: supported
---Defining processing settings...
Variables transferred.
Chris

Chris_24_04_15

low

lowest

low

---Loading Images---
['/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.63.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.61.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.75.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.60.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.67.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.85.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.14.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.20.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.58.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.55.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.23.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.77.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.43.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.40.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.13.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.71.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.39.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.52.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.56.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.16.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.19.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.4.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.10.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.29.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.26.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.50.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.82.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.59.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.28.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.46.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.35.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.81.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.17.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.38.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.22.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.15.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.41.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.74.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.68.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.30.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.32.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.57.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.9.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.2.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.3.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.54.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.18.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.11.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.69.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.65.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.42.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.51.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.25.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.79.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.5.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.78.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.84.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.48.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.6.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.24.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.33.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.31.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.36.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.72.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.70.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.44.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.27.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.53.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.83.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.8.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.37.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.34.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.80.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.86.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.62.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.7.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.66.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.73.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.49.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.64.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.12.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.45.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.47.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.76.jpg', '/home/sam3d/Documents/AgisoftPhotos/Chris_24_04_15/192.168.0.21.jpg']
Loading photos...
Finished processing in 0.013952 sec (exit code 1)
---Saving project...
File: /home/sam3d/Documents/Agisoft_Photoscan_Projects/Chris_24_04_15.psz
Saving project...
saved project in 0.008013 sec
Finished processing in 0.008054 sec (exit code 1)
---Detecting Markers---
Detecting markers...
192.168.0.2.jpg: 0 markers
192.168.0.3.jpg: 0 markers
192.168.0.4.jpg: 0 markers
192.168.0.5.jpg: 0 markers
192.168.0.6.jpg: 0 markers
192.168.0.7.jpg: 0 markers
192.168.0.8.jpg: 2 markers
192.168.0.9.jpg: 0 markers
192.168.0.10.jpg: 0 markers
192.168.0.11.jpg: 0 markers
192.168.0.12.jpg: 0 markers
192.168.0.13.jpg: 0 markers
192.168.0.14.jpg: 0 markers
192.168.0.15.jpg: 0 markers
192.168.0.16.jpg: 0 markers
192.168.0.17.jpg: 0 markers
192.168.0.18.jpg: 0 markers
192.168.0.19.jpg: 0 markers
192.168.0.20.jpg: 0 markers
192.168.0.21.jpg: 0 markers
192.168.0.22.jpg: 0 markers
192.168.0.23.jpg: 0 markers
192.168.0.24.jpg: 0 markers
192.168.0.25.jpg: 0 markers
192.168.0.26.jpg: 0 markers
192.168.0.27.jpg: 0 markers
192.168.0.28.jpg: 1 markers
192.168.0.29.jpg: 0 markers
192.168.0.30.jpg: 0 markers
192.168.0.31.jpg: 0 markers
192.168.0.32.jpg: 0 markers
192.168.0.33.jpg: 0 markers
192.168.0.34.jpg: 0 markers
192.168.0.35.jpg: 0 markers
192.168.0.36.jpg: 0 markers
192.168.0.37.jpg: 0 markers
192.168.0.38.jpg: 0 markers
192.168.0.39.jpg: 0 markers
192.168.0.40.jpg: 0 markers
192.168.0.41.jpg: 0 markers
192.168.0.42.jpg: 0 markers
192.168.0.43.jpg: 0 markers
192.168.0.44.jpg: 3 markers
192.168.0.45.jpg: 0 markers
192.168.0.46.jpg: 0 markers
192.168.0.47.jpg: 0 markers
192.168.0.48.jpg: 1 markers
192.168.0.49.jpg: 0 markers
192.168.0.50.jpg: 0 markers
192.168.0.51.jpg: 0 markers
192.168.0.52.jpg: 0 markers
192.168.0.53.jpg: 0 markers
192.168.0.54.jpg: 0 markers
192.168.0.55.jpg: 0 markers
192.168.0.56.jpg: 0 markers
192.168.0.57.jpg: 0 markers
192.168.0.58.jpg: 1 markers
192.168.0.59.jpg: 0 markers
192.168.0.60.jpg: 0 markers
192.168.0.61.jpg: 0 markers
192.168.0.62.jpg: 1 markers
192.168.0.63.jpg: 0 markers
192.168.0.64.jpg: 2 markers
192.168.0.65.jpg: 0 markers
192.168.0.66.jpg: 0 markers
192.168.0.67.jpg: 0 markers
192.168.0.68.jpg: 0 markers
192.168.0.69.jpg: 0 markers
192.168.0.70.jpg: 0 markers
192.168.0.71.jpg: 0 markers
192.168.0.72.jpg: 0 markers
192.168.0.73.jpg: 2 markers
192.168.0.74.jpg: 0 markers
192.168.0.75.jpg: 0 markers
192.168.0.76.jpg: 0 markers
192.168.0.77.jpg: 0 markers
192.168.0.78.jpg: 1 markers
192.168.0.79.jpg: 0 markers
192.168.0.80.jpg: 3 markers
192.168.0.81.jpg: 0 markers
192.168.0.82.jpg: 0 markers
192.168.0.83.jpg: 1 markers
192.168.0.84.jpg: 0 markers
192.168.0.85.jpg: 0 markers
192.168.0.86.jpg: 0 markers
Finished processing in 7.78508 sec (exit code 1)
>>>


Regards
Sam

4
Hi Alexey,

Thankyou for your quick reply but unfortunately this solution isn't working for me at present. When getting to this point in my script it exits with exit code 1.

The script successfully identifies the coded markers and they are named 'target 1' etc. I have tried a couple of different ways of inputting the marker name/number such as '1' or 'target1' but if I put 'target 1' I am given an invalid syntax error from Photoscan.

Is there anything you could suggest further that might be causing my issue?

Regards
Sam

5
Hi,

Does anyone know what how to do the input for creating a scalebar?

I have been attempting this and having looked on the forums and in the literature I haven't be able to find a suitable example to help, I know the command 'chunk.addScalebar(scalebar=?)', I have successfully detected the markers through the script but it gets stuck at creating the scalebar as I don't know the form to call the markers with.

Here's my piece of script for this:
Code: [Select]
#Marker Detection
#Detect Markers
print("---Detecting Markers---")
chunk.detectMarkers(PhotoScan.TargetType.CircularTarget12bit, 50)

ab = chunk.addScalebar(scalebar= chunk.Markers[1], chunk.Markers[9])
ab.reference.distance = 0.4243

bc = chunk.addScalebar(scalebar= chunk.Markers[9], chunk.markers[4])
bc.reference.distance = 0.4243

cd = chunk.addScalebar(scalebar= chunk.Markers[4], chunk.markers[8])
cd.reference.distance = 0.4243

da = chunk.addScalebar(scalebar= chunk.Markers[8], chunk.markers[1])
da.reference.distance = 0.4243

ac = chunk.addScalebar(scalebar= chunk.Markers[1], chunk.markers[4])
ac.reference.distance = 0.60

bd = chunk.addScalebar(scalebar= chunk.Markers[9], chunk.markers[8])
bd.reference.distance = 0.60

chunk.markers[1].reference.location = PhotoScan.Vector((0,0,0.3))
chunk.markers[9].reference.location = PhotoScan.Vector((0.3,0,0))
chunk.markers[4].reference.location = PhotoScan.Vector((0,0,-0.3))
chunk.markers[8].reference.location = PhotoScan.Vector((-0.3,0,0))

I would also like to check that for 4 markers in a diamond shape around the origin/centre(0,0,0) that the reference locations are correct as I have not been able to test this part due to the script not reaching it yet.

Any help would be fantastic!
Sam

6
Python and Java API / Re: Import Cameras/Build Points?
« on: April 15, 2015, 09:02:10 AM »
Hi gchaprnka,

I've been working on pretty much the exact same thing as you over the last week or so and actually found a few things in your script that really helped me. I also had your problem of the final model being outside of cameras but not of object in focus. After about 3 hours of searching through the forum (and mostly Alexey's posts  :P) I think I have found a solution to the issue, I'm not that happy with the solution but it does work.

Basically it seems to be the calibration file that is causing the problem (for me at least) in that the cameras are not calibrated properly through the script, I'm pretty sure it's my calibration file as I can manually import the calibration file and it does the same thing, the fact you're getting the same weird results suggests your calibration file might be wrong in the same way mine is. Unfortunately I haven't been able to work out what is wrong with my calibration file so my solution is just to use the functions:

Code: [Select]
chunk.alignCameras()
directly after the 'matchingPhotos' section. This just does the alignment that is normally done through the GUI, as I haven't been able to get the calibration file to work it's the second best solution. I hope this helps and if you have made any progress on this I would be very interested.

Regards
Sam

7
Python and Java API / Python Script for Basic Full Process Chain
« on: April 14, 2015, 05:56:42 AM »
Hello,

Firstly I have only been using python for a couple of weeks now so I am not anywhere near what you would call fully python literate but I will probably be able to understand any responses I get and I am running Agisoft on a Ubuntu system.

Basically I have been trying to create a python script and have found only one response (http://www.agisoft.com/forum/index.php?topic=1881.msg10014#msg10014) about a script that can progress through the Agisoft processing but this response was too complex for my needs and my attempts to adapt it so far have failed.
I currently do the process manually but I need to automate it to the greatest extent I can, below I define the basic manual process I carry out for clarity:

- Add Folder
- Align Photos [Accuracy(preferably able to choose different settings), Pair preselection(Disabled), Advanced (Default)]
- Build Dense Cloud [Quality & Depth Filtering(preferably able to choose different settings)]
- Build Mesh [Surface Type(Arbitrary), Source Data(Dense Cloud), Face Count(preferably able to choose different settings),  Advanced(Default)]
- Build Texture [All default settings]
- Save Project as desired
- Export Model as Wavefront OBJ

I'm sure/hope someone out there has a link to a post I have missed, a script or the skeleton of a script that has this functionality, or the ability to quite quickly guide me onto the right path.
Any help anyone could offer would be greatly appreciated as the literature and forums have left me a bit stumped.

Regards
Sam

Pages: [1]