Skip to content

'cap' object is not self. initialized #1781

@rohandubey

Description

@rohandubey

🐛 Bug

cap.release() function should be embedded in utils.dataset as closing of a webcam will governed by utils.dataset not detect.py.
But on running utils.dataset, it was throwing off error saying cap is not a a self declared variable in Class LoadStream.

To Reproduce (REQUIRED)

Input:
In utils.dataset() file, class LoadStream:

def __next__(self):
        self.count += 1
        img0 = self.imgs.copy()
        if cv2.waitKey(1) == ord('q'):  # q to quit
            self.cap.release()
            cv2.destroyAllWindows()
            raise StopIteration

Output:

self.cap.release()
AttributeError: 'LoadStreams' object has no attribute 'cap'

Expected behavior

utlis.dataset should effectively be able to release camera.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions