Python&OpenCV buglist

作者: 童年雅趣 | 来源:发表于2019-03-05 15:42 被阅读5次
  1. OpenCV python: ValueError: too many values to unpack
#Bug: 
Traceback (most recent call last):
    File "skinimagecontour.py", line 13, in <module>
    contours, _ = cv2.findContours(skin_ycrcb, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
ValueError: too many values to unpack
#解决:
 contours, _ = cv2.findContours(skin_ycrcb, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
改为
  _, contours,  _ = cv2.findContours(skin_ycrcb, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
  1. 错误“TypeError: a bytes-like object is required, not 'str'”
Traceback (most recent call last):
  File "detect_numbers_images.py", line 38, in <module>
    model = pickle.loads(model)
TypeError: a bytes-like object is required, not 'str'

file = open(args["model"])
model = pickle.load(file)
改为
file = open(args["model"], 'rb')
model = pickle.load(file,encoding='bytes')

3.错误“Python3版UnicodeDecodeError: 'ascii' codec can't decode byte 0x90 in position 614: ordinal not in”

nvidia@tegra-ubuntu:~/work/algorithm/Number_Detection$ python3 detect_numbers_images.py --model models/svm.cpickle --image images/f5a.jpg
Traceback (most recent call last):
  File "detect_numbers_images.py", line 38, in <module>
    model = pickle.load(file)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc6 in position 1: ordinal not in range(128)

model = pickle.load(file)
改为
model = pickle.load(file,encoding='bytes')

  1. 错误 “TypeError: integer argument expected, got float”

改:'/' 为'//'

  1. 错误“ValueError: too many values to unpack (expected 2)”

(cnts, _) = cv2.findContours(edged.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
改为
cnts = cv2.findContours(edged.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

  1. 错误:Python3 “ImportError: No module named 'cPickle'”
Traceback (most recent call last):
  File "detect_numbers_images.py", line 19, in <module>
    import cPickle
ImportError: No module named 'cPickle'

import cPickle
改为
import pickle

  1. 错误“ ”

相关文章

网友评论

    本文标题:Python&OpenCV buglist

    本文链接:https://www.haomeiwen.com/subject/ltmuuqtx.html