Beispiel #1
0
    def __init__(self,
                 transf_file_path,
                 sname,
                 snum,
                 objname,
                 objnum,
                 ap_defaults=None,
                 icp_defaults=None,
                 umbral_score=1e-3,
                 **kwargs):
        (super(SDTWithPostAlignment, self).__init__(transf_file_path, sname,
                                                    snum, objname, objnum))

        # alignment prerejective e ICP
        self.umbral_score = umbral_score
        if ap_defaults is None:
            # alignment prerejective parameters
            ap_defaults = APDefaults()
            ap_defaults.leaf = 0.005
            ap_defaults.max_ransac_iters = 100
            ap_defaults.points_to_sample = 3
            ap_defaults.nearest_features_used = 4
            ap_defaults.simil_threshold = 0.1
            ap_defaults.inlier_threshold = 3
            ap_defaults.inlier_fraction = 0.8
            # ap_defaults.show_values = True

        self._ap_defaults = ap_defaults

        if icp_defaults is None:
            # icp parameters
            icp_defaults = ICPDefaults()
            icp_defaults.euc_fit = 1e-5
            icp_defaults.max_corr_dist = 3
            icp_defaults.max_iter = 50
            icp_defaults.transf_epsilon = 1e-5
            # icp_defaults.show_values = True

        self._icp_defaults = icp_defaults

        # Seteo el tamaño de las esferas usadas para filtrar de la escena
        # los puntos del objeto encontrado
        first_leaf_size = kwargs.get('first_leaf_size', 0.005)
        self.adapt_leaf = kwargs.get(
            'adapt_leaf', AdaptLeafRatio(first_leaf=first_leaf_size))

        # Seteo el porcentaje de puntos que permito conservar del modelo del
        # objeto antes de considerar que lo que se encontró no es el objeto
        self.perc_obj_model_points = kwargs.get('perc_obj_model_points', 0.5)

        # Seteo el tamaño del frame de busqueda. Este valor se va a multiplicar
        # por la altura y el ancho del objeto. Ej: si se multiplica por 2, el
        # frame de busqueda tiene un area 4 (2*2) veces mayor que la del objeto
        self.obj_mult = kwargs.get('obj_mult', 2)
Beispiel #2
0
    def __init__(self, icp_defaults=None, umbral_score=1e-4):
        super(ICPFinder, self).__init__()
        if icp_defaults is None:
            icp_defaults = ICPDefaults()
            icp_defaults.euc_fit = 1e-15
            icp_defaults.max_corr_dist = 0.3
            icp_defaults.max_iter = 50
            icp_defaults.transf_epsilon = 1e-15

        self._icp_defaults = icp_defaults
        self.umbral_score = umbral_score
Beispiel #3
0
def prueba_solo_deteccion_automatica(img_provider):

    # Set detection parameters values
    det_template_threshold = 0.2

    ap_defaults = APDefaults()
    ap_defaults.leaf = 0.005
    ap_defaults.max_ransac_iters = 120
    ap_defaults.points_to_sample = 3
    ap_defaults.nearest_features_used = 4
    ap_defaults.simil_threshold = 0.6
    ap_defaults.inlier_threshold = 4
    ap_defaults.inlier_fraction = 0.3

    icp_detection_defaults = ICPDefaults()
    icp_detection_defaults.euc_fit = 1e-10
    icp_detection_defaults.max_corr_dist = 3
    icp_detection_defaults.max_iter = 50
    icp_detection_defaults.transf_epsilon = 1e-6

    det_umbral_score = 1e-3
    det_obj_scene_leaf = 0.005
    det_perc_obj_model_points = 0.5
    det_depth_area_extra = 0.333

    detector = RGBDDetector(
        template_threshold=det_template_threshold,
        ap_defaults=ap_defaults,
        icp_defaults=icp_detection_defaults,
        umbral_score=det_umbral_score,
        perc_obj_model_points=det_perc_obj_model_points,
        first_leaf_size=det_obj_scene_leaf,
        depth_area_extra=det_depth_area_extra,
    )

    finder = Finder()

    follower = DetectionWithCombinedFollowers(
        img_provider,
        detector,
        finder,
        finder
    )

    for i in range(3):
        FollowingSchemeExploringParameterRGBD(
            img_provider,
            follower,
            'pruebas_guardadas',
            'probando_deteccion_automatica_RGBD',
            'UNICO',
        ).run()

        img_provider.restart()
