Помогите отрисовать такой прямоугольник в tkinter
Мне нужно сделать так, чтобы на трансляции изображения с веб-камеры был виден такой прямоугольник, как на фото. Как можно его наложить прямо на видео, я разобрался, но у меня лишь отображается треугольник снизу от видео.
from tkinter import *
import cv2
from PIL import Image, ImageTk
# Define a video capture object
vid = cv2.VideoCapture(0)
# Declare the width and height in variables
width, height = 1000, 1000
# Set the width and height
vid.set(cv2.CAP_PROP_FRAME_WIDTH, width)
vid.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
# Create a GUI app
app = Tk()
# Bind the app with Escape keyboard to
# quit app whenever pressed
app.bind('<Escape>', lambda e: app.quit())
# Create a label and display it on app
label_widget = Label(app)
label_widget.pack()
canvas = Canvas(bg="white", width=250, height=200)
canvas.pack(anchor=CENTER, expand=1)
canvas.create_rectangle(10, 20, 200, 60, fill="", outline="#004D40")
def open_camera():
_, frame = vid.read()
opencv_image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGBA)
captured_image = Image.fromarray(opencv_image)
# Convert captured image to photoimage
photo_image = ImageTk.PhotoImage(image=captured_image)
# Displaying photoimage in the label
label_widget.photo_image = photo_image
# Configure image in the label
label_widget.configure(image=photo_image)
# Repeat the same process after every 10 seconds
label_widget.after(10, open_camera)
# Create a button to open the camera in GUI app
button1 = Button(app, text="Open Camera", command=open_camera)
button1.pack()
# Create an infinite loop for displaying app on screen
app.mainloop()
