def test_no_video_single_tag():
    """
    raises a value error when no video and no image passed.
    works on static images
    reqs: 03, 04 ,05
    """
    config = {'video source': 'none'}

    tracker = ArUcoTracker(config)
    assert not tracker.has_capture()
    tracker.start_tracking()
    with pytest.raises(ValueError):
        tracker.get_frame()
    capture = VideoCapture('data/output.avi')
    for frame in range(2):
        _, image = capture.read()
        (port_handles, timestamps, framenumbers, tracking,
         quality) = tracker.get_frame(image)
        assert len(port_handles) == len(timestamps)
        assert len(port_handles) == len(framenumbers)
        assert len(port_handles) == len(tracking)
        assert len(port_handles) == len(quality)
        assert len(port_handles) == 1
        assert port_handles[0] == 'DICT_4X4_50:0'
        assert framenumbers[0] == frame
        assert quality[0] == 1.0

    tracker.stop_tracking()
    tracker.close()
def test_with_tool_desc_and_calib():
    """
    connect track and close with multitags, defined
    rigid bodies, and camera calibration
    reqs: 03, 04 ,05, 07
    """
    config = {
        'video source':
        'data/multipattern.avi',
        'calibration':
        'data/calibration.txt',
        'rigid bodies': [{
            'name': 'reference',
            'filename': 'data/reference.txt',
            'aruco dictionary': 'DICT_ARUCO_ORIGINAL',
            'tag width': 49.50
        }, {
            'name': 'pointer',
            'filename': 'data/pointer.txt',
            'aruco dictionary': 'DICT_ARUCO_ORIGINAL'
        }]
    }

    tracker = ArUcoTracker(config)
    tracker.start_tracking()

    assert tracker.has_capture()
    (port_handles, timestamps, framenumbers, tracking,
     quality) = tracker.get_frame()
    assert len(port_handles) == len(timestamps)
    assert len(port_handles) == len(framenumbers)
    assert len(port_handles) == len(tracking)
    assert len(port_handles) == len(quality)
    assert len(port_handles) == 4  #there is an extraneous marker (1000)
    assert 'reference' in port_handles
    assert 'pointer' in port_handles
    assert 'DICT_4X4_50:0' in port_handles

    reference_index = port_handles.index('reference')
    pointer_index = port_handles.index('pointer')

    assert np.isclose(quality[reference_index], 0.91666666)
    assert np.isclose(quality[pointer_index], 0.83333333)

    ref_regression = np.array(
        [[-0.84701057, 0.51884094, -0.11565978, -8.22903442e+01],
         [-0.48733129, -0.67100208, 0.55880625, 4.85032501e+01],
         [0.21232361, 0.52967943, 0.82119327, 2.43992401e+02],
         [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 1.00000000e+00]],
        dtype=np.float32)

    assert np.allclose(tracking[reference_index], ref_regression)

    tracker.stop_tracking()
    tracker.close()