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 god resource on how to handle the results """ filename = sys.argv[1] image = highgui.cvLoadImage (filename) cutRatios = [0.75] #cutRatios = [lib.PHI] settings = Settings(cutRatios) image = highgui.cvLoadImage (filename) thickness = 4 settings.setMarginPercentage(0.025) cutNo = int(sys.argv[2]) #udtrak af cut cut = lib.findMeans(cv.cvGetSize(image), settings.cutRatios[0])[cutNo] # cuttet verdi, dog skal det vi generaliseres lidt oriantesen = cut.getPoints()[0].x == cut.getPoints()[1].x if oriantesen: cutPixel = cut.getPoints()[1].x else: cutPixel = cut.getPoints()[1].y #Get the BW edge image edgeImage = expandedMethod.getEdgeImage(image, settings) (blobImg, comp) = expandedMethod.analyzeCut(image, edgeImage, cut, settings, 'True') #Liste af liste # Find the margin margin = marginCalculator.getPixels(image, cut, settings.marginPercentage) lib.drawMargin(image, cut, margin) #Udregning af gridet gridPointsList = grid.gridIt(blobImg, comp) #hvor mange pixel der er pa den ende side i forhold til den anden, i procent pixelRatio = pixelSideCounter(gridPointsList, cutPixel, oriantesen) print pixelRatio #Udregning af center og mass points = centerOfMass(gridPointsList, oriantesen) #Draw the cut #print cut.getPoints()[0].y #print cut.getPoints()[1].y #print cut.getPoints()[0].x #print cut.getPoints()[1].x #print cutPixel if oriantesen: # print 'hej' cv.cvLine(image, cv.cvPoint(cutPixel, cut.getPoints()[0].y), cv.cvPoint(cutPixel, cut.getPoints()[1].y), COL_RED) else: cv.cvLine(image, cv.cvPoint(cut.getPoints()[0].x, cutPixel), cv.cvPoint(cut.getPoints()[1].x, cutPixel), COL_RED) #Draw center of mass for point in points: if oriantesen: # print 'hej' # print point cv.cvLine(image, cv.cvPoint(point, cut.getPoints()[0].y), cv.cvPoint(point, cut.getPoints()[1].y), COL_GREEN) else: # print point cv.cvLine(image, cv.cvPoint(cut.getPoints()[0].x, point), cv.cvPoint(cut.getPoints()[1].x, point), COL_GREEN) lib.drawBoundingBoxes(image, comp, 4, COL_GREEN) #highgui.cvSaveImage('floodfillbilledet.png', blobImg) highgui.cvSaveImage('centerOfMass.png', image) showImage(image, 'name')