I have defined cap in
def fingerCursor(device):
global cap
global cap_height
global cap_width
cap = cv2.VideoCapture(device)
#cap.set(cv2.cap_PROP_FRAME_HEIGHT,720)
#cap.set(cv2.cap_PROP_FRAME_WIDTH,1280)
cap_height = cap.get(cv2.cap_PROP_FRAME_HEIGHT)
cap_width = cap.get(cv2.cap_PROP_FRAME_WIDTH)
#print(cap_height,cap_width)
But still whenever I am running this part of my code, it says cap not defined. It also has the same problem with cap_height and cap_width.
while(cap.isOpened()):
## capture frame-by-frame
ret, frame_raw = cap.read()
while not ret:
ret,frame_raw = cap.read()
frame_raw = cv2.flip(frame_raw, 1)
frame = frame_raw[:round(cap_height),:round(cap_width)] # ROI of the image
cv2.imshow("raw_frame",frame)