metterklume / chessputzer

Image recognition for chess positions
112 stars 24 forks source link

Error when running command line version (putzmain.py) #11

Open JohnCTillis opened 1 year ago

JohnCTillis commented 1 year ago
Traceback (most recent call last):
  File "<frozen runpy>", line 189, in _run_module_as_main
  File "<frozen runpy>", line 112, in _get_module_details
  File "/home/user/programming/chess/putzmain.py", line 216, in <module>
    alltemps = np.load('pbarrs.npz').items()[0][1]
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
TypeError: 'ItemsView' object is not subscriptable

This error occurs simply when trying to run the script normally like so:

python3 -m putzmain.py -f board.png -o out.txt
Patjwmiller commented 5 months ago
Traceback (most recent call last):
  File "<frozen runpy>", line 189, in _run_module_as_main
  File "<frozen runpy>", line 112, in _get_module_details
  File "/home/user/programming/chess/putzmain.py", line 216, in <module>
    alltemps = np.load('pbarrs.npz').items()[0][1]
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
TypeError: 'ItemsView' object is not subscriptable

This error occurs simply when trying to run the script normally like so:

python3 -m putzmain.py -f board.png -o out.txt

If you're using OpenCV 4.0 or later, modify the line in putzlib.py, contourbox function:

find this line: _,contours,_ = cv2.findContours(ee, 1, 2)

replace with: contours, _ = cv2.findContours(ee, 1, 2) # Remove the first '_'

You might have to do this in the lib py file as well.