scripts/scene_checker.py
def onUpdate(self):
        '''
        Shows image and object bounding box overlays.
        '''

        # Filenames
        img_file = self.img_dir + '/' + str(int(self.cur / 100)) + \
            '00/' + str(self.cur) + self.img_ext
        data_file = self.data_dir + '/' + str(self.cur) + EXT_DATA
        # print(img_file, data_file)

        # Clean canvas
        self.canvas.delete("all")

        # Update scene image
        try:
            image = Image.open(img_file) 
            photo = ImageTk.PhotoImage(image)
        except:
            print('Could not open ' + img_file + '.Exiting...')
            self.parent.destroy()
            sys.exit(2)

        self.canvas.image = photo
        self.canvas.create_image(0, 0, image=photo, anchor=tk.NW)

        # Open XML dataset file
        try:
            tree = ET.parse(data_file)
        except:
            print('Could not open ' + data_file + '. Exiting...')
            self.parent.destroy()
            sys.exit(2)

        annotation = tree.getroot()

        if SHOW_HELP:
            # Commands
            self.canvas.create_rectangle(40, 40, 300, 230,
                fill="gray", stipple="gray50", width=0)
            # Draw label with cur / total scene indicator
            label = 'Scene ' + str(self.cur) + '/' + str(self.first + self.scenes - 1)
            self.canvas.create_text(45, 45, text=label, fill="white",
                font=('arial', '18'), anchor=tk.NW)
            # Draw help label
            label = 'Commands\n'            + \
                    'Left\tPrevious\n'      + \
                    'Right\tNext\n'         + \
                    'Spacebar\tExport\n'    + \
                    'Return\tExit'
            self.canvas.create_text(45, 80, text=label, fill="white",
                font=('arial', '18'), anchor=tk.NW)

        # Draw bounding boxes
        for obj in annotation.findall('object'):
            name = obj.find('name').text
            color = BOX_COLOR
            if   (name == "sphere"):   color = SPHERE_COLOR
            elif (name == "cylinder"): color = CYLINDER_COLOR
            
            for bnd_box in obj.findall('bndbox'):
                x_min = int(bnd_box.find('xmin').text)
                y_min = int(bnd_box.find('ymin').text)
                x_max = int(bnd_box.find('xmax').text)
                y_max = int(bnd_box.find('ymax').text)
                rect = self.canvas.create_rectangle(x_min, y_min, x_max, y_max,
                    outline=color, width=2)
                text = self.canvas.create_text(x_min, y_min-25, text=name,
                    fill=TEXT_COLOR, font=('arial', '16'), anchor=tk.NW)
                background = self.canvas.create_rectangle(self.canvas.bbox(text),
                    outline=color, fill=color)
                self.canvas.tag_lower(background, text)

        Shows image and object bounding box overlays.
        
Shows image and object bounding box overlays.
Shows image and object bounding box overlays .
def onUpdate(self):
        img_file = self.img_dir + '/' + str(int(self.cur / 100)) + \
            '00/' + str(self.cur) + self.img_ext
        data_file = self.data_dir + '/' + str(self.cur) + EXT_DATA
        self.canvas.delete("all")
        try:
            image = Image.open(img_file) 
            photo = ImageTk.PhotoImage(image)
        except:
            print('Could not open ' + img_file + '.Exiting...')
            self.parent.destroy()
            sys.exit(2)
        self.canvas.image = photo
        self.canvas.create_image(0, 0, image=photo, anchor=tk.NW)
        try:
            tree = ET.parse(data_file)
        except:
            print('Could not open ' + data_file + '. Exiting...')
            self.parent.destroy()
            sys.exit(2)
        annotation = tree.getroot()
        if SHOW_HELP:
            self.canvas.create_rectangle(40, 40, 300, 230,
                fill="gray", stipple="gray50", width=0)
            label = 'Scene ' + str(self.cur) + '/' + str(self.first + self.scenes - 1)
            self.canvas.create_text(45, 45, text=label, fill="white",
                font=('arial', '18'), anchor=tk.NW)
            label = 'Commands\n'            + \
                    'Left\tPrevious\n'      + \
                    'Right\tNext\n'         + \
                    'Spacebar\tExport\n'    + \
                    'Return\tExit'
            self.canvas.create_text(45, 80, text=label, fill="white",
                font=('arial', '18'), anchor=tk.NW)
        for obj in annotation.findall('object'):
            name = obj.find('name').text
            color = BOX_COLOR
            if   (name == "sphere"):   color = SPHERE_COLOR
            elif (name == "cylinder"): color = CYLINDER_COLOR
            for bnd_box in obj.findall('bndbox'):
                x_min = int(bnd_box.find('xmin').text)
                y_min = int(bnd_box.find('ymin').text)
                x_max = int(bnd_box.find('xmax').text)
                y_max = int(bnd_box.find('ymax').text)
                rect = self.canvas.create_rectangle(x_min, y_min, x_max, y_max,
                    outline=color, width=2)
                text = self.canvas.create_text(x_min, y_min-25, text=name,
                    fill=TEXT_COLOR, font=('arial', '16'), anchor=tk.NW)
                background = self.canvas.create_rectangle(self.canvas.bbox(text),
                    outline=color, fill=color)
                self.canvas.tag_lower(background, text)
