I have developed a DNN Model that predicts the placements of license plates. I then want to take the predicted rectangle and crop the image based upon its placement in the image.
Current Error:
TypeError: only integer scalar arrays can be converted to a scalar index
Current Code:
import cv2
import imutils
import numpy as np
import pytesseract
pytesseract.pytesseract.tesseract_cmd = r'C:Program Files (x86)Tesseract-OCResseract.exe'
img = cv2.resize(cv2.imread("licensed_car109.jpeg",cv2.IMREAD_COLOR) / 255, dsize=(WIDTH, HEIGHT))
y_hat = model.predict(img.reshape(1, WIDTH, HEIGHT, 3)).reshape(-1) * WIDTH
xt, yt = y_hat[0], y_hat[1]
xb, yb = y_hat[2], y_hat[3]
img = cv2.cvtColor(img.astype(np.float32), cv2.COLOR_BGR2RGB)
image = cv2.rectangle(img, (xt, yt), (xb, yb), (0, 0, 255), 1)
plt.imshow(image)
plt.show()
Cropped = img[x:(xt, xb), y:(yt, yb)]
question from:
https://stackoverflow.com/questions/65877712/crop-image-based-upon-cnn-model-predicted-values-for-license-plates 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…