示例#1
0
 def test():
     inst1 = np.random.rand(10, 10) * 100000.3 - 1000
     inst2 = np.random.randint(-100000, 100000, (10, 10))
     for inst in [inst1, inst2]:
         rgb = encode_inst_id.id_to_rgb(inst)
         recover = encode_inst_id.rgb_to_id(rgb)
         mg()
         assert (inst == recover).all()
示例#2
0
def test_heatmap_to_pseudo_color(depth):
    def _f(v):
        return tuple(interpolate_or_clip(turbo_colormap_data, v))

    vf = np.vectorize(_f)

    with timeit("vf"):
        color1 = np.concatenate([i[..., None] for i in vf(depth)], -1)

    with timeit("heatmap_to_pseudo_color"):
        color2 = heatmap_to_pseudo_color(depth)

    mg()
    assert (np.abs(color1 - color2) < 1 / 256).all()
    show - color1
示例#3
0
    def test(cls):
        inst0 = np.arange(-100, 10000)
        inst1 = np.random.randint(-cls.max_denominator / 2,
                                  cls.max_denominator / 2, (10000))
        inst2 = np.float32(
            np.linspace(-cls.max_denominator / 2, cls.max_denominator / 2,
                        10000))
        inst3 = np.float32(np.random.rand(10000) * 10000.3 - 1000)
        for inst in [inst0, inst1, inst2, inst3]:
            boxx.tree - inst
            for inst_id in inst.flatten():
                rgb = encode_inst_id.id_to_rgb(inst_id).astype(np.float32)
                # print(rgb, inst_id)
                recover = encode_inst_id.rgb_to_id(rgb)
                boxx.mg()
                assert recover == inst_id, (inst_id, recover)

        assert (encode_inst_id.rgb_to_id(np.float32(
            [0, 0, 0])) == 0), "Check background should decode to 0"