sgrvinod / a-PyTorch-Tutorial-to-Object-Detection

SSD: Single Shot MultiBox Detector | a PyTorch Tutorial to Object Detection
MIT License
3.04k stars 718 forks source link

How to run it on a video path? #56

Open prajnasb opened 4 years ago

prajnasb commented 4 years ago

Hi.. it would be helpful if you give me a script for running the program, given a video path as well as through webcam.

Philopatearashraf commented 4 years ago

Hi I had the same problem and I find a solution

video_path = 'D:\my college books\SEMESTERS\8 SENIOR2\Waterloo\cutting video into frames'  #put the video path in here
    imageObjects = []
    imgFiles  = [
        join( video_path, fn )                    # Create full paths to images
        for fn in listdir( video_path )           # For each item in the image folder
        if isfile( join( video_path, fn ) )       # If the item is indeed a file
        and fn.lower().endswith(('.png','.jpg'))   # Which ends with an image suffix (can add more types here if needed)
    ]

    for imgFile in imgFiles:
        original_image = Image.open(imgFile, mode='r')
        original_image = original_image.convert('RGB')
        output_im = detect(original_image, min_score=0.2, max_overlap=0.6, top_k=200,suppress= prohibted_list).show()

Hope this will help.