这是我使用的代码:
import threading
import cv2
def showimg(*a):
cv2.imshow('img', a)
cv2.waitKey(5)
cv2.destroyAllWindows()
def main():
img = cv2.imread('tree.jpg')
t = threading.Thread(target = showimg, args = (img) )
t.start()
if __name__ == '__main__':
main()
一个简单的代码,如何将彩色图像传递给函数?
我收到如下错误:
TypeError: mat is not a numerical tuple
我无法理解它。
Q1:我错过了什么?
Q2:彩色图和灰度图一样吗?
最佳答案
我一开始不明白你为什么要使用 import thread
。
您可以通过相对简单得多的方式将图像传递给函数:
import cv2
def showimg(a):
cv2.imshow('img', a)
img = cv2.imread('tree.jpg')
showimg(img)
cv2.waitKey(0)
关于multithreading - 如何将图像传递给函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42777740/