0

How change the 'q' to call my button i create
How change the 'q' to call my button i create

import cv2
from tkinter import *

root = Tk()
# 1.creating a video object
video = cv2.VideoCapture(0)
# 2. Variable
a = 0
# 3. While loop

button1= Button(root, text="Take a picture", height= 5, width=10)
button1.pack(side=BOTTOM)

while True:
    a = a + 1
    # 4.Create a frame object
    check, frame = video.read()
  
    # 5.show the frame!
    cv2.imshow("Capturing",frame)
    # 6.for playing
    key = cv2.waitKey(1)
    if key == ord('q'):
        break
        cv2.destroyAllWindows
# 7. image saving
showPic = cv2.imwrite("awit.png",frame)
print(showPic)
# 8. shutdown the camera
video.release()

How change the 'q' to call my button i create

Delrius Euphoria
  • 14,910
  • 3
  • 15
  • 46
VPlay
  • 25
  • 3
  • 1
    Could you edit your post so all your code goes inside the code block, else it won't display properly. – LBJ May 22 '22 at 09:46
  • my bad forget to update it – VPlay May 22 '22 at 10:27
  • How can i change to a button instead pressing q? – VPlay May 22 '22 at 10:28
  • 1
    `command = awit` is not defined, what is it, and where is it from? – LBJ May 22 '22 at 10:42
  • its nothing forget to remove it – VPlay May 22 '22 at 10:46
  • 1
    Have a look at the answers [posted here.](https://stackoverflow.com/questions/35372700/whats-0xff-for-in-cv2-waitkey1) – LBJ May 22 '22 at 10:49
  • @Claudio I don't think its best for anyone else to "assume" what the OP has meant and change the title and the text and elaborate more on the question. If the OP confirms your assumption, then go ahead and edit the post – Delrius Euphoria Jun 06 '22 at 04:24
  • @Claudio Because from what I understood from the vague question, I thought the OP was asking on how to call a function when the button 'q' was pressed. But yes it was about to be closed and I am still surprised about the +3 upvotes on a poorly written question – Delrius Euphoria Jun 06 '22 at 05:04

0 Answers0