보이는 것처럼 사소하지 않습니다. 모든 문자에 대해 32x32 png 이미지를 생성하고 화이트 노이즈를 추가합니다. 비디오의 backgound가 움직이고 있습니다. 8 및 6과 같은 캐릭터는 그다지 다르지 않습니다.
cap = cv2.VideoCapture("rtsp:...")
time.sleep(2)
templates = {}
w=[]
h=[]
for i in range(0,11):
templates["template_"+str(i)]=cv2.imread(str(i)+'.bmp',0)
tmp_w,tmp_h=templates["template_"+str(i)].shape[::-1]
w.append(tmp_w)
h.append(tmp_h)
threshold = 0.70
while(True):
les_points=[[],[],[],[],[],[],[],[],[],[],[]]
ret, frame = cap.read()
if frame==None:
break
crop_image=frame[38:70,11:364]
gray=cv2.cvtColor(crop_image,cv2.COLOR_BGR2GRAY)
for i in range(0,11):
res= cv2.matchTemplate(gray,templates["template_"+str(i)],cv2.TM_CCOEFF_NORMED)
loc = np.where(res >= threshold)
for pt in zip(*loc[::-1]):
les_points[i].append(pt[0])
cv2.rectangle(crop_image, pt, (pt[0] + w[i], pt[1] + h[i]), (0,i*10,255), 2)
print les_points
cv2.imshow('normal',crop_image)
if cv2.waitKey(1)& 0xFF == ord('p'):
threshold=threshold+0.01
print threshold
if cv2.waitKey(1)& 0xFF == ord('m'):
threshold=threshold-0.01
print threshold
if cv2.waitKey(1) & 0xFF == ord('q'):
break
내가 템플릿의 caracters의 동일한 크기로 분할하여 이미지를 다른 테스트를하고 있어요 : 여기에 순간 내 코드입니다. 그러나 이것은 좋은 결과를주지 못합니다.
각 문자에 대해 템플릿 매칭을 시도 했습니까? – Miki
Miki가 응답 해 주셔서 감사합니다. 저는 25 프레임/초입니다. 각 문자마다 하나씩 템플릿 일치를 수행 할 수 있습니까? 이 작은 이미지를 비교하는 것보다 작은 이미지로 나누어야합니까? –
프레임 속도는 보장 할 수 없지만 다른 OCR 방식보다 빠릅니다. 10 개의 숫자에 대해 10 개의 템플리트가 있고, 슬래시에 대해 1 개의 템플리트 (점에 대해 1)가 있습니다. 그런 다음 전체 이미지에 11 (12) 번 템플릿 일치 (각 템플릿 사용)를 적용합니다. 당신은 일치하는 결과의 최대 값을보고 올바른 자리를 찾을 수 있어야합니다 ... – Miki