def onUpdate ( self ) : img_file = self . img_dir + '/' + str ( int ( self . cur / 100 ) ) + '00/' + str ( self . cur ) + self . img_ext data_file = self . data_dir + '/' + str ( self . cur ) + EXT_DATA self . canvas . delete ( "all" ) try : image = Image . open ( img_file ) photo = ImageTk . PhotoImage ( image ) except : print ( 'Could not open ' + img_file + '.Exiting...' ) self . parent . destroy ( ) sys . exit ( 2 ) self . canvas . image = photo self . canvas . create_image ( 0 , 0 , image = photo , anchor = tk . NW ) try : tree = ET . parse ( data_file ) except : print ( 'Could not open ' + data_file + '. Exiting...' ) self . parent . destroy ( ) sys . exit ( 2 ) annotation = tree . getroot ( ) if SHOW_HELP : self . canvas . create_rectangle ( 40 , 40 , 300 , 230 , fill = "gray" , stipple = "gray50" , width = 0 ) label = 'Scene ' + str ( self . cur ) + '/' + str ( self . first + self . scenes - 1 ) self . canvas . create_text ( 45 , 45 , text = label , fill = "white" , font = ( 'arial' , '18' ) , anchor = tk . NW ) label = 'Commands\n' + 'Left\tPrevious\n' + 'Right\tNext\n' + 'Spacebar\tExport\n' + 'Return\tExit' self . canvas . create_text ( 45 , 80 , text = label , fill = "white" , font = ( 'arial' , '18' ) , anchor = tk . NW ) for obj in annotation . findall ( 'object' ) : name = obj . find ( 'name' ) . text color = BOX_COLOR if ( name == "sphere" ) : color = SPHERE_COLOR elif ( name == "cylinder" ) : color = CYLINDER_COLOR for bnd_box in obj . findall ( 'bndbox' ) : x_min = int ( bnd_box . find ( 'xmin' ) . text ) y_min = int ( bnd_box . find ( 'ymin' ) . text ) x_max = int ( bnd_box . find ( 'xmax' ) . text ) y_max = int ( bnd_box . find ( 'ymax' ) . text ) rect = self . canvas . create_rectangle ( x_min , y_min , x_max , y_max , outline = color , width = 2 ) text = self . canvas . create_text ( x_min , y_min - 25 , text = name , fill = TEXT_COLOR , font = ( 'arial' , '16' ) , anchor = tk . NW ) background = self . canvas . create_rectangle ( self . canvas . bbox ( text ) , outline = color , fill = color ) self . canvas . tag_lower ( background , text )
Shows image and object bounding box overlays.
Shows image and object bounding box overlays .
'''
        Shows image and object bounding box overlays.
        ''' # Filenames # print(img_file, data_file) # Clean canvas # Update scene image # Open XML dataset file # Commands # Draw label with cur / total scene indicator # Draw help label # Draw bounding boxes
self