Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· OpenAIAi2 WildChat-4.8M (AI2)

hi why this code does not show image? import cv2 import numpy as np selected = False…

  1. User

    hi why this code does not show image? import cv2 import numpy as np

    selected = False tommy = cv2.imread(r"C:\Users\Alireza\Desktop\Tommy800.png") points = []

    def click(event, x, y, flags, param): if event == cv2.EVENT_LBUTTONDOWN: points.append([x,y]) cv2.circle(tommy, (x, y), 2, (0, 0, 255), -1)

    cv2.namedWindow("Tommy") cv2.setMouseCallback("Tommy", click)

    while True:

     if not selected:
            cv2.imshow("Tommy", tommy)
    
  2. Assistant

    The code provided should display an image and allow the user to mark points by clicking on the image.

    Here are a few potential reasons why the image may not be displaying:

    1. The image path may be incorrect. Double-check the file path to ensure it is pointing to the correct location of the image file on your computer.
    2. The image file may be in a format that OpenCV cannot read. Check to make sure the image file is in a supported format such as JPEG or PNG.
    3. The image file may be corrupted. Try opening the image file using a different image viewer to verify if it is readable.
    4. There may be an issue with your OpenCV installation. Try reinstalling OpenCV or updating to the latest version.

    If none of these solutions work, please provide more information about any error messages or behaviors you are encountering so that we can assist you further.