# -*- coding: utf-8 -*-
"""Command Line Group for OpenCV Functions"""

import cv2
import click
import numpy as np


class Configuration(object):
    """Configuration Defaults"""

    def __init__(self):
        """Set default configuration.

        Termination Criteria:
            Stop on either maximum iterations or subpixel resolution.

        TERM_CRITERIA_MAX_ITER iteration stop
        TERM_CRITERIA_EPS      subpixel resolution stop

        Default is to stop on either 30 iterations or 1/1000 pixel resolution.
        """

        self.MAXIMUM_ITERATIONS = 30
        self.PIXEL_RESOLUTION = 0.001

        self.criteria = (cv2.TERM_CRITERIA_MAX_ITER + cv2.TERM_CRITERIA_EPS,
                         self.MAXIMUM_ITERATIONS,
                         self.PIXEL_RESOLUTION)

        self.COLUMNS = 7
        self.ROWS = 6
        # Size the array to support the number of inner points in the board.
        self.chessboard_points = np.zeros((self.COLUMNS * self.ROWS, 3),
                                          np.float32)
        # Fill the first two columns with an index.
        self.chessboard_points[:, :2] = np.mgrid[0:self.COLUMNS,
                                                 0:self.ROWS].T.reshape(-1, 2)

        self.chessboard3d_points = []
        self.chessboard2d_points = []


pass_configuration = click.make_pass_decorator(Configuration)
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])


@click.group(context_settings=CONTEXT_SETTINGS)
@click.pass_context
def cli(ctx):
    """cv2stuff group function

    Instantiate the ctx.obj to be a Configuration object.
    """

    ctx.obj = Configuration()


@cli.command()
def find_show_chessboard_corners():
    pass

@@ -1,28 +1,4 @@
-# -*- coding: utf-8 -*-%0A
 %22%22%22C
@@ -125,379 +125,151 @@
  %22%22%22
-Configuration Defaults%22%22%22%0A%0A    def __init__(self):%0A        %22%22%22Set default configuration.%0A%0A        Termination Criteria:%0A            Stop on either maximum iterations or subpixel resolu
+Set and maintain configuration defaults for the rest of the%0A    applica
 tion.%0A
-%0A
     
-    TERM_CRITERIA_MAX_ITER iteration stop%0A        TERM_CRITERIA_EPS      subpixel resolution stop%0A%0A        Default is to stop on either 30 iterations or 1/1000 pixel resolution
+%22%22%22%0A%0A    def __init__(self):%0A        %22%22%22Initilize the defaults
 .%0A  
@@ -1274,89 +1274,537 @@
  %22%22%22
-cv2stuff group function%0A%0A    Instantiate the ctx.obj to be a Configu
+%0A    By default this program should reconize a chessboard image with seven%0A    columns and six rows.  Since that is the number of 'inner' corners the%0A    chessboard image actually has 8 columns of square by 7 rows.%0A%0A    The termination criteria for finding subpixel centers is tostop on either%0A    maximum iterations or subpixel resolution.%0A%0A    TERM_CRITERIA_MAX_ITER: iteration stop%0A    TERM_CRITERIA_EPS:      subpixel resolution stop%0A%0A    The default behavior is to stop on either 30 ite
 ration
+s
  o
-bject
+r%0A    1/1000 pixel resolution
 .%0A  

update cv2stuff documentation