Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
296 views
in Technique[技术] by (71.8m points)

python - Crop Image Based Upon CNN Model Predicted Values for License Plates

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)]

code

question from:https://stackoverflow.com/questions/65877712/crop-image-based-upon-cnn-model-predicted-values-for-license-plates

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...