Forum

Author Topic: can anyone help with this error?  (Read 6173 times)

rananna

  • Newbie
  • *
  • Posts: 7
    • View Profile
can anyone help with this error?
« on: December 04, 2017, 05:21:59 PM »
I am tearing my hair out trying to get python to prompt for information.
I keep getting the following error:
2017-12-04 09:18:40 usage: batch.py [-h] -i INPUT -p PSZ -o OUTPUT -r RESOLUTION
2017-12-04 09:18:40 batch.py: error: the following arguments are required: -i/--input, -p/--psz, -o/--output, -r/--resolution
2017-12-04 09:18:40 Error: 2
>>>
here is an excerpt from my python script:

def parse_args():
   parser = argparse.ArgumentParser(description="Input/Output folder to save 3D model")
   #parser.add_argument('--inputpath', '-p', action="store", help="path to photos", required=True)
   #parser.add_argument('--outputfile', '-o', action="store", help="output file name", required=True)
   parser.add_argument('-i','--input',help='Input Photos Path',required=True)
   parser.add_argument('-p','--psz',help='psz file name',required=True)
   parser.add_argument('-o','--output',help='Output Folder Path',required=True)
   parser.add_argument('-r','--resolution',help='Output Ortho Resolution',required=True,type=float)
   return parser.parse_args()
def main():
   print("Script is starting")
   args = parse_args()
   print("args.input")
   print("args.psz")
   print("args.output")

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14847
    • View Profile
Re: can anyone help with this error?
« Reply #1 on: December 04, 2017, 06:45:06 PM »
Hello rananna,

For me it worked in the following way (just simple example based on your code):

Code: [Select]
import argparse, PhotoScan

parser = argparse.ArgumentParser(description="Input/Output folder to save 3D model")
parser.add_argument('-i','--input', help='Input Photos Path', type = str)
parser.add_argument('-p','--psz', help='psz file name', type = str)
parser.add_argument('-o','--output', help='Output Folder Path', type = str)
parser.add_argument('-r','--resolution', help='Output Ortho Resolution', type = float)

print("Script is starting")
args = parser.parse_args()

print(args.input)
print(args.psz)
print(args.output)
print(args.resolution)

So I used the following call in the command line and got proper output:
Code: [Select]
photoscan.exe -r parser.py -i "input_path" -p "project.psz" -o "output_path" -r 42
Code: [Select]
input_path
project.psz
output_path
42.0
Best regards,
Alexey Pasumansky,
Agisoft LLC

rananna

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: can anyone help with this error?
« Reply #2 on: December 04, 2017, 08:10:18 PM »
thank you!
This worked.