a-PyTorch-Tutorial-to-Object-Detection icon indicating copy to clipboard operation
a-PyTorch-Tutorial-to-Object-Detection copied to clipboard

How to run it on a video path?

Open prajnasb opened this issue 4 years ago • 1 comments

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

prajnasb avatar Jun 04 '20 06:06 prajnasb

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.

Philopatearashraf avatar Jun 17 '20 14:06 Philopatearashraf