def analyzeImage(original): scaleImage = cv.cvCreateImage(cv.cvSize(int(original.width*scale), int(original.height*scale)), 8, 3) cv.cvResize(original, scaleImage) # Create 1-channel image for the egdes edgeImage = cv.cvCreateImage(cv.cvGetSize(scaleImage), 8, 1) # Retrieve edges edgeDetector.findBWEdges(scaleImage, edgeImage, edgeThreshold1, edgeThreshold2) # Get cuts cuts = lib.findGoldenMeans(cv.cvGetSize(scaleImage)) # Run along allComponents = [] for cut in cuts: cutComponents = analyzeCut(scaleImage, edgeImage, cut) allComponents.append(cutComponents) # Get the collected component_dictionaries for dict in allComponents: lib.drawBoundingBoxes(original, dict, scale) # Draw the margins for cut in cuts: lib.drawMargin(original, cut, margin, scale) #include if super margen is need to drawn #lib.drawMargin(original, cut, superMargin, scale) return (original, allComponents)
image = highgui.cvLoadImage (filename) if not image: print "Error loading image '%s'" % filename print "" sys.exit(-1) threshold1 = 70; threshold2 = 70; <<<<<<< HEAD out = cv.cvCreateImage(cv.cvGetSize(image), 8, 3) edgeDetector.findEdges(image, out, threshold1, threshold2) print "Finding the golden means in the picture" lines = lib.findGoldenMeans(cv.cvGetSize(image)) # Define cut cut = lines[0] print "Test plot and line scanner methods" points = lineScanner.naiveLineScanner(out, cut) out = highgui.cvLoadImage (filename) comp_dict = {} featureDetector.floodFillLine(image, out, points, cut, lo, up, comp_dict) # Set margin margin = 15