Beispiel #4
0
    def __init__(self,
                 matfile_path,
                 obj_rgbd_name,
                 obj_rgbd_num,
                 ap_defaults=APDefaults(),
                 icp_defaults=ICPDefaults(),
                 leaf_size=0.002,
                 icp_threshold=1e-3,
                 perc_obj_model_pts=0.5):
        (super(StaticDetectorWithModelAlignment,
               self).__init__(matfile_path, obj_rgbd_name, obj_rgbd_num))
        self._ap_defaults = ap_defaults
        self._icp_defaults = icp_defaults

        # El tamaño del radio de la esfera para buscar puntos en la escena
        self.leaf_size = leaf_size

        # Umbral de aceptacion para ICP
        self.icp_threshold = icp_threshold

        # Porcentaje minimo de puntos del modelo que deben detectarse
        self.perc_obj_model_pts = perc_obj_model_pts
Beispiel #5
0
def sistema_de_seguimiento_automatico_completo_rgb_rgbd(img_provider):

    # Set detection parameters values
    det_template_threshold = 0.2

    ap_defaults = APDefaults()
    ap_defaults.leaf = 0.005
    ap_defaults.max_ransac_iters = 120
    ap_defaults.points_to_sample = 3
    ap_defaults.nearest_features_used = 4
    ap_defaults.simil_threshold = 0.6
    ap_defaults.inlier_threshold = 4
    ap_defaults.inlier_fraction = 0.3

    icp_detection_defaults = ICPDefaults()
    icp_detection_defaults.euc_fit = 1e-10
    icp_detection_defaults.max_corr_dist = 3
    icp_detection_defaults.max_iter = 50
    icp_detection_defaults.transf_epsilon = 1e-6

    det_umbral_score = 1e-3
    det_obj_scene_leaf = 0.005
    det_perc_obj_model_points = 0.5
    det_depth_area_extra = 0.333

    # Set depth following parameters values
    icp_finder_defaults = ICPDefaults()
    icp_finder_defaults.euc_fit = 1e-10
    icp_finder_defaults.max_corr_dist = 0.1
    icp_finder_defaults.max_iter = 50
    icp_finder_defaults.transf_epsilon = 1e-6

    find_umbral_score = 1e-4
    find_adapt_area = FixedSearchArea(3)
    find_adapt_leaf = AdaptLeafRatio()
    find_obj_scene_leaf = 0.002
    find_perc_obj_model_points = 0.6

    # Set RGB following parameters values
    find_template_comp_method = cv2.cv.CV_COMP_BHATTACHARYYA
    template_perc = 0.6
    template_worst = 1
    find_template_reverse = False

    find_frame_comp_method = cv2.cv.CV_COMP_BHATTACHARYYA
    frame_perc = 0.3
    frame_worst = 1
    find_frame_reverse = False

    metodo_de_busqueda = BusquedaCambiandoSizePeroMismoCentro()

    # Repetir 3 veces para evitar detecciones fallidas por RANSAC
    for i in range(3):
        detector = RGBDDetector(
            template_threshold=det_template_threshold,
            ap_defaults=ap_defaults,
            icp_defaults=icp_detection_defaults,
            umbral_score=det_umbral_score,
            perc_obj_model_points=det_perc_obj_model_points,
            first_leaf_size=det_obj_scene_leaf,
            depth_area_extra=det_depth_area_extra,
        )

        template_comparator = HistogramComparator(
            method=find_template_comp_method,
            perc=template_perc,
            worst_case=template_worst,
            reverse=find_template_reverse,
        )
        frame_comparator = HistogramComparator(
            method=find_frame_comp_method,
            perc=frame_perc,
            worst_case=frame_worst,
            reverse=find_frame_reverse,
        )

        rgb_finder = TemplateAndFrameHistogramFinder(
            template_comparator,
            frame_comparator,
            metodo_de_busqueda,
        )
        depth_finder = ICPFinderWithModelToImproveRGB(
            icp_defaults=icp_finder_defaults,
            umbral_score=find_umbral_score,
            adapt_area=find_adapt_area,
            adapt_leaf=find_adapt_leaf,
            first_leaf_size=find_obj_scene_leaf,
            perc_obj_model_points=find_perc_obj_model_points,
        )

        follower = DetectionWithCombinedFollowers(
            image_provider=img_provider,
            detector=detector,
            main_finder=depth_finder,
            secondary_finder=rgb_finder,
        )

        # mostrar_seguimiento = MuestraSeguimientoEnVivo('Seguimiento')

        # FollowingScheme(img_provider, follower, mostrar_seguimiento).run()
        FollowingSchemeExploringParameterRGBD(
            img_provider,
            follower,
            'pruebas_guardadas',
            'definitivo_automatico_RGB_RGBD',
            'UNICO',
        ).run()

        img_provider.restart()
