Is anyone know how to connect tkinter webcam to Yolov5?

This is a classic reason why we should avoid using wildcard * imports.

The original question contained this:

from tkinter import *
from PIL import Image, ImageTk

the wildcard * imports all the functions of the tkinter module.
One of the functions is Image.

In the next line, we see Image imported again via the PIL module and this will overwrite the first Image.

It is for this reason that we prefer an alias like this:

import tkinter as tk

Because now we can identify where “same named” functions, like Image come from.

One would be tk.Image and the other image.

This does not in itself resolve the issue, but removes one of the errors or sources of confusion (and potentially others).

Leave a Comment