Exemple #1
0
 def __init__(self):
     Filter.__init__(self)
     self.circley = Param("Circley", 0, min_v=0, max_v=200)
     self.circlex = Param("Circlex", 0, min_v=0, max_v=200)
     self.colorr = Param("colorr", 0, min_v=0, max_v=255)
     self.colorg = Param("colorg", 0, min_v=0, max_v=255)
     self.colorb = Param("colorb", 255, min_v=0, max_v=255)
Exemple #2
0
    def __init__(self):
        Filter.__init__(self)
        self.case = 'test'
        self.resize = False

        self.strength = Param("strength", 0.0, min_v=0.0, max_v=3.0)
        self.naturalness = Param("naturalness", 10, min_v=0, max_v=10)
        # self.sub_lum = Param("sub_lum", 100, min_v=0, max_v=255)
        # self.shift_x = Param("shift_x", 0, min_v=-800, max_v=800)
        # self.shift_y = Param("shift_y", 0, min_v=-600, max_v=600)

        self.show_image = Param("show_images", 1, min_v=1, max_v=10)
        self.limit_image = Param("limit_image", 4, min_v=1, max_v=10)
        self.debug_show = Param(
            "show_debug",
            "show_normal",
            lst_value=[
                "show_normal",
                "show_sat",
                "show_con"])
        self.show_hdr = Param("show_hdr", False)
        self.index = 0
        self.images = []
        self.imgs = []
        self.first_time = True
 def __init__(self):
     Filter.__init__(self)
     self.face_detect_name = os.path.join('data',
                                          'facedetect',
                                          'haarcascade_frontalface_alt.xml')
     self.face_cascade = cv2.CascadeClassifier()
     assert self.face_cascade.load(self.face_detect_name)
Exemple #4
0
    def __init__(self):
        Filter.__init__(self)

        self.convert_color = Param("Convert choice", 1, min_v=0, max_v=4)
        desc = "0 = original\n1 = BGR TO YUV\n2 = BGR TO HSV\n3 = BGR TO RGB\n\
        4 = BGR TO GRAY"
        self.convert_color.set_description(desc)
    def __init__(self):
        Filter.__init__(self)
        self.area_min = Param("Area Min", 300, min_v=1, max_v=100000)
        self.area_max = Param("Area Max", 35000, min_v=1, max_v=100000)

        self._kernel = cv2.getStructuringElement(
            cv2.MORPH_RECT, (3, 3), (0, 0))
Exemple #6
0
 def __init__(self):
     Filter.__init__(self)
     self.circley = Param("Circley", 0, min_v=0, max_v=200)
     self.circlex = Param("Circlex", 0, min_v=0, max_v=200)
     self.colorr = Param("colorr", 0, min_v=0, max_v=255)
     self.colorg = Param("colorg", 0, min_v=0, max_v=255)
     self.colorb = Param("colorb", 255, min_v=0, max_v=255)
 def __init__(self):
     Filter.__init__(self)
     self.kernel_erode_height = Param(
         "Kernel Erode Height",
         3,
         min_v=1,
         max_v=255)
     self.kernel_erode_width = Param(
         "Kernel Dilate Width",
         3,
         min_v=1,
         max_v=255)
     self.kernel_dilate_height = Param(
         "Kernel Erode Height",
         5,
         min_v=1,
         max_v=255)
     self.kernel_dilate_width = Param(
         "Kernel Dilate Width",
         5,
         min_v=1,
         max_v=255)
     self.sections = Param("Sections", 5, min_v=1, max_v=10)
     self.min_area = Param("Minimum Area", 1000, min_v=1, max_v=65535)
     self.configure()
Exemple #8
0
    def __init__(self):
        Filter.__init__(self)
        self.area_min = Param("Area Min", 300, min_v=1, max_v=100000)
        self.area_max = Param("Area Max", 35000, min_v=1, max_v=100000)

        self._kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (3, 3),
                                                 (0, 0))
Exemple #9
0
    def __init__(self):
        Filter.__init__(self)

        self.convert_color = Param("Convert choice", 1, min_v=0, max_v=4)
        desc = "0 = original\n1 = BGR TO YUV\n2 = BGR TO HSV\n3 = BGR TO RGB\n\
        4 = BGR TO GRAY"

        self.convert_color.set_description(desc)
