Forum

Author Topic: Detecting Markers and creating Scalebars in Agisoft 1.1.5  (Read 11066 times)

SamC-E

  • Newbie
  • *
  • Posts: 7
    • View Profile
Detecting Markers and creating Scalebars in Agisoft 1.1.5
« on: April 16, 2015, 10:02:12 PM »
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
« Last Edit: April 24, 2015, 07:06:30 PM by SamC-E »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15165
    • View Profile
Re: Detecting Markers and creating Scalebars in Agisoft 1.1.5
« Reply #1 on: April 21, 2015, 02:11:01 PM »
Hello Sam,

after marker detection you need to perform the following:

Code: [Select]
ab = chunk.addScalebar(chunk.markers[1], chunk.markers[9])
ab.reference.distance = 0.44
and etc.
Best regards,
Alexey Pasumansky,
Agisoft LLC

SamC-E

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Detecting Markers and creating Scalebars in Agisoft 1.1.5
« Reply #2 on: April 24, 2015, 06:11:44 PM »
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

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15165
    • View Profile
Re: Detecting Markers and creating Scalebars in Agisoft 1.1.5
« Reply #3 on: April 24, 2015, 06:26:25 PM »
Hello Sam,

Could you post the latest version of the script that you are using (part related to the marker detection)? And the console pane output related to the script run.
Best regards,
Alexey Pasumansky,
Agisoft LLC

SamC-E

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Detecting Markers and creating Scalebars in Agisoft 1.1.5
« Reply #4 on: April 24, 2015, 06:37:26 PM »
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
« Last Edit: April 24, 2015, 07:07:39 PM by SamC-E »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15165
    • View Profile
Re: Detecting Markers and creating Scalebars in Agisoft 1.1.5
« Reply #5 on: April 24, 2015, 06:41:49 PM »
Hello Sam,

And does this script create the scale bar and add the reference distance?

Are there at all any markers detected by the detection operation?
Best regards,
Alexey Pasumansky,
Agisoft LLC

SamC-E

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Detecting Markers and creating Scalebars in Agisoft 1.1.5
« Reply #6 on: April 24, 2015, 06:45:21 PM »
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.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15165
    • View Profile
Re: Detecting Markers and creating Scalebars in Agisoft 1.1.5
« Reply #7 on: April 24, 2015, 06:46:34 PM »
Hello Sam,

Indices in the brackets of chunk.markers[] actually represent the order of the marker in the list of the Workspace pane (starting from zero) - it is not a marker label.
« Last Edit: April 24, 2015, 06:52:45 PM by Alexey Pasumansky »
Best regards,
Alexey Pasumansky,
Agisoft LLC

SamC-E

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Detecting Markers and creating Scalebars in Agisoft 1.1.5
« Reply #8 on: April 24, 2015, 06:53:55 PM »
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