Exemple #1
0
def main():
	"""
	Just the test
	This method is a god resource on how to handle the results
	"""

	filename = sys.argv[1]
	image = highgui.cvLoadImage (filename)

	cutRatios = [0.61]
	settings = Settings(cutRatios)
	image = highgui.cvLoadImage (filename)
	thickness = 4
	settings.setMarginPercentage(0.025)
	cutNo = int(sys.argv[2])
	
	cut = lib.findMeans(cv.cvGetSize(image), settings.cutRatios[0])[cutNo]
	
	# Get the BW edge image
	edgeImage = naiveMethod.getEdgeImage(image, settings)

	(blobImg, comp) = naiveMethod.analyzeCut(image, edgeImage, cut, settings, 'True')
	#liste af liste 
	
	gridPointsList = grid.gridIt(blobImg, comp)
	#print gridPointsList
	points = centerOfMass(gridPointsList)
	#(x,y)
	for point in points:
		cv.cvLine(image, cv.cvPoint(point, 0), cv.cvPoint(point,600), COL_GREEN)
	lib.drawBoundingBoxes(image, comp)
	
	#highgui.cvSaveImage('floodfillbilledet.png', blobImg)
	#highgui.cvSaveImage('boindingboxbilledet.png', boxxImg)
	
	showImage(image, 'name')
def main():
	"""
	Just the test
	This method is a good resource on how to handle the results.
	Save images in this method if you have to.
	"""

	filename = sys.argv[1]
	image = highgui.cvLoadImage (filename)

	cutRatios = [lib.PHI]
	#cutRatios = [0.75]
	ratios = (0.51803398874999995, 0.56803398875, 0.61803398875000004, 0.66666000000000003, 0.71803398875000002, 0.76803398874999995, 0.81803398875, 0.86803398875000004 , 0.91803398874999997, 0.96803398875000002)
	settings = Settings(cutRatios)
	image = highgui.cvLoadImage (filename)
	thickness = 4
	settings.setMarginPercentage(0.024)
	cuts = (0,1,2,3)
	cut = int(sys.argv[2])
	winname = sys.argv[3]+".png"
	#settings.setThresholds(100,150)
	# Set the color for the boxes
	#color = lib.COL_BLACK
	#color = lib.COL_WHITE
	#color = lib.COL_RED
	color = lib.COL_GREEN
	#color = lib.COL_BLUE
	tmp = 0
	for r in cuts:
		cut = r
		print str(r), '---------------------------------'
		for i in ratios:
			#settings = Settings(cutRatios)
			print i
			cutd = lib.findMeans(cv.cvGetSize(image), i)[cut]
			edgeImage = naiveMethod.getEdgeImage(image, settings)
			components = naiveMethod.analyzeCut(image, edgeImage, cutd, settings)
			print len(components)		
			tmp = tmp + len(components)
	print tmp
	blobImg = blobResult(image, settings, cut)
	boxxImg = boundingBoxResult(image, settings, cut, thickness, color)
	cutt = lib.findMeans(cv.cvGetSize(image), settings.cutRatios[0])[cut]
	# cuttet verdi, dog skal det vi generaliseres lidt
	oriantesen = cutt.getPoints()[0].x == cutt.getPoints()[1].x
	if oriantesen:
		cutPixel = cutt.getPoints()[1].x
	else:
		cutPixel = cutt.getPoints()[1].y
	
	if oriantesen:
	#	print 'hej'
		cv.cvLine(boxxImg, cv.cvPoint(cutPixel, cutt.getPoints()[0].y), cv.cvPoint(cutPixel, cutt.getPoints()[1].y), lib.COL_RED)
	else:
		cv.cvLine(boxxImg, cv.cvPoint(cutt.getPoints()[0].x, cutPixel), cv.cvPoint(cutt.getPoints()[1].x, cutPixel), lib.COL_RED)
	# Save images
	highgui.cvSaveImage('floodfillbilledet.png', blobImg)
	highgui.cvSaveImage(winname, boxxImg)

	# Show images
	compareImages(blobImg, boxxImg, "blob", winname)