I am doing image processing but here I a facing problem in my code for open cv part. Here is the code where error is been there. I have marked the error in the code.
if event.type == MOUSEMOTION and iswriting:
xcord,ycord = event.pos
pygame.draw.circle(DISPLAYSURFACE, WHITE, (xcord, ycord), 4.0)
number_xcord.append(xcord)
number_ycord.append(ycord)
if event.type == MOUSEBUTTONDOWN:
iswriting = True
if event.type == MOUSEBUTTONUP:
iswriting = False
number_xcord = sorted(number_xcord)
number_ycord = sorted(number_ycord)
rect_min_x, rect_max_x = max(number_xcord[0]-BOUNDARYINC, 0), min(WINDOWSIZEX, number_xcord[-1]+BOUNDARYINC)
rect_min_y, rect_max_y = max(number_ycord[0]-BOUNDARYINC, 0), min(WINDOWSIZEY, number_ycord[-1]+BOUNDARYINC)
number_xcord = []
number_ycord = []
img_arr = np.array(pygame.PixelArray(DISPLAYSURFACE))
if IMAGESAVE:
cv2.imwrite("image.png")
inmg_cnt +=1
if PREDICT:
image = cv2.resize(img_arr, (28,28)) <----- Error Here
image = np.pad(image, (10,10), 'constant', constant_value = 0)
image = cv2.resize(image, (28,28))/WHITE_INT
label = str(LABELS[np.argmax(MODEL.predict(image.reshape(1,28,28,1)))]).title()
pygame.draw.rect(DISPLAYSURFACE, RED, (rect_min_x, rect_min_y, rect_max_x-rect_min_y,
rect_max_y-rect_min_y), 3)
if event.type == KEYDOWN:
if event.unicode == 'N':
DISPLAYSURFACE.fill(BLACK)
pygame.display.update()
The error shown is this
cv2.error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'resize'
> Overload resolution failed:
> - src data type = 8 is not supported
> - Expected Ptr<cv::UMat> for argument 'src'
Please help me out. I have no clue what to do now.