So finden Sie Konturen im gepunkteten Text captcha BildPython

Python-Programme
Anonymous
 So finden Sie Konturen im gepunkteten Text captcha Bild

Post by Anonymous »

Ich bin Neuling zu OpenCV. Ich versuche die Konturen des Captcha -Bildes zu finden. Es funktioniert nicht nur, wenn mein Captcha -Bild den gepunkteten Text enthält.import numpy as np
import cv2 as cv
import imgaug.augmenters as iaa

im = cv.imread('dataset/1.jpg')
imgray = cv.cvtColor(im, cv.COLOR_BGR2GRAY)

imgray = cv.threshold(imgray, 127, 255, 0)[1]

dst = cv.Canny(imgray,0,150)
blured = cv.blur(dst,(5,5),0)
img_thresh = cv.adaptiveThreshold(blured,255,cv.ADAPTIVE_THRESH_GAUSSIAN_C, cv.THRESH_BINARY_INV, 11, 2)

kernel = cv.getStructuringElement(cv.MORPH_RECT, (3,3))
threshed = cv.morphologyEx(img_thresh,cv.MORPH_CLOSE,kernel)

contours, hierarchy = cv.findContours(dst, cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE)
print(len(contours))
# cv.drawContours(im, contours, -1, (0, 255, 0), 3)

cv.imshow("img_thresh",img_thresh)
cv.imshow("dst",dst)
cv.imshow("threshed",threshed)
cv.waitKey(0)
cv.destroyAllWindows()
< /code>
Kann jemand dabei helfen? Gibt es eine Möglichkeit, Konturen in diesem Bild zu finden? />

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post