Beispiel #6
0
def correr_con_depth_como_principal(img_provider, scenename, scenenumber,
                                    objname, objnum):
    # Set alignment detection parameters values
    ap_defaults = APDefaults()
    ap_defaults.leaf = 0.005
    ap_defaults.max_ransac_iters = 120
    ap_defaults.points_to_sample = 3
    ap_defaults.nearest_features_used = 4
    ap_defaults.simil_threshold = 0.6
    ap_defaults.inlier_threshold = 4
    ap_defaults.inlier_fraction = 0.3

    icp_detection_defaults = ICPDefaults()
    icp_detection_defaults.euc_fit = 1e-10
    icp_detection_defaults.max_corr_dist = 3
    icp_detection_defaults.max_iter = 50
    icp_detection_defaults.transf_epsilon = 1e-6

    det_umbral_score = 1e-3
    det_obj_scene_leaf = 0.005
    det_perc_obj_model_points = 0.5

    # Set depth following parameters values
    icp_finder_defaults = ICPDefaults()
    icp_finder_defaults.euc_fit = 1e-10
    icp_finder_defaults.max_corr_dist = 0.1
    icp_finder_defaults.max_iter = 50
    icp_finder_defaults.transf_epsilon = 1e-6

    find_umbral_score = 1e-4
    find_adapt_area = FixedSearchArea(3)
    find_adapt_leaf = AdaptLeafRatio()
    find_obj_scene_leaf = 0.002
    find_perc_obj_model_points = 0.6

    # Set RGB following parameters values
    find_template_comp_method = cv2.cv.CV_COMP_BHATTACHARYYA
    template_perc = 0.6
    template_worst = 1
    find_template_reverse = False

    find_frame_comp_method = cv2.cv.CV_COMP_BHATTACHARYYA
    frame_perc = 0.3
    frame_worst = 1
    find_frame_reverse = False

    metodo_de_busqueda = BusquedaCambiandoSizePeroMismoCentro()

    # Repetir 3 veces para evitar detecciones fallidas por RANSAC
    for i in range(3):
        detector = StaticDetectorForRGBD(
            matfile_path=('videos/rgbd/scenes/{sname}/{sname}_{snum}.mat'
                          .format(sname=scenename, snum=scenenumber)),
            obj_rgbd_name=objname,
            obj_rgbd_num=objnum,
            ap_defaults=ap_defaults,
            icp_defaults=icp_detection_defaults,
            leaf_size=det_obj_scene_leaf,
            icp_threshold=det_umbral_score,
            perc_obj_model_pts=det_perc_obj_model_points
        )

        template_comparator = HistogramComparator(
            method=find_template_comp_method,
            perc=template_perc,
            worst_case=template_worst,
            reverse=find_template_reverse,
        )
        frame_comparator = HistogramComparator(
            method=find_frame_comp_method,
            perc=frame_perc,
            worst_case=frame_worst,
            reverse=find_frame_reverse,
        )

        rgb_finder = ImproveObjectFoundWithHistogramFinder(
            template_comparator,
            frame_comparator,
            metodo_de_busqueda,
        )

        depth_finder = ICPFinderWithModel(
            icp_defaults=icp_finder_defaults,
            umbral_score=find_umbral_score,
            adapt_area=find_adapt_area,
            adapt_leaf=find_adapt_leaf,
            first_leaf_size=find_obj_scene_leaf,
            perc_obj_model_points=find_perc_obj_model_points,
        )

        follower = DetectionWithCombinedFollowers(
            image_provider=img_provider,
            detector=detector,
            main_finder=depth_finder,
            secondary_finder=rgb_finder,
        )

        # mostrar_seguimiento = MuestraSeguimientoEnVivo('Seguimiento')

        # FollowingScheme(img_provider, follower, mostrar_seguimiento).run()
        FollowingSchemeExploringParameterRGBD(
            img_provider,
            follower,
            'pruebas_guardadas',
            'definitivo_RGBD_preferD',
            'DEFINITIVO',
        ).run()

        img_provider.restart()