numpy.array setting an array element with a sequence
HellO! I am russian student and I began to study OpenCV :) I write this code:
import cv2
import numpy
def eye_detection():
src = cv2.imread("E:\\Ilya\\PythonProjects\\eye.jpg")
if src == None:
print 'Do not open image!'
return -1
gray = cv2.cvtColor(~src, cv2.cv.CV_BGR2GRAY)
cv2.threshold(gray, 220, 255, cv2.THRESH_BINARY, gray)
contours = cv2.findContours(gray.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
#cv2.imwrite(str("E:\\Ilya\\PythonProjects\\") + str("1") + ".jpg", gray)
#print(contours)
numpy.array(contours, dtype=numpy.float)
cv2.drawContours(gray, cv2.cv.Scalar(contours), -1, cv2.cv.RGB(255,255,255), -1)
if __name__ == "__main__":
eye_detection()
If I compile this script:
line 16, in eye_detection
numpy.array(contours, dtype=numpy.float)
ValueError: setting an array element with a sequence.
contours contains(print(contours)):
([array([[[344, 254]]]), array([[[194, 243]],
[[194, 244]],
[[195, 244]],
[[196, 244]],
[[197, 244]],
[[198, 244]],
[[199, 244]],
[[200, 244]],
[[201, 244]],
[[202, 244]],
[[203, 244]],
[[204, 244]],
[[205, 244]],
[[204, 244]],
[[203, 244]],
[[202, 244]],
[[201, 243]],
[[200, 243]],
[[199, 243]],
[[198, 243]],
[[197, 243]],
[[196, 243]],
[[195, 243]]]), array([[[217, 242]], etc.
how to solve this problem?