Exemple #10
0
 def __init__(self):
     Filter.__init__(self)
     self.canny1 = Param("Canny1", 50, min_v=1, max_v=256)
     self.canny2 = Param("Canny2", 200, min_v=1, max_v=256)
     self.rho = Param("Rho", 1, min_v=1, max_v=256)
     self.theta = Param("Theta", 180, min_v=0, max_v=360)
     self.threshold = Param("Threshold", 100, min_v=1, max_v=256)
     self.line_size = Param("Line Size", 1000, min_v=1, max_v=2000)
 def __init__(self):
     Filter.__init__(self)
     self.kernel_width = Param("Kernel Width", 3, min_v=1, max_v=256)
     self.kernel_height = Param("Kernel Height", 3, min_v=1, max_v=256)
     self.anchor_x = Param("Anchor X", -1)
     self.anchor_y = Param("Anchor Y", -1)
     self.iterations = Param("Iteration,", 1, min_v=1)
     self.configure()
 def __init__(self):
     Filter.__init__(self)
     self.canny1 = Param("Canny1", 50, min_v=1, max_v=256)
     self.canny2 = Param("Canny2", 200, min_v=1, max_v=256)
     self.rho = Param("Rho", 1, min_v=1, max_v=256)
     self.theta = Param("Theta", 180, min_v=0, max_v=360)
     self.threshold = Param("Threshold", 100, min_v=1, max_v=256)
     self.line_size = Param("Line Size", 1000, min_v=1, max_v=2000)
Exemple #13
0
 def __init__(self):
     Filter.__init__(self)
     self.kernel_width = Param("Kernel Width", 3, min_v=1, max_v=256)
     self.kernel_height = Param("Kernel Height", 3, min_v=1, max_v=256)
     self.anchor_x = Param("Anchor X", -1)
     self.anchor_y = Param("Anchor Y", -1)
     self.iterations = Param("Iteration,", 1, min_v=1)
     self.configure()
Exemple #14
0
 def __init__(self):
     Filter.__init__(self)
     self.blue = Param("Blue", 20, min_v=1, max_v=256, thres_h=256)
     self.green = Param("Green", 20, min_v=1, max_v=256, thres_h=256)
     self.red = Param("Red", 20, min_v=1, max_v=256, thres_h=256)
     self._barray = None
     self._garray = None
     self._rarray = None
     self.configure()
 def __init__(self):
     Filter.__init__(self)
     path_frontal_face = os.path.join('/', 'usr', 'share', 'opencv',
                                      'haarcascades',
                                      'haarcascade_frontalface_alt.xml')
     self.face_detect_name = os.path.join('data', 'facedetect',
                                          path_frontal_face)
     self.face_cascade = cv2.CascadeClassifier()
     assert self.face_cascade.load(self.face_detect_name)
Exemple #16
0
 def __init__(self):
     Filter.__init__(self)
     path_frontal_face = os.path.join('/', 'usr', 'share', 'opencv',
                                      'haarcascades',
                                      'haarcascade_frontalface_alt.xml')
     self.face_detect_name = os.path.join('data',
                                          'facedetect',
                                          path_frontal_face)
     self.face_cascade = cv2.CascadeClassifier()
     assert self.face_cascade.load(self.face_detect_name)
Exemple #17
0
 def __init__(self):
     # this subclass of Filter
     Filter.__init__(self)
     self.params = {}
     cppfunc(
         self.params,
         self.py_init_param,
         self.notify_output_observers,
         self.dct_global_param,
         self.py_init_global_param)
 def __init__(self):
     Filter.__init__(self)
     self.nb_face = 1
     self.eye_detect_name = os.path.join('data', 'facedetect',
                                     'haarcascade_eye_tree_eyeglasses.xml')
     self.face_detect_name = os.path.join('data', 'facedetect',
                                          'haarcascade_frontalface_alt.xml')
     self.eye_cascade = cv2.CascadeClassifier()
     self.face_cascade = cv2.CascadeClassifier()
     self.eye_cascade.load(self.eye_detect_name)
     self.face_cascade.load(self.face_detect_name)
     self.notify_filter = Param("notify", False)
