(self, overwrite=False, x_y=(0,0))
draw room outline
draw room outline
draw room outline
def draw_room_outline(self, overwrite=False, x_y=(0,0)):
        '''
        draw room outline
        '''
        if not self.roomOutline:
            return
        self.log.debug("MAP: checking room outline")
        if HAVE_CV2:
            if self.room_outline_contour is None: # or overwrite:
                self.room_outline_contour = self.load_image('room.npy')
                self.room_outline = None
            if self.room_outline is None:
                self.room_outline = self.make_new_outline_image(self.room_outline_contour)
            #is x_y inside(1), on(0) or outside(-1) contour?
            if cv2.pointPolygonTest(self.room_outline_contour, x_y, False) == -1:
                self.log.info("MAP: found new outline perimeter")
                img = Image.alpha_composite(self.base, self.room_outline)
                edgedata = np.array(img.convert('L'))
                # find external contour
                _, contours, _ = self.findContours(
                    edgedata,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
                if len(contours) == 0 or contours[0] is None: return
                if len(contours[0]) < 5: return
                self.room_outline_contour = contours[0]
                self.room_outline = self.make_new_outline_image(self.room_outline_contour)
        else:   #PIL
            if self.room_outline is None:# or overwrite:
                self.room_outline = self.load_image('room.png')
            self.room_outline = self.make_new_outline_image()

        if overwrite or self.debug:
            # save room outline
            self.save_image(self.room_outline, 'room.png')
            if HAVE_CV2:
                # save room outline contour as numpy array
                self.save_image(self.room_outline_contour, 'room.npy')
            if self.auto_rotate:
                # update outline centre
                self.get_image_parameters(
                    image=self.room_outline, contour=self.room_outline_contour,
                    final=overwrite)
                self.room_outline = self.transform_image(self.room_outline)
            self.log.info("MAP: Wrote new room outline files")
def draw_room_outline ( self , overwrite = False , x_y = ( 0 , 0 ) ) : if not self . roomOutline : return self . log . debug ( "MAP: checking room outline" ) if HAVE_CV2 : if self . room_outline_contour is None : # or overwrite: self . room_outline_contour = self . load_image ( 'room.npy' ) self . room_outline = None if self . room_outline is None : self . room_outline = self . make_new_outline_image ( self . room_outline_contour ) #is x_y inside(1), on(0) or outside(-1) contour? if cv2 . pointPolygonTest ( self . room_outline_contour , x_y , False ) == - 1 : self . log . info ( "MAP: found new outline perimeter" ) img = Image . alpha_composite ( self . base , self . room_outline ) edgedata = np . array ( img . convert ( 'L' ) ) # find external contour _ , contours , _ = self . findContours ( edgedata , cv2 . RETR_EXTERNAL , cv2 . CHAIN_APPROX_SIMPLE ) if len ( contours ) == 0 or contours [ 0 ] is None : return if len ( contours [ 0 ] ) < 5 : return self . room_outline_contour = contours [ 0 ] self . room_outline = self . make_new_outline_image ( self . room_outline_contour ) else : #PIL if self . room_outline is None : # or overwrite: self . room_outline = self . load_image ( 'room.png' ) self . room_outline = self . make_new_outline_image ( ) if overwrite or self . debug : # save room outline self . save_image ( self . room_outline , 'room.png' ) if HAVE_CV2 : # save room outline contour as numpy array self . save_image ( self . room_outline_contour , 'room.npy' ) if self . auto_rotate : # update outline centre self . get_image_parameters ( image = self . room_outline , contour = self . room_outline_contour , final = overwrite ) self . room_outline = self . transform_image ( self . room_outline ) self . log . info ( "MAP: Wrote new room outline files" )