Q: OpencCV HoughLines does not find vertical lines I need to process tables and I decided to use openCV in python. However, at the first stage, I ran into a problem that the program does not find the lines that I am looking for. See the sample code below.
import cv2
import numpy as np

img = cv2.imread('./sssr/narodnoe_hozyaystvo_sssr_za_1913-1955_gg_page-0111.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
ret, threshold_image = cv2.threshold(img, 127, 255, 0)
edges = cv2.Canny(gray, 50, 150, apertureSize=3)
lines = cv2.HoughLines(edges, 1, np.pi / 180, 300)

for line in lines:
    for r, theta in line:
        a = np.cos(theta)
        b = np.sin(theta)
        x0 = a * r
        y0 = b * r
        x1 = int(x0 + 1000 * (-b))
        y1 = int(y0 + 1000 * (a))
        x2 = int(x0 - 1000 * (-b))
        y2 = int(y0 - 1000 * (a))
        cv2.line(threshold_image, (x1, y1), (x2, y2), (0, 0, 255), 2)

cv2.imwrite('linesDetected.jpg', threshold_image)

The the result is:
result of HoughLines transform
The program finds many lines that I don't need. It can't determine the vertical borders of the table header.