Exemple #19
0
    def __init__(self):
        Filter.__init__(self)
        self.topleftx = Param("Top Left X", 0, min_v=0, max_v=640)
        self.toplefty = Param("Top Left TY", 0, min_v=0, max_v=480)
        self.bottomleftx = Param("Bottom Left X", 100, min_v=0, max_v=640)
        self.bottomlefty = Param("Bottom Left Y", 480, min_v=0, max_v=480)
        self.toprightx = Param("Top Right X", 640, min_v=0, max_v=640)
        self.toprighty = Param("Top Right Y", 0, min_v=0, max_v=480)
        self.bottomrightx = Param("Bottom Right X", 540, min_v=0, max_v=640)
        self.bottomrighty = Param("Bottom Right Y", 480, min_v=0, max_v=480)

        self.mmat = None
        self.configure()
    def __init__(self):
        Filter.__init__(self)
        self.topleftx = Param("Top Left X", 0, min_v=0, max_v=640)
        self.toplefty = Param("Top Left TY", 0, min_v=0, max_v=480)
        self.bottomleftx = Param("Bottom Left X", 100, min_v=0, max_v=640)
        self.bottomlefty = Param("Bottom Left Y", 480, min_v=0, max_v=480)
        self.toprightx = Param("Top Right X", 640, min_v=0, max_v=640)
        self.toprighty = Param("Top Right Y", 0, min_v=0, max_v=480)
        self.bottomrightx = Param("Bottom Right X", 540, min_v=0, max_v=640)
        self.bottomrighty = Param("Bottom Right Y", 480, min_v=0, max_v=480)

        self.mmat = None
        self.configure()
Exemple #21
0
    def __init__(self):
        Filter.__init__(self)
        self.nb_face = 1
        # linux path
        path_frontal_face = os.path.join('/', 'usr', 'share', 'opencv',
                                         'haarcascades',
                                         'haarcascade_frontalface_alt.xml')
        self.face_detect_name = os.path.join(
            'data', 'facedetect', path_frontal_face)

        self.face_cascade = cv2.CascadeClassifier()
        self.face_cascade.load(self.face_detect_name)

        self.notify_filter = Param("notify", False)
Exemple #22
0
    def __init__(self):
        Filter.__init__(self)
        self.dct_color_choose = {"red": (0, 0, 255), "green": (0, 255, 0),
                                 "blue": (255, 0, 0)}
        self.color_rect = self.dct_color_choose["red"]
        self.i_text_size = 1.0
        # add params
        self.show_output = Param("enable_output", True)
        self.show_output.set_description("Enable to show rectangle.")

        self.color_rectangle = Param("color_rectangle", "red",
                                     lst_value=self.dct_color_choose.keys())
        self.color_rectangle.set_description(
            "Change the RGB color of the rectangle.")
        self.color_rectangle.add_group("rectangle")

        self.show_rectangle = Param("show_rectangle", True)
        self.show_rectangle.set_description(
            "Colorize a rectangle around the face.")
        self.show_rectangle.add_group("rectangle")

        self.border_rec_size = Param("border_rec_size", 3, min_v=1, max_v=9)
        self.border_rec_size.set_description(
            "Change the border size of the rectangle.")
        self.border_rec_size.add_group("rectangle")

        self.show_text = Param("enable_text", True)
        self.show_text.set_description("Show text upper the rectangle.")
        self.show_text.add_group("message")

        self.text_face = Param("text_face", "")
        self.text_face.set_description("The text to write on the rectangle.")
        self.text_face.add_group("message")

        self.text_size = Param("text_size", self.i_text_size, min_v=0.1,
                               max_v=4.9)
        self.text_size.set_description("Change the text size.")
        self.text_size.add_group("message")

        self.nb_face = 1
        # linux path
        path_frontal_face = os.path.join('/', 'usr', 'share', 'opencv',
                                         'haarcascades',
                                         'haarcascade_frontalface_alt.xml')
        self.face_detect_name = os.path.join('data', 'facedetect',
                                             path_frontal_face)
        self.face_cascade = cv2.CascadeClassifier()
        self.face_cascade.load(self.face_detect_name)
