예제 #1
0
def detect_board(filename):
    output_filename = os.path.splitext(filename)[0] + "_corners.txt"
    if os.path.exists(output_filename):
        print "Skipping %s, exists." % filename
        return True, filename
    else:
        print "Detecting on %s" % filename
    thresh = True
    # This may no longer be necessary.
    #if 'bmp' in filename:
    #    thresh = False
    try:
        img = imread(filename)
    except:
        warn(filename)
        return False, filename
    if len(img.shape) == 0:
        warn(filename)
        return False, filename
    try:
        corners, chessboards = pycb.extract_chessboards(
            img, use_corner_thresholding=thresh)
    except Exception as e:
        print "Exception on file", filename
        raise e
    if len(chessboards) > 0:
        write_board(filename, corners, chessboards)
        return True, filename
    else:
        return False, filename
def get_corners_rgb(rgb, method='pycb', rows=None,cols=None):
    
    if not rows: rows = cb_rows
    if not cols: cols = cb_cols
    
    if method=='cv':
        cv_rgb = cv.fromarray(rgb)
        rtn, corners = cv.FindChessboardCorners(cv_rgb, (rows, cols))
        return rtn, corners
    elif method=='pycb':
        corners, cbs = extract_chessboards(rgb)
        if len(cbs) == 0:
            return 0, None
        elif len(cbs) == 1:
            return 1, corners[cbs[0]]
        else:
            cbcorners = []
            for cb in cbs:
                cbcorners.append(corners[cb])
            return len(cbs), cbcorners
예제 #3
0
파일: simple.py 프로젝트: afcarl/pycb
from scipy.misc import imread
from pycb import extract_chessboards, draw_boards

img = imread("scene1.jpg")
corners, chessboards = extract_chessboards(img)
draw_boards(img, corners, chessboards)
예제 #4
0
from scipy.misc import imread
from pycb import extract_chessboards, draw_boards

img = imread("scene1.jpg")
corners, chessboards, unrefined = extract_chessboards(img,
                                                      include_unrefined=True)
draw_boards(img, corners, chessboards, unrefined)