Python Forum
python script cant find folder where files are kept
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python script cant find folder where files are kept
#1
I am trying to access a folder "frames" which contains image files which i want to open with python. My code is:

import os
       import matplotlib.pyplot as plt
       import cv2
       from matplotlib.widgets import RectangleSelector


      #global constants
      img = None
      tl_list = []
      br_list = []
      object_list = []

      #constants
      image_folder = 'C:/Users/Angel of Darkness/Downloads/Desktop/Thesis/videos/1_05/frames'
      savedir = 'annotations'
      obj = 'red_hat'

      if __name__ == '__main__':
          for n, image_file in enumerate(os.scandir(frames)):
              img = image_file
              fig, ax = plt.subplots(1)
              image = cv2.imread(image_file.path)
              image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
              ax.imshow(image)
              plt.show()


However when I run this in Anaconda virtual environment, i get the following error:

Traceback (most recent call last):
File "trctocsv.py", line 19, in <module>
for n, image_file in enumerate(os.scandir(frames)):
NameError: name 'frames' is not defined


It seems "frames" folder can not be read by my script. Any suggestions how to resolve this?
Reply


Messages In This Thread
python script cant find folder where files are kept - by Shameendra - Nov-23-2018, 03:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question How to add Python folder in Windows Registry ? Touktouk 1 248 Feb-20-2024, 01:04 PM
Last Post: DeaD_EyE
  Compare folder A and subfolder B and display files that are in folder A but not in su Melcu54 3 532 Jan-05-2024, 05:16 PM
Last Post: Pedroski55
  Rename files in a folder named using windows explorer hitoxman 3 735 Aug-02-2023, 04:08 PM
Last Post: deanhystad
  Rename all files in a folder hitoxman 9 1,482 Jun-30-2023, 12:19 AM
Last Post: Pedroski55
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,196 Jun-29-2023, 11:57 AM
Last Post: gologica
Question Need help for a python script to extract information from a list of files lephunghien 6 1,076 Jun-12-2023, 05:40 PM
Last Post: snippsat
  script to calculate data in csv-files ledgreve 0 1,094 May-19-2023, 07:24 AM
Last Post: ledgreve
  package script cant find sibling script when executed from outside Bock 3 870 Mar-03-2023, 04:26 PM
Last Post: snippsat
  Find duplicate files in multiple directories Pavel_47 9 3,074 Dec-27-2022, 04:47 PM
Last Post: deanhystad
  How to loop through all excel files and sheets in folder jadelola 1 4,461 Dec-01-2022, 06:12 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020