Why is the returned value of cv2.HoughLines of OpenCV for Python need to be accessed with index?
<p>I hope I wrote the question title right because I don't know how to exactly explain it. Consider below's code:</p>

<pre><code>lines = cv2.HoughLines(edges,1,np.pi/180,200)
for rho,theta in lines[0]:
    a = np.cos(theta)
    b = np.sin(theta)
    x0 = a*rho
    y0 = b*rho
    x1 = int(x0 + 1000*(-b))
    y1 = int(y0 + 1000*(a))
    x2 = int(x0 - 1000*(-b))
    y2 = int(y0 - 1000*(a))

    cv2.line(img,(x1,y1),(x2,y2),(0,0,255),2)
</code></pre>

<p>Why it has to be wrote <code>for rho,theta in lines[0]:</code>? By this kind of code, I can only obtain one line. I have tried to remove the indexing in <code>lines</code> but I got <code>ValueError: need more than 1 value to unpack</code>. I have tried to print the returned value and it look something like this:</p>

<pre><code>[[[ 287.            1.97222209]]

[[ 885.            1.20427716]]

[[ 881.            1.22173047]]]
</code></pre>

<p>I have kinda solved this problem my making the code look like this:</p>

<pre><code>lines = cv2.HoughLines(edges,1,np.pi/180,200)
for i in range(10):
    for rho,theta in lines[i]:
</code></pre>

<p>I wonder, what is really happening? Or did I do something wrong here?</p>