gpt4 book ai didi

python - cv2.namedWindow和imshow无法正常工作

转载 作者:行者123 更新时间:2023-12-02 17:19:26 25 4
gpt4 key购买 nike

这个简单的代码无法正常工作。

output = cv2.namedWindow("Output", cv2.WINDOW_AUTOSIZE)
cv2.imshow(output, saliencyMap)
cv2.waitKey(0)
它应该在 saliencyMap窗口中显示 "Output",但是它正在生成两个窗口(如下)。
我正在使用spyder编辑器,并且也收到此消息。
You might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded.
QObject::moveToThread: Current thread (0x7fbf1e53c600) is not the object's thread (0x7fbf1e6f0850).
Cannot move to target thread (0x7fbf1e53c600)`
enter image description here

最佳答案

namedWindow是一个函数,它是void函数,因此它不提供任何输出值。 imshow将字符串和Mat作为输入。
正确的应该是:

import cv2

img = cv2.imread('img.png')
cv2.namedWindow("Output", cv2.WINDOW_AUTOSIZE)
cv2.imshow("Output", img)
cv2.waitKey(0)

关于python - cv2.namedWindow和imshow无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62887068/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com