Ejemplo n.º 1
0
from quick_show import quick_show

files = os.listdir('data/examples')
counter = 0
for f in files:
	image = cv.LoadImage('data/examples/'+f)
	for plate in anpr.detect_plates(image):
		zzz = cv.CreateImage(cv.GetSize(plate), cv.IPL_DEPTH_8U, 3)
		cv.Smooth(plate, zzz)
		#
		cv.PyrMeanShiftFiltering(plate, zzz, 40, 15)
		foo = anpr.greyscale(plate)
		segmented = cv.CreateImage(cv.GetSize(plate), cv.IPL_DEPTH_8U, 1)
		bar = cv.CreateImage(cv.GetSize(plate), cv.IPL_DEPTH_8U, 1)
		cv.EqualizeHist(foo, segmented)
		cv.AdaptiveThreshold(segmented, bar, 255, 
			cv.CV_ADAPTIVE_THRESH_GAUSSIAN_C, cv.CV_THRESH_BINARY_INV,
			plate.height%2 == 0 and (plate.height+1) or plate.height, 
			plate.height/2)
		baz = cv.CreateImage(cv.GetSize(plate), cv.IPL_DEPTH_8U, 1)
		el = cv.CreateStructuringElementEx(1, 2, 0, 0, cv.CV_SHAPE_RECT)
		cv.Erode(bar, baz, el)
		#quick_show(plate)
		#quick_show(segmented)
		#quick_show(bar)
		quick_show(baz)
		for char in anpr.find_characters(foo, baz):
			cv.Rectangle(plate, (int(char.x1),int(char.y1)), 
				(int(char.x2), int(char.y2)), (255,0,0))
		quick_show(plate)
Ejemplo n.º 2
0
#!/usr/bin/env python
# encoding: utf-8
"""
test/contour.py

Testing contour processing.

Created by Oliver Smith on 2009-09-26.
Copyright (c) 2009 Oliver Smith. All rights reserved.
"""

import os
import cv
import anpr
from quick_show import quick_show

files = os.listdir('data/examples')
for f in files:
	image = cv.LoadImage('data/examples/'+f)
	grey,bw = anpr.preprocess(image)
	contours = set(anpr.find_characters(grey, bw))
	for bbox in contours:
		cv.Rectangle(image, (int(bbox.x1),int(bbox.y1)), 
			(int(bbox.x2), int(bbox.y2)), (255,0,0))
	quick_show(image)
Ejemplo n.º 3
0
files = os.listdir('data/examples')
counter = 0
for f in files:
    image = cv.LoadImage('data/examples/' + f)
    for plate in anpr.detect_plates(image):
        zzz = cv.CreateImage(cv.GetSize(plate), cv.IPL_DEPTH_8U, 3)
        cv.Smooth(plate, zzz)
        #
        cv.PyrMeanShiftFiltering(plate, zzz, 40, 15)
        foo = anpr.greyscale(plate)
        segmented = cv.CreateImage(cv.GetSize(plate), cv.IPL_DEPTH_8U, 1)
        bar = cv.CreateImage(cv.GetSize(plate), cv.IPL_DEPTH_8U, 1)
        cv.EqualizeHist(foo, segmented)
        cv.AdaptiveThreshold(
            segmented, bar, 255, cv.CV_ADAPTIVE_THRESH_GAUSSIAN_C,
            cv.CV_THRESH_BINARY_INV,
            plate.height % 2 == 0 and (plate.height + 1) or plate.height,
            plate.height / 2)
        baz = cv.CreateImage(cv.GetSize(plate), cv.IPL_DEPTH_8U, 1)
        el = cv.CreateStructuringElementEx(1, 2, 0, 0, cv.CV_SHAPE_RECT)
        cv.Erode(bar, baz, el)
        #quick_show(plate)
        #quick_show(segmented)
        #quick_show(bar)
        quick_show(baz)
        for char in anpr.find_characters(foo, baz):
            cv.Rectangle(plate, (int(char.x1), int(char.y1)),
                         (int(char.x2), int(char.y2)), (255, 0, 0))
        quick_show(plate)
Ejemplo n.º 4
0
import os
import cv
import anpr
from quick_show import quick_show

files = os.listdir('data/examples')
counter = 0
for f in files:
	image = cv.LoadImage('data/examples/'+f)
	for plate in anpr.detect_plates(image):
		zzz = cv.CreateImage(cv.GetSize(plate), cv.IPL_DEPTH_8U, 3)
		cv.Smooth(plate, zzz)
		#
		cv.PyrMeanShiftFiltering(plate, zzz, 40, 15)
		foo = anpr.greyscale(plate)
		segmented = cv.CreateImage(cv.GetSize(plate), cv.IPL_DEPTH_8U, 1)
		bar = cv.CreateImage(cv.GetSize(plate), cv.IPL_DEPTH_8U, 1)
		cv.EqualizeHist(foo, segmented)
		cv.AdaptiveThreshold(segmented, bar, 255, 
			cv.CV_ADAPTIVE_THRESH_GAUSSIAN_C, cv.CV_THRESH_BINARY_INV,
			plate.height%2 == 0 and (plate.height+1) or plate.height, 
			plate.height/2)
		baz = cv.CreateImage(cv.GetSize(plate), cv.IPL_DEPTH_8U, 1)
		el = cv.CreateStructuringElementEx(1, 2, 0, 0, cv.CV_SHAPE_RECT)
		cv.Erode(bar, baz, el)
		for char in anpr.find_characters(foo, baz):
			cv.Rectangle(plate, (int(char.x1),int(char.y1)), 
				(int(char.x2), int(char.y2)), (255,0,0))
		quick_show(plate)