(self, contour=None)
make image from contour
make image from contour
make image from contour
def make_new_outline_image(self, contour=None):
        '''
        make image from contour
        '''
        if HAVE_CV2 and contour is not None:
            perimeter = cv2.arcLength(contour,True)
            outline = self.make_blank_image()
            edgeimage = np.array(outline)   # make blank RGBA image array
            # self.draw_edges is the max deviation from a line (set to 0.3%)
            # you can fiddle with this
            approx = cv2.approxPolyDP(contour, self.draw_edges * perimeter, True)
            # outline with grey, width 1
            cv2.drawContours(edgeimage,[approx] , -1, self.outlineColor, self.outlineWidth)
            return Image.fromarray(edgeimage)
        else:   #PIL
            if self.room_outline is None:
                self.room_outline = self.load_image('room.png')
            edges = ImageOps.invert(self.room_outline.convert('L'))
            edges.paste(self.base)
            edges = edges.convert('L').filter(ImageFilter.SMOOTH_MORE)
            edges = ImageOps.invert(edges.filter(ImageFilter.FIND_EDGES))
            return make_transparent(edges, (0, 0, 0, 255))
def make_new_outline_image ( self , contour = None ) : if HAVE_CV2 and contour is not None : perimeter = cv2 . arcLength ( contour , True ) outline = self . make_blank_image ( ) edgeimage = np . array ( outline ) # make blank RGBA image array # self.draw_edges is the max deviation from a line (set to 0.3%) # you can fiddle with this approx = cv2 . approxPolyDP ( contour , self . draw_edges * perimeter , True ) # outline with grey, width 1 cv2 . drawContours ( edgeimage , [ approx ] , - 1 , self . outlineColor , self . outlineWidth ) return Image . fromarray ( edgeimage ) else : #PIL if self . room_outline is None : self . room_outline = self . load_image ( 'room.png' ) edges = ImageOps . invert ( self . room_outline . convert ( 'L' ) ) edges . paste ( self . base ) edges = edges . convert ( 'L' ) . filter ( ImageFilter . SMOOTH_MORE ) edges = ImageOps . invert ( edges . filter ( ImageFilter . FIND_EDGES ) ) return make_transparent ( edges , ( 0 , 0 , 0 , 255 ) )