当我运行我的tkinter代码时,当按下按钮并使用函数playsound()作为其命令时,它会崩溃python。 提交到这里:
from scipy.signal import convolve2d
sortedTmp=[q1,q2,q3,q4,q5,q6,q7,q8,q9]
sorted1=[]
for i in sortedTmp:
for j in i:
sorted1.append(j)
sorted_circles = np.array(sorted1)
circle_radius = sorted_circles[...,-1].min()
kernel = np.ones((2*circle_radius,2*circle_radius),dtype=int)
out0 = convolve2d(255-img, kernel,'same')
detected_vals = out0[sorted_circles[...,1], sorted_circles[...,0]]
detected_vals -= detected_vals.min()
mask = detected_vals>detected_vals.max()/2
for i in range(36):
cv2.putText(cimg,str(i),(sorted1[i][0],sorted1[i][1]), cv2.FONT_HERSHEY_SIMPLEX, 1,(255,0,0),3,cv2.LINE_AA)
if mask[i]==1:
cv2.putText(cimg,"B",(sorted1[i][0],sorted1[i][1]-28), cv2.FONT_HERSHEY_SIMPLEX, 0.5,(255,0,0),1,cv2.LINE_AA)
else:
cv2.putText(cimg,"W",(sorted1[i][0],sorted1[i][1]-28), cv2.FONT_HERSHEY_SIMPLEX, 0.5,(255,0,0),1,cv2.LINE_AA)
cv2.imshow('detected circles',cimg)
cv2.waitKey(0)
cv2.destroyAllWindows()