Norod78

Example: Enumarate jpgs, print their size, using CV

Dec 23rd, 2020
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1.  
  2. import os
  3. import cv2
  4.  
  5. FOLDER_WITH_IMAGES = './aligned-images/Alfred-E-Neuman/'
  6.  
  7. files = [f for f in os.listdir(FOLDER_WITH_IMAGES) if f.endswith('.jpg')]
  8.  
  9. for infile in files:
  10.  
  11.    print('Processing file %s ...' % (infile))
  12.    full_path = os.path.join(FOLDER_WITH_IMAGES, infile)  
  13.    cv_image = cv2.imread(full_path)
  14.    height, width = cv_image.shape[:2]
  15.    print('\t(%s X %s)' % (width,height))
  16.  
  17. print('Done')
Advertisement
Add Comment
Please, Sign In to add comment