Beispiel #1
0
def detect_chessboard(chessboard_images,
                      size_of_chessboard=47,
                      shape_of_chessboard=(8, 6)):

    # BUILD CHESSBOARD OBJECT
    chessboard = phm_calib.Chessboard(size_of_chessboard, shape_of_chessboard)

    for id_camera in chessboard_images:
        for angle in chessboard_images[id_camera]:
            im = chessboard_images[id_camera][angle]
            found = chessboard.detect_corners(id_camera, angle, im)

    return [chessboard],
def test_chessboard_3():
    plant_number = 1

    chess = phm_calib.Chessboard(50, (8, 6))

    images = phm_data.chessboard_images(plant_number=plant_number)[0]
    found = chess.detect_corners("side", 42, images['side'][42])

    if found:
        corners = chess.get_corners_2d("side")[42]
        res = numpy.array(corners).astype(float)
        res = numpy.around(res, decimals=2)

        assert res.shape == (48, 2)
    else:
        assert False
Beispiel #3
0
def test_chessboard_3():

    chess = phm_calib.Chessboard(50, (8, 6))

    dir_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                            "../data/plant_1")
    images = phm_data.chessboard_images(dir_path)[0]
    found = chess.detect_corners("side", 42, images['side'][42])

    if found:
        corners = chess.get_corners_2d("side")[42]
        res = numpy.array(corners).astype(float)
        res = numpy.around(res, decimals=2)

        assert res.shape == (48, 2)
    else:
        assert False
Beispiel #4
0
def test_chessboard_2():
    chess = phm_calib.Chessboard(50, (8, 6))

    result = chess.get_corners_local_3d()

    assert numpy.array_equal(result[8 * 0 + 0], [0., 0., 0.])
    assert numpy.array_equal(result[8 * 0 + 1], [50., 0., 0.])
    assert numpy.array_equal(result[8 * 0 + 2], [100., 0., 0.])
    assert numpy.array_equal(result[8 * 0 + 3], [150., 0., 0.])
    assert numpy.array_equal(result[8 * 0 + 4], [200., 0., 0.])
    assert numpy.array_equal(result[8 * 0 + 5], [250., 0., 0.])
    assert numpy.array_equal(result[8 * 0 + 6], [300., 0., 0.])
    assert numpy.array_equal(result[8 * 0 + 7], [350., 0., 0.])

    assert numpy.array_equal(result[8 * 5 + 0], [0., 250., 0.])
    assert numpy.array_equal(result[8 * 5 + 1], [50., 250., 0.])
    assert numpy.array_equal(result[8 * 5 + 2], [100., 250., 0.])
    assert numpy.array_equal(result[8 * 5 + 3], [150., 250., 0.])
    assert numpy.array_equal(result[8 * 5 + 4], [200., 250., 0.])
    assert numpy.array_equal(result[8 * 5 + 5], [250., 250., 0.])
    assert numpy.array_equal(result[8 * 5 + 6], [300., 250., 0.])
    assert numpy.array_equal(result[8 * 5 + 7], [350., 250., 0.])
Beispiel #5
0
def test_chessboard_1():
    chess = phm_calib.Chessboard(50, (8, 6))

    assert chess.square_size == 50
    assert chess.shape == (8, 6)
    assert chess.image_points == dict()
import openalea.phenomenal.display as phm_display
import openalea.phenomenal.calibration as phm_calib

## Detect chessboard corners in the images
##  Load Images
plant_number = 1
chessboard_images = phm_data.chessboard_images(plant_number=plant_number)[0]
phm_display.show_image(chessboard_images['side'][42])

## Create chessboard object

square_size_of_chessboard = 47 # In mm
square_shape_of_chessboard = (8, 6) # (8 square x 6 square on chessboard)

# BUILD CHESSBOARD OBJECT
chessboard = phm_calib.Chessboard(square_size_of_chessboard, 
                                  square_shape_of_chessboard)

# DISPLAY IT
print chessboard

## Detect corners from images
for id_camera in chessboard_images:
    for angle in chessboard_images[id_camera]:
        im = chessboard_images[id_camera][angle]
        found = chessboard.detect_corners(id_camera, angle, im)
        print("Angle {} - Chessboard corners {}".format(angle, "found" if found else "not found"))

## Display chessboard corners on images
angle = 42
img = chessboard_images["side"][angle].copy()