Beispiel #1
0
    def search(self,
               faces,
               search_gallery,
               max_results=3,
               search_threshold=None,
               run_async=False,
               **kwargs):
        request = fsd.SearchRequest()

        request.probes.CopyFrom(faces)
        request.search_gallery = search_gallery
        request.max_results = max_results

        if search_threshold is not None:
            request.threshold = search_threshold

        if run_async == False:
            error = self.service_stub.search(request, None)
        elif run_async == True:
            self.waitOnResults()
            error = self.service_stub.search.future(request, None)
            self.running_async_jobs.append(error)
        else:
            raise ValueError("Unexpected run_async value: %s" % (run_async, ))

        return error
Beispiel #2
0
    def search(self,
               faces,
               gallery_name,
               max_results=3,
               threshold=None,
               run_async=False,
               **kwargs):
        request = fsd.SearchRequest()

        #print( "enrolling:",gallery_name,subject_id,subject_name)
        request.probes.CopyFrom(faces)
        request.gallery_name = gallery_name
        request.max_results = max_results

        if threshold is not None:
            request.threshold = threshold

        if run_async == False:
            error = self.rec_stub.search(request, None)
        elif run_async == True:
            self.waitOnResults()
            error = self.rec_stub.search.future(request, None)
            self.running_async_jobs.append(error)
        else:
            raise ValueError("Unexpected run_async value: %s" % (run_async, ))

        return error
Beispiel #3
0
    def detectExtractSearch(self,
                            im,
                            search_gallery='default',
                            max_results=3,
                            search_threshold=None,
                            best=False,
                            threshold=None,
                            min_size=None,
                            run_async=False,
                            source=None,
                            subject_id=None,
                            frame=None):
        request = fsd.DetectExtractSearchRequest()
        request.detect_request.CopyFrom(fsd.DetectRequest())
        request.extract_request.CopyFrom(fsd.ExtractRequest())
        request.search_request.CopyFrom(fsd.SearchRequest())

        try:
            request.detect_request.image.CopyFrom(pt.image_np2proto(im))
        except:
            request.detect_request.image.CopyFrom(
                pt.image_np2proto(im.asOpenCV2()[:, :, ::-1]))

        request.search_request.search_gallery = search_gallery
        request.search_request.max_results = max_results

        if search_threshold is None:
            search_threshold = self.match_threshold

        request.search_request.threshold = search_threshold

        # Setup the source and subject information.
        request.detect_request.source = 'UNKNOWN_SOURCE'
        request.detect_request.subject_id = 'UNKNOWN_SUBJECT'
        if source is not None:
            request.detect_request.source = source
        if frame is not None:
            request.detect_request.frame = frame
        if subject_id is not None:
            request.detect_request.subject_id = subject_id

        request.detect_request.detect_options.best = best

        if threshold == None:
            request.detect_request.detect_options.threshold = self.info.detection_threshold
        else:
            request.detect_request.detect_options.threshold = float(threshold)

        if run_async == False:
            face_records = self.service_stub.detectExtractSearch(request, None)
        elif run_async == True:
            self.waitOnResults()
            face_records = self.service_stub.detectExtractSearch.future(
                request, None)
            self.running_async_jobs.append(face_records)
        else:
            raise ValueError("Unexpected run_async value: %s" % (run_async, ))

        return face_records