Пример #1
0
def getBoundingBoxImage(original, settings, cutNo, thickness=1, color=None):
	"""Same as above but will paint the bounding boxes
	original should be the image data
	settings should be of class Settings
	cutNo as int
	color as CV_RGB"""

	# Get the cut defined by cutNo from the cuts from the first cut ratio in settings
	cut = lib.findMeans(cv.cvGetSize(original), settings.cutRatios[0])[cutNo]

	# Get the BW edge image
	edgeImage = getEdgeImage(original, settings)

	# Find the margin
	margin = marginCalculator.getPixels(original, cut, settings.marginPercentage)

	tmp = []
	tmp.append(cut)
	components = analyzeCut(original, edgeImage, cut, settings)
	lib.drawMargin(original, cut, margin)

	# Draw the components
	lib.drawBoundingBoxes(original, components, thickness, color)

	return original
Пример #2
0
def getBlobImage(original, settings, cutNo):
	"""Show the colored blobs in an image at the cut specified
	by cutNo as int. The cut ratio are placed in the settings and only
	the first cut in this ratio-list will be analyzed.
	original should be the image data
	settings should be of class Settings
	cutNo as int"""

	# Get the cut defined by cutNo from the cuts from the first cut ratio in settings
	cut = lib.findMeans(cv.cvGetSize(original), settings.cutRatios[0])[cutNo]

	# Get the BW edge image
	edgeImage = getEdgeImage(original, settings)

	# Find the margin
	margin = marginCalculator.getPixels(original, cut, settings.marginPercentage)

	# Clever hack for putting the cut in an array
	tmp = []
	tmp.append(cut)

	# Get results
	(blobImage, components) = analyzeCut(original, edgeImage, cut, settings, True)
	lib.drawLines(blobImage, blobImage, tmp)
	lib.drawMargin(blobImage, cut, margin)

	# Return result, what a surprise
	return blobImage