def _create_python_code(mod, modname, cppcode):
    # param variable size
    p = {}
    pip = py_init_param
    pip_global = py_init_global_param
    py_notify = Filter().notify_output_observers
    image = np.zeros((1, 1), dtype=np.uint8)
    image_original = np.zeros((1, 1), dtype=np.uint8)
    dct_global_param = {}

    # help
    func = ext_tools.ext_function('help_' + modname, help_code(), [])
    mod.add_function(func)

    # __init__
    func = ext_tools.ext_function(
        'init_' + modname, init_code("void init()" in cppcode),
        ['p', 'pip', 'py_notify', 'dct_global_param', 'pip_global'])
    func.customize.add_support_code(params_code())
    func.customize.add_support_code(notify_code())
    mod.add_function(func)

    # configure
    if "void configure()" in cppcode:
        has_configure = True
        func = ext_tools.ext_function('config_' + modname, config_code(), [])
        func.customize.add_support_code(params_code())
        func.customize.add_support_code(cppcode)
        func.customize.add_support_code(notify_code())
        mod.add_function(func)
    else:
        has_configure = False

    # destroy
    if "void destroy()" in cppcode:
        has_destroy = True
        func = ext_tools.ext_function('destroy_' + modname, destroy_code(), [])
        mod.add_function(func)
    else:
        has_destroy = False

    # set original image
    func = ext_tools.ext_function('set_original_image_' + modname,
                                  set_original_image_code(),
                                  ['image_original'])
    mod.add_function(func)

    # set global params
    func = ext_tools.ext_function('set_global_params_' + modname,
                                  set_global_params_code(),
                                  ['dct_global_param'])
    mod.add_function(func)

    # execute
    # Get the size of parameter
    func = ext_tools.ext_function('exec_' + modname, execute_code(), ['image'])
    func.customize.add_support_code(params_code())
    func.customize.add_support_code(cppcode)
    func.customize.add_support_code(notify_code())
    mod.add_function(func)
 def deserialize(self, name, value):
     status = True
     self.filterchain_name = name
     lst_filter = value.get("lst_filter", [])
     self.default_media_name = value.get("default_media_name", None)
     self.filters = []
     index = 0
     # add default filter
     self.add_filter(Filter(keys.get_empty_filter_name()))
     for filter_to_ser in lst_filter:
         filter_name = filter_to_ser.get("filter_name", None)
         o_filter = self.resource.create_filter(filter_name, index)
         index += 1
         if not o_filter:
             log.print_function(
                 logger.warning,
                 "Cannot create filter %s, maybe it not exists." %
                 filter_name)
             continue
         status &= o_filter.deserialize(filter_to_ser)
         self.add_filter(o_filter)
     if status:
         log.print_function(logger.info,
                            "Deserialize filterchain %s success." % name)
     else:
         log.print_function(logger.warning,
                            "Deserialize filterchain %s failed." % name)
     return status
    def __init__(self,
                 filterchain_name,
                 serialize=None,
                 default_media_name=None):
        # to limit the infini import, we import in the init
        from resource import Resource

        self.resource = Resource()

        self.filters = []
        # {"filter_name":[observator,]}
        self.image_observers = {}
        self.filter_output_observers = []
        self.filterchain_name = filterchain_name
        self.original_image_observer = []
        self.dct_global_param = {}
        self.dct_media_param = {}
        # If starting filterchain with empty media_name, we take the default
        # media
        self.default_media_name = default_media_name

        if serialize:
            self.deserialize(filterchain_name, serialize)
        else:
            # add default filter
            self.add_filter(Filter(keys.get_empty_filter_name()))

        self.do_configure()
    def __init__(self):
        Filter.__init__(self)
        self.nb_face = 1
        eye_xml = 'haarcascade_eye_tree_eyeglasses.xml'
        self.eye_detect_name = os.path.join('/', 'usr', 'share', 'opencv',
                                            'haarcascades', eye_xml)
        self.face_detect_nam = os.path.join('/', 'usr', 'share', 'opencv',
                                            'haarcascades',
                                            'haarcascade_frontalface_alt.xml')
        self.eye_cascade = cv2.CascadeClassifier()
        self.face_cascade = cv2.CascadeClassifier()
        self.eye_cascade.load(self.eye_detect_name)
        self.face_cascade.load(self.face_detect_name)
        self.show_rectangle = Param("show_rectangle", True)

        # To share parameter between filter, create it with :
        self.add_shared_param(Param("width", 3, min_v=1, max_v=10))
    def __init__(self):
        Filter.__init__(self)
        self.nb_face = 1
        self.eye_detect_name = os.path.join('data', 'facedetect',
                                        'haarcascade_eye_tree_eyeglasses.xml')
        self.face_detect_name = os.path.join('data', 'facedetect',
                                             'haarcascade_frontalface_alt.xml')
        self.eye_cascade = cv2.CascadeClassifier()
        self.face_cascade = cv2.CascadeClassifier()
        self.eye_cascade.load(self.eye_detect_name)
        self.face_cascade.load(self.face_detect_name)
        self.show_rectangle = Param("show_rectangle", True)

        # To share parameter between filter, create it with :
        self.add_global_params(Param("width", 3, min_v=1, max_v=10))
        # On the execution, use it like this :
        param = self.get_global_params("width")
