Need help finding why the error with cv2.imshow('frame',frame) (Working in Jupyter Notebook)
This program is to collect many images so that I can train a model that has 10 gestures.
import cv2 #opencv
import os
import time
import uuid
# Directory to collect images for training
IMAGES_PATH='Tensorflow/workspace/images/collectedimages'
# Setting an array with all the labels
labels = ['gest-1', 'gest-2', 'gest-3','gest-4','gest-5','gest-6','gest-7','gest-8', 'gest-
9', 'gest-10']
number_imgs = 20
# loop throught each of the labels in the array
for label in labels:
#create a directory for each of the labels
os.mkdir ('Tensorflow/workspace/images/collectedimages/'+label)
# Initialize the webcam (openCV)
cap = cv2.VideoCapture(0)
# time.sleep(2)
print('Collecting images for {}'.format(label))
time.sleep(5)
#Loop through the number of images we want to collect
for imgnum in range(number_imgs):
ret,frame = cap.read()
# Naming of the pictures
# .format(str(uuid.uuid1())) makes sure that we dont duplicate names
imgname = os.path.join(IMAGES_PATH, label, label+'.'+'{}.jpg'.format(str(uuid.uuid1())))
cv2.imwrite(imgname, frame)
cv2.imshow('frame',frame)
time.sleep(2)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()