简体   繁体   中英

Python OpenCV cv2.imshow() not working in windows

I'm trying to load a sample image using python 3.6 OpenCV. I do not know why my image is not loaded when I run my program. This is my code:

import cv2
import time

test1=cv2.imread("C:/Users/JP/Desktop/JP Files/Python/Python
Programs/FaceRecog/data/test1.jpg")
cv2.imshow("Test", test1)

I already changed the slash to C:\UsersJP\Desktop\JP Files\Python\Python Programs\FaceRecog\data\test1.jpg but still no luck.

did you try with double '\\' ?

okay some more characters...

Did you try by adding cv2.waitkey(0) at the end of the program. Hope it will work!!!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM