added adptative threshold to detect chessboard