`>
the code
import cv2
import os
import time
import uuid
IMAGES_PATH = 'Tensorflow/workspace/images/collectedimages'
labels = ['hello', 'thanks', 'yes', 'no', 'IloveYou']
number_imgs = 15
for label in labels:
!mkdir {'Tensorflow\workspace\images\collectedimages\\'+label}
cap = cv2.VideoCapture(0)
print('collecting image for {}'.format(label))
time.sleep(2)
for imgnum in range(number_imgs):
ret, frame = cap.read()
imgname = os.path.join(IMAGES_PATH, label, label+'.'+'{}.jpeg'.format(str(uuid.uuid1())))
cv2.imwrite(imgname, frame)
cv2.imshow('frame', frame)
time.sleep(5)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
the error
error Traceback (most recent call last)
<ipython-input-6-8ea005f6434e> in <module>
7 ret, frame = cap.read()
8 imgname = os.path.join(IMAGES_PATH, label, label+'.'+'{}.jpeg'.format(str(uuid.uuid1())))
----> 9 cv2.imwrite(imgname, frame)
10 cv2.imshow('frame', frame)
11 time.sleep(5)
error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-i1s8y2i1\ opencv\modules\imgcodecs\src\loadsave.cpp:753: error: (-215:Assertion failed) !_img.empty() in function 'cv::imwrite'
real time object detection project