# Path: src/cte.py
# GOBAN_SIZE = 19
# 
# Path: src/cte.py
# BLACK = 1
# 
# Path: src/cte.py
# WHITE = 2


from cv import CV_8UC1
from cv import CV_BGR2GRAY
from cv import CloneMat
from cv import CvtColor
from cv import Canny
from cv import Smooth
from cv import CV_GAUSSIAN
from cv import CV_32FC3
from cv import CV_HOUGH_GRADIENT
from cv import HoughCircles
from cv import Get2D 
from cv import CreateMat
from src.cte import GOBAN_SIZE
from src.cte import BLACK
from src.cte import WHITE
    white_total = 0
    no_color = 0
    for x in range(pt[0] - radious/2, pt[0] + radious/2):
        try: 
            pixel = Get2D(img, pt[1], x)[:-1]
        except:
            continue
        if all(p > threshold for p in pixel):
            white_total += 1
        elif all(p < 50 for p in pixel):
            black_total += 1
        else:
            no_color += 1
    for y in range(pt[1] - radious/2, pt[1] + radious/2):
        try:
            pixel = Get2D(img, y, pt[0])
        except:
            continue
        if all(p > threshold for p in pixel):
            white_total += 1
        elif all(p < 50 for p in pixel):
            black_total += 1
        else:
            no_color += 1
    
    if white_total >= black_total and white_total >= no_color:
        return WHITE
    elif no_color >= black_total and no_color >= white_total:
        return -1
    elif black_total >= white_total and black_total >= no_color:

# Path: src/cte.py
# GOBAN_SIZE = 19
# 
# Path: src/cte.py
# BLACK = 1
# 
# Path: src/cte.py
# WHITE = 2


# Path: src/search_stones.py
from cv import CV_8UC1
from cv import CV_BGR2GRAY
from cv import CloneMat
from cv import CvtColor
from cv import Canny
from cv import Smooth
from cv import CV_GAUSSIAN
from cv import CV_32FC3
from cv import CV_HOUGH_GRADIENT
from cv import HoughCircles
from cv import Get2D 
from cv import CreateMat
from src.cte import GOBAN_SIZE
from src.cte import BLACK
from src.cte import WHITE

    white_total = 0
    no_color = 0
    for x in range(pt[0] - radious/2, pt[0] + radious/2):
        try: 
            pixel = Get2D(img, pt[1], x)[:-1]
        except:
            continue
        if all(p > threshold for p in pixel):
            white_total += 1
        elif all(p < 50 for p in pixel):
            black_total += 1
        else:
            no_color += 1
    for y in range(pt[1] - radious/2, pt[1] + radious/2):
        try:
            pixel = Get2D(img, y, pt[0])
        except:
            continue
        if all(p > threshold for p in pixel):
            white_total += 1
        elif all(p < 50 for p in pixel):
            black_total += 1
        else:
            no_color += 1
    
    if white_total >= black_total and white_total >= no_color:
        return WHITE
    elif no_color >= black_total and no_color >= white_total:
        return -1
    elif black_total >= white_total and black_total >= no_color:

        return BLACK