Ask Your Question

Tintuk Tomin's profile - activity

2019-12-02 06:49:53 -0600 commented question Unable to see and take the picture in second time

If i call the function again the excution will stops on this line cv2.imshow("Capturing", frame)

2019-12-02 06:48:15 -0600 commented answer Unable to see and take the picture in second time

If i dont destroy the camera the window will be there. It wont be closed and the webcam will work all the time. I need t

2019-12-02 06:45:55 -0600 commented question Unable to see and take the picture in second time

@LBerger @berak @ Supra Thanks for your comments. But the problem remains there. I tried to take out webcam = cv2.VideoC

2019-12-02 04:53:53 -0600 marked best answer Unable to see and take the picture in second time

Code:

import cv2

def method_webcam_trigger()

    key = cv2. waitKey(1)
    webcam = cv2.VideoCapture(0)
    while True:
        try:
            check, frame = webcam.read()
            cv2.imshow("Capturing", frame)
            key = cv2.waitKey(1)
            if key == ord('s'): 
                cv2.imwrite(filename='saved_img.jpg', img=frame)
                webcam.release()
                cv2.waitKey(1650)
                cv2.destroyAllWindows()
                print("Image saved!")
                webcam.release()
                cv2.destroyAllWindows()
                break
            elif key == ord('q'):
                webcam.release()
                cv2.destroyAllWindows()
                break

Abouve the code which am using. I wrote the code to take the picture in a function and the function will activate in a button click. If i click on a button then the button will call this particular function(method_webcam_trigger) and save the picture. The problem is that if i click on that button again then it wont work. if i click the button on second time then the execution will stop on below line.

cv2.imshow("Capturing", frame)

Can anybody help to solve this? Below is another link which i saw asking the same question, but did't find the answer. https://stackoverflow.com/questions/2... Please help. Thankyou

2019-12-02 04:41:08 -0600 edited question Unable to see and take the picture in second time

Unable to see and take the picture in second time import cv2 def method_webcam_trigger() key = cv2. waitKey(1) webcam

2019-12-02 04:39:54 -0600 edited question Unable to see and take the picture in second time

Unable to see and take the picture in second time import cv2 def method_webcam_trigger() key = cv2. waitKey(1) webcam

2019-12-02 04:38:17 -0600 received badge  Editor (source)
2019-12-02 04:38:17 -0600 edited question Unable to see and take the picture in second time

Unable to see and take the picture in second time import cv2 def method_webcam_trigger() key = cv2. waitKey(1) webcam

2019-12-02 04:15:21 -0600 asked a question Unable to see and take the picture in second time

Unable to see and take the picture in second time import cv2 def method_webcam_trigger() key = cv2. waitKey(1)