Exemplo n.º 1
0
def run_test(id_test, test, id_estimator, estimator):
    global W, H

    logger.info('     id_test: %s' % id_test)
    logger.info('id_estimator: %s' % id_estimator)
    from led_detection.unit_tests import LEDDetectionUnitTest
    assert isinstance(test, LEDDetectionUnitTest)
    query = test.get_query()
    print( query['images']['rgb'][0].shape)
    H, W, _ = query['images']['rgb'][0].shape
    print('shape is %s, %s'%(W, H))
    result = estimator.detect_led(**query)

    # We are testing whether the expected detections are a subset of
    # the returned ones, we will accept duplicate detections of the
    # same LED
    match_count = [0]*len(test.expected)
    for r in result.detections:
        m = find_match(r, test.expected)
        if(m != -1):
            match_count[m]+=1

    missedLEDs = [test.expected[i] for i in range(0,  len(match_count)) if match_count[i]==0]
    if(missedLEDs):
        logger.error('missed LED detections (%s): \n %s' % (len(missedLEDs),missedLEDs))

    return not 0 in match_count

if __name__ == '__main__':
    wrap_main(main)
Exemplo n.º 2
0
    filename = os.path.join(root, dirname, filename)

    alltests = load_tests(filename)
    estimators = {'dummy': DummyLEDDetector()}
    
    which_tests = expand_string(which_tests0, list(alltests))
    which_estimators = expand_string(which_estimators0, list(estimators))

    logger.info('     tests: %r |-> %s' % (which_tests0, which_tests))
    logger.info('estimators: %r |-> %s' % (which_estimators0, which_estimators))

    # which tests to execute
    for id_test in which_tests:
        for id_estimator in which_estimators:
            test_results = run_test(id_test, alltests[id_test],
                                    id_estimator, estimators[id_estimator])

    
def run_test(id_test, test, id_estimator, estimator):
    logger.info('     id_test: %s' % id_test)
    logger.info('id_estimator: %s' % id_estimator)
    from led_detection.unit_tests import LEDDetectionUnitTest
    assert isinstance(test, LEDDetectionUnitTest)
    query = test.get_query()
    result = estimator.detect_led(**query)
    raise NotImplementedError('To finish: Compare result to expected result.')

if __name__ == '__main__':
    wrap_main(main)