我无法在定义的函数中打印任何内容。解决办法是什么?
import cv2
def ResimFarkBul(Resim1,Resim2):
Resim2 = cv2.resize(Resim2,(Resim1.shape[1],Resim1.shape[0]))
Fark_Resim = cv2.absdiff(Resim1,Resim2)
Fark_Sayı = cv2.countNonZero(Fark_Resim)
print(Fark_Sayı)
任何帮助将不胜感激。
答案 0 :(得分:0)
创建函数后您忘记调用该函数:
您只需要简单地调用它即可。
ResimFarkBul(arg1, arg2)
示例:
#create function
def print_something(arg1, arg2):
print("arg1 =>", arg1)
print("arg2 =>", arg2)
# now you need to call it
print_something("spam", "eggs") # this will print "arg1 => spam", "arg2 => eggs"
# if you call print_something() you ll get Error because you didnt give any arguments and declared the functions with arguments