我讀的圖像,並通過將左上角座標和矩形然後croping的image.Some客戶端的右下角座標找到感興趣區域感興趣區域(ROI)提供樣品如100 DPI,200 dpi或相同圖像的400 dpi圖像。在這些類型的圖像中,當具有不同dpi的圖像時,輸入座標位於其他位置。我正在做template matching任務,其中我給了包含文本的小模板。找到文本後,邊界框被繪製到匹配的部分。從該邊界框引用,我必須從圖像中找到父矩形然後保存在文件夾中。對於100 dpi的圖像,它正在工作,但一旦我改變圖像與不同的dpi矩形縮小。圖片爲:opencv的:爲不同的dpi的圖像
下面的代碼模板匹配的鏈接進行更新:
startX = abs(startX - 113)
startY = abs(startY - 5)
endX = abs(endX + 117)
endY = abs(endY + 208)
cv2.rectangle(image, (startX, startY), (endX, endY), (0, 0, 255), 2)
下面的代碼是尋找矩形和裁剪:
first = [660,1000]
last = [1030,1400]
i = 1
for imagePath in glob.glob(args["images"] + "/*.jpg"):
print imagePath
image = cv2.imread(imagePath)
cropped = ROI_extract(first,last,image)
savingName = "SGBAU_pink/pnr" + str(i) + ".jpg"
cv2.imwrite(savingName, cropped)
i = i + 1
cv2.imshow("Cropped",cropped)
cv2.waitKey(0)
哪有我修復了一個問題,以找到實際感興趣的區域不同dpi的圖像並找到確切的ROI?給一些粗略的想法來解決它。