cap = cv2.VideoCapture('video.mp4')
def realTime():
while True:
success, img = cap.read()
img =cv2.resize(img,(0,0),None,0.5,0.5)
ih, iw, channels = img.shape
# Draw the crossing lines
cv2.line(img, (0, middle_line_position), (iw, middle_line_position), (255, 0, 255), 1)
cv2.line(img, (0, up_line_position), (iw, up_line_position), (0, 0, 255), 1)
cv2.line(img, (0, down_line_position), (iw, down_line_position), (0, 0, 255), 1)
# Show the frames
cv2.imshow('Output', img)
if __name__ == '__main__':
realTime()
input_size = 320
blob = cv2.dnn.blobFromImage(img, 1 / 255,(input_size,input_size), [0, 0, 0], 1, crop=False)
so this was my code and it keeps on throwing error NameError: name 'img' is not defined
on the blob asignment line.
i tried updating all commands and modules but still this error is showing up and now i cannot find a solution
New contributor
Sushant Singh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.