Exemple #28
0
    def __init__(self):
        Filter.__init__(self)
        self.nb_face = 1
        eye_xml = 'haarcascade_eye_tree_eyeglasses.xml'
        self.eye_detect_name = os.path.join('/', 'usr', 'share', 'opencv',
                                            'haarcascades', eye_xml)
        self.face_detect_nam = os.path.join('/', 'usr', 'share', 'opencv',
                                            'haarcascades',
                                            'haarcascade_frontalface_alt.xml')
        self.eye_cascade = cv2.CascadeClassifier()
        self.face_cascade = cv2.CascadeClassifier()
        self.eye_cascade.load(self.eye_detect_name)
        self.face_cascade.load(self.face_detect_name)
        self.show_rectangle = Param("show_rectangle", True)

        # To share parameter between filter, create it with :
        self.add_shared_param(Param("width", 3, min_v=1, max_v=10))
Exemple #29
0
 def __init__(self):
     Filter.__init__(self)
     self.kernel_erode_height = Param("Kernel Erode Height",
                                      3,
                                      min_v=1,
                                      max_v=255)
     self.kernel_erode_width = Param("Kernel Dilate Width",
                                     3,
                                     min_v=1,
                                     max_v=255)
     self.kernel_dilate_height = Param("Kernel Erode Height",
                                       5,
                                       min_v=1,
                                       max_v=255)
     self.kernel_dilate_width = Param("Kernel Dilate Width",
                                      5,
                                      min_v=1,
                                      max_v=255)
     self.sections = Param("Sections", 5, min_v=1, max_v=10)
     self.min_area = Param("Minimum Area", 1000, min_v=1, max_v=65535)
     self.configure()
Exemple #30
0
 def __init__(self):
     Filter.__init__(self)
     self.threshold1 = Param("Threshold1", 10, min_v=0, max_v=255)
     self.threshold2 = Param("Threshold2", 100, min_v=0, max_v=255)
 def __init__(self):
     Filter.__init__(self)
     self.kernel_height = Param("Kernel Height", 3, min_v=1, max_v=256)
     self.kernel_width = Param("Kernel Width", 3, min_v=1, max_v=256)
     self.sigma_x = Param("Sigma X", 3, min_v=1, max_v=256)
     self.sigma_y = Param("Sigma Y", 3, min_v=1, max_v=256)
Exemple #32
0
 def __init__(self):
     Filter.__init__(self)
     self.diameter = Param("Diameter", 10, min_v=0, max_v=255)
     self.sigma_color = Param("Sigma Color", 0, min_v=0, max_v=255)
     self.sigma_space = Param("Sigma Space", 0, min_v=0, max_v=255)
 def __init__(self):
     Filter.__init__(self)
     self.kernel_width = Param("width", 3, min_v=1, max_v=10)
     self.kernel_height = Param("height", 3, min_v=1, max_v=10)
