In [1]:
import sys
sys.path.append('../')

In [2]:
%load_ext autoreload
%autoreload 2

In [6]:
import numpy as np
from matplotlib import pyplot as plt
%matplotlib inline

In [22]:
import numpy as np
from segmentboard.segmentboard import crop

def test_crop():
    img_test = np.arange(20).reshape((4, 5))
    assert (crop(img_test, 2, 5, 0, 2) == np.array([[2, 3, 4], [7, 8, 9]])).all()

In [13]:
img_test = np.arange(20).reshape((4, 5))

In [14]:
img_test


Out[14]:
array([[ 0,  1,  2,  3,  4],
       [ 5,  6,  7,  8,  9],
       [10, 11, 12, 13, 14],
       [15, 16, 17, 18, 19]])

In [15]:
crop(img_test, 2, 5, 0, 2)


Out[15]:
array([[2, 3, 4],
       [7, 8, 9]])

In [21]:
assert (crop(img_test, 2, 5, 0, 2) == np.array([[2, 3, 4], [7, 8, 9]])).all()

In [ ]:


In [33]:
from segmentboard.segmentboard import extract_cards
from utils.format import bgr2rgb
import cv2

def test_extract_cards():
    board_img = bgr2rgb(cv2.imread('../tests/test_data/test_board.jpg'))
    cards = extract_cards(board_img)
    assert len(cards) == 12

In [34]:
test_extract_cards()


12 cards segmented.

In [4]:
from segmentboard.segmentboard import extract_cards
from utils.format import bgr2rgb
import cv2


def test_extract_cards():
    """Simple test. Todo: add more tests"""
    board_img = bgr2rgb(cv2.imread('../tests/test_data/test_board.jpg'))
    cards = extract_cards(board_img)
    assert len(cards) == 12
    
test_extract_cards()


---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-4-20f67c1f8498> in <module>()
     10     assert len(cards) == 12
     11 
---> 12 test_extract_cards()

<ipython-input-4-20f67c1f8498> in test_extract_cards()
      6 def test_extract_cards():
      7     """Simple test. Todo: add more tests"""
----> 8     board_img = bgr2rgb(cv2.imread('./tests/test_data/test_board.jpg'))
      9     cards = extract_cards(board_img)
     10     assert len(cards) == 12

/Users/ivan/projects/set/dev/utils/format.py in bgr2rgb(img)
     16 
     17     """
---> 18     return cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

error: /Users/jenkins/miniconda/1/x64/conda-bld/conda_1486587097465/work/opencv-3.1.0/modules/imgproc/src/color.cpp:7341: error: (-215) scn == 3 || scn == 4 in function ipp_cvtColor

In [36]:
test_extract_cards()


12 cards segmented.

In [ ]:


In [ ]:


In [ ]:


In [ ]: