def __init__(self, host, port, blob_dir, source="webcam", do_preview=False, do_train = None):
    
        self.logger = logging.getLogger("Borg.Brain.Vision.BlobDetector")
        super(BlobDetector, self).__init__(host, port)

        self.__preview = do_preview
        #TODO; not sure about this part:
        self.__vmr = util.vidmemreader.VidMemReader([source])
        self.__blob_dir = blob_dir
        self.__colorlist_list = colorlist.load_color_file_list(self.__blob_dir)

        self.__display_surface = None
        self.__do_train = not do_train == None
        self.__last_surface = None

        if self.__do_train:
            print "In training procedure..."
            self.__gui = gui.Gui(self.__colorlist_list)
    def __init__(self,
                 host,
                 port,
                 blob_dir,
                 source="webcam",
                 do_preview=False,
                 do_train=None):

        self.logger = logging.getLogger("Borg.Brain.Vision.BlobDetector")
        super(BlobDetector, self).__init__(host, port)

        self.__preview = do_preview
        #TODO; not sure about this part:
        self.__vmr = util.vidmemreader.VidMemReader([source])
        self.__blob_dir = blob_dir
        self.__colorlist_list = colorlist.load_color_file_list(self.__blob_dir)

        self.__display_surface = None
        self.__do_train = not do_train == None
        self.__last_surface = None

        if self.__do_train:
            print "In training procedure..."
            self.__gui = gui.Gui(self.__colorlist_list)
        self.handle_events()


def print_usage():
    print "Usage: blob.py [color_list_file]"
    print "Click on a pixel to add it to the color list."
    print "Press 'q' to quit."
    print "Press 'f' to freeze the current image."
    print "Press 'l' to load the (specified) color cube list."
    print "Press 's' to save the (specified) color cube list."
    print "Press 'd' to empty the (specified) color cube list."
    print "Press 'a' to increase the cube size."
    print "Press 'z' to decrease the cube size."
    print "Press 'u' to remove the last newly added color from the color cube list."
    print "Press 'b' to (try) to detect a color blob."
    print "Press 'p' to select the next *.colorblob file."
    print "Press 'o' to select the previous *.colorblob file."


if __name__ == "__main__":
    print_usage()

    if len(sys.argv) != 2:
        raise Exception(
            "You need to specify the location of the directory where all *.colorblob files are located!"
        )
        quit()

    gui = Gui(colorlist.load_color_file_list(sys.argv[1]))
    gui.run()
示例#4
0
        
        self.handle_events()
    

def print_usage():
    print "Usage: blob.py [color_list_file]"
    print "Click on a pixel to add it to the color list."
    print "Press 'q' to quit."
    print "Press 'f' to freeze the current image."
    print "Press 'l' to load the (specified) color cube list."
    print "Press 's' to save the (specified) color cube list."
    print "Press 'd' to empty the (specified) color cube list."
    print "Press 'a' to increase the cube size."
    print "Press 'z' to decrease the cube size."
    print "Press 'u' to remove the last newly added color from the color cube list."
    print "Press 'b' to (try) to detect a color blob."
    print "Press 'p' to select the next *.colorblob file."
    print "Press 'o' to select the previous *.colorblob file."


if __name__ == "__main__":
    print_usage()

    if len(sys.argv) != 2:
        raise Exception("You need to specify the location of the directory where all *.colorblob files are located!")
        quit()

    gui = Gui(colorlist.load_color_file_list(sys.argv[1]))
    gui.run()