ArgParse -Fehler: Die folgenden Argumente sind erforderlichPython

Python-Programme
Anonymous
 ArgParse -Fehler: Die folgenden Argumente sind erforderlich

Post by Anonymous »

Code: Select all

import argparse
import os

#import skvideo.io
import cv2

def main(video_path, nth_sample, output_path):
if not os.path.exists(output_path):
os.makedirs(output_path)

cap = cv2.VideoCapture(video_path)
frame_num = 1
ret, frame = cap.read()
while ret:
frame_num += 1
if frame_num % nth_sample == 0:
cv2.imwrite(os.path.join(output_path, 'frame_' + str(frame_num).zfill(5) + '.png'), frame)
ret, frame = cap.read()
print (frame_num)

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Extrace frames from a video file')

parser.add_argument('C:/Users/Pratik/AppData/Local/Programs/Python/Python36-32/WhatsApp Video 2017-11-21 at 18.59.55.mp4',help='path to video file')

parser.add_argument('-n','--5',help='Sample rate to extract every nth frame',type = int,default=1)
parser.add_argument('-o','--C:/Users/Pratik/AppData/Local/Programs/Python/Python36-32/frame',help='path to output test images, defaults to out',default='out')
args = parser.parse_args()
main(**vars(args))
< /code>

Ich erhalte den folgenden Fehler, ich bin neu in Python, also denke ich, dass ich einen Fehler beim [url=viewtopic.php?t=23808]Übergeben[/url] der Variablen mache, aber ich bin nicht sicher, wo. < /p>

usage: Frme.py [-h] [-n 5]
[-o C:/USERS/PRATIK/APPDATA/LOCAL/PROGRAMS/PYTHON/PYTHON36_32/FRAME]
C:/Users/Pratik/AppData/Local/Programs/Python/Python36-32/WhatsApp
Video 2017-11-21 at 18.59.55.mp4
Frme.py: error: the following arguments are required: C:/Users/Pratik/AppData/Local/Programs/Python/Python36-32/WhatsApp Video 2017-11-21 at 18.59.55.mp4

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post