Пишу кликер для игрушки) Использую opencv.
Вот код:
import cv2
import mss
import time
import numpy as np
monitor = {"top": 0, "left": 0, "width": 960, "height": 1080}
color = (255, 255, 0)
thickness = 10
net = cv2.dnn.readNetFromONNX('model/best-m.onnx')
start_time = time.time()
x = 1
counter = 0
with mss.mss() as sct:
while True:
counter+=1
img = np.array(sct.grab(monitor=monitor))
blob = cv2.dnn.blobFromImage(img, swapRB=True, crop=False)
net.setInput(blob)
boxes, masks = net.forward(['detection_out_final', 'detection_masks'])
small = cv2.resize(img, (0, 0), fx=0.5, fy=0.5)
cv2.imshow("Computer Vision", small)
if (time.time() - start_time) > x :
print("FPS: ", counter / (time.time() - start_time))
counter = 0
start_time = time.time()
if cv2.waitKey(25) & 0xFF == ord('q'):
cv2.destroyAllWindows()
break
Когда запускаю вибивает ошибку:
Traceback (most recent call last):
File "d:\top\test.py", line 22, in <module>
boxes, masks = net.forward(['detection_out_final', 'detection_masks'])
cv2.error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\layers\convolution_layer.cpp:420: error: (-2:Unspecified error) Number of input channels should be multiple of 3 but got 4 in function 'cv::dnn::ConvolutionLayerImpl::getMemoryShapes'
Помогите пофиксить пожалуйста.