0

(im new to both machine learning and python so i wanted to see if i can do a project from github to learn while doing it) there were a lot of errors i got that i was able to fix by myself with the help of stackoverflow but im unable to fix this one so i hope someone can help me with this

global cap1     
cap1 = WebcamVideoStream(src=0).start() 
frame1 = cap1.read()
frame1 = cv2.resize(frame1,(600,500)) 

it says "OpenCV(4.1.2) /io/opencv/modules/imgproc/src/resize.cpp:3720: error: (-215:Assertion failed) !ssize.empty() in function 'resize' "

i tried doing this

frame1 = cv2.resize(frame1,(600,500),fx=0,fy=0, interpolation = cv2.INTER_CUBIC)

but it still shows the same error

this is the code for WebcamVideoStream class :

    class WebcamVideoStream:
    
    def __init__(self, src=0):
        self.stream = cv2.VideoCapture(src,cv2.CAP_DSHOW)
        (self.grabbed, self.frame) = self.stream.read()
        self.stopped = False

    def start(self):
            # start the thread to read frames from the video stream
        Thread(target=self.update, args=()).start()
        return self
        
    def update(self):
        # keep looping infinitely until the thread is stopped
        while True:
            # if the thread indicator variable is set, stop the thread
            if self.stopped:
                return
            # otherwise, read the next frame from the stream
            (self.grabbed, self.frame) = self.stream.read()

    def read(self):
        # return the frame most recently read
        return self.frame
    def stop(self):
        # indicate that the thread should be stopped
        self.stopped = True
Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
anan
  • 1
  • 1
  • 1
    have you try another source device? seems you are using direct show here `cv2.VideoCapture(src,cv2.CAP_DSHOW)` maybe you can use different flags https://docs.opencv.org/4.5.0/d4/d15/group__videoio__flags__base.html – danangjoyoo Apr 18 '22 at 07:05
  • you are using `imutils`. you haven't checked whether opening that "WebcamVideoStream" actually succeeded or not. – Christoph Rackwitz Apr 18 '22 at 12:44
  • ill try them, thank u for the suggestions! – anan Apr 18 '22 at 18:35

0 Answers0