TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType' 有什么问题?

时间:2021-02-19 01:24:47

标签: python pandas cv2

def load_file():
  # Проходим циклом и загружаем все файлы из папок
  cat_files = []
  dog_files = []

  for i in (cat_name):
    df = cv2.VideoCapture(file_name_cat + i)
    frameCount = int(df.get(cv2.CAP_PROP_FRAME_COUNT))
    frameWidth = int(df.get(cv2.CAP_PROP_FRAME_WIDTH))
    frameHeight = int(df.get(cv2.CAP_PROP_FRAME_HEIGHT))
    cat = np.empty((frameCount, frameHeight, frameWidth, 3), np.dtype('uint8'))
    fc = 0
    ret = True
    while (fc < frameCount  and ret): # The error is given here
      ret, cat[fc] = df.read()
      fc += 1
    cat_files.append(cat)
    
  for i in (dog_name):
    df = cv2.VideoCapture(file_name_dog + i)
    frameCount = int(df.get(cv2.CAP_PROP_FRAME_COUNT))
    frameWidth = int(df.get(cv2.CAP_PROP_FRAME_WIDTH))
    frameHeight = int(df.get(cv2.CAP_PROP_FRAME_HEIGHT))
    dog = np.empty((frameCount, frameHeight, frameWidth, 3), np.dtype('uint8'))
    fc = 0
    ret = True
    while (fc < frameCount  and ret):
      ret, dog[fc] = df.read()
      fc += 1
    dog_files.append(dog)

  # Применяем функцию обработки для получения стройного массива
  cat_np = min_obs(cat_files)
  dog_np = min_obs(dog_files)

  # Возвращаем полученные массивы
  return cat_np, dog_np

帮我看看是什么问题?我还不是很有经验,出现了很多问题。大约 5 个小时,我试图在互联网上找到解决方案。当我单独运行它时,一切正常

错误文本本身:

TypeError                                 Traceback (most recent call last)
<ipython-input-7-140c0f9251eb> in <module>()
----> 1 cat_files, dog_files = load_file()

<ipython-input-5-2526f87de82a> in load_file()
     12     ret = True
     13     while (fc < frameCount  and ret):
---> 14       ret, cat[fc] = df.read()
     15       fc += 1
     16     cat_files.append(cat)

TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

0 个答案:

没有答案