Header Ads

Header ADS

Image capture using opencv in python

import cv2 # importing cv2 liberary

cam = cv2.VideoCapture(0)

count = 0

while True:
    ret, img = cam.read()

    cv2.imshow("Test", img)

    if not ret:
        break

    k=cv2.waitKey(1)

    if k%256==27:
        #For Esc key
        print("Close")
        break
    elif k%256==32:
        #For Space key

        print("Image "+str(count)+"saved")
        file='C:/Users/Dell/Desktop/Image/img'+str(count)+'.jpg'
        cv2.imwrite(file, img)
        count +=1

cam.release
cv2.destroyAllWindows

1 comment:

  1. hi..i am using python 3.9.0, images are not going to folder .

    ReplyDelete

Theme images by enot-poloskun. Powered by Blogger.