Exemple #34
0
 def __init__(self):
     Filter.__init__(self)
     self.angle = Param('angle', 0, max_v=3, min_v=0)
 def __init__(self):
     Filter.__init__(self)
     self.threshold = Param("Threshold", 12, min_v=0, max_v=255)
 def __init__(self):
     Filter.__init__(self)
     self.red = Param("red", 100, min_v=0, max_v=255)
     self.green = Param("green", 100, min_v=0, max_v=255)
     self.blue = Param("blue", 100, min_v=0, max_v=255)
 def __init__(self):
     Filter.__init__(self)
     self.red = Param("red", 100, min_v=0, max_v=255)
     self.green = Param("green", 100, min_v=0, max_v=255)
     self.blue = Param("blue", 100, min_v=0, max_v=255)
 def __init__(self):
     Filter.__init__(self)
     self.kernel_height = Param("Kernel Height", 10, min_v=1, max_v=256)
     self.kernel_width = Param("Kernel Width", 10, min_v=1, max_v=256)
     self.area_min = Param("Area Min", 3200, min_v=1)
     self.configure()
 def __init__(self):
     Filter.__init__(self)
     self.kernel_height = Param("Kernel Height", 10, min_v=1, max_v=256)
     self.kernel_width = Param("Kernel Width", 10, min_v=1, max_v=256)
     self.area_min = Param("Area Min", 3200, min_v=1)
     self.configure()
Exemple #40
0
 def __init__(self):
     Filter.__init__(self)
     self._images = []
     self.nb_images = Param("Nb Images", 10, min_v=1, max_v=99)
 def __init__(self):
     Filter.__init__(self)
     self.diameter = Param("Diameter", 10, min_v=0, max_v=255)
     self.sigma_color = Param("Sigma Color", 0, min_v=0, max_v=255)
     self.sigma_space = Param("Sigma Space", 0, min_v=0, max_v=255)
Exemple #42
0
 def __init__(self):
     Filter.__init__(self)
     self.kernel_width = Param("width", 3, min_v=1, max_v=10)
     self.kernel_height = Param("height", 3, min_v=1, max_v=10)
     self.kernel_height.set_description("kernel's height")
     self.kernel_width.set_description("kernel's width")
 def __init__(self):
     Filter.__init__(self)
     self._images = []
     self.nb_images = Param("Nb Images", 10, min_v=1, max_v=99)
 def __init__(self):
     # this subclass of Filter
     Filter.__init__(self)
     self.params = {}
     cppfunc(self.params, self.py_init_param, self.notify_output_observers,
             self.dct_global_param, self.py_init_global_param)
Exemple #45
0
 def __init__(self):
     Filter.__init__(self)
     self.threshold = Param("Threshold", 12, min_v=0, max_v=255)
 def __init__(self):
     Filter.__init__(self)
     self.param_str = Param("param_str", "")
Exemple #47
0
 def __init__(self):
     Filter.__init__(self)
     self.x1 = Param('x1', 0, max_v=65535, min_v=0)
     self.y1 = Param('y1', 0, max_v=65535, min_v=0)
     self.x2 = Param('x2', 100, max_v=65535, min_v=0)
     self.y2 = Param('y2', 100, max_v=65535, min_v=0)
Exemple #48
0
 def __init__(self):
     Filter.__init__(self)
     self.kernel_width = Param("width", 3, min_v=1, max_v=10)
     self.kernel_height = Param("height", 3, min_v=1, max_v=10)
     self.kernel_height.set_description("kernel's height")
     self.kernel_width.set_description("kernel's width")
Exemple #49
0
 def __init__(self):
     Filter.__init__(self)
     self.code = ""
     self.is_python = True
     self._ccode = None
     self._has_error = False
Exemple #50
0
 def __init__(self):
     Filter.__init__(self)
 def __init__(self):
     Filter.__init__(self)
     self.threshold = Param("Threshold", 100, min_v=0, max_v=255)
     self.technique = Param("Technique", 0, min_v=0, max_v=2)
Exemple #52
0
 def __init__(self):
     Filter.__init__(self)
     self.threshold1 = Param("Threshold1", 10, min_v=0, max_v=255)
     self.threshold2 = Param("Threshold2", 100, min_v=0, max_v=255)
Exemple #53
0
 def __init__(self):
     Filter.__init__(self)
     self.angle = Param('angle', 0, max_v=3, min_v=0)
Exemple #54
0
 def __init__(self):
     Filter.__init__(self)
 def __init__(self):
     Filter.__init__(self)
     self.threshold = Param("Threshold", 100, min_v=0, max_v=255)
     self.technique = Param("Technique", 0, min_v=0, max_v=2)