I want to recognize table structure from some arbitrary photo image and store it in some formal notation (Let it be HTML table notation).
Now to detect structure I want to detect intersections between lines, their type (T-type, X-type, or simple corner), their orientations and their location on the image. After this I'm going to use all gained information for further joining of adjacent crosses in some structure, and translate this structure into formal representation.
In general these crosses may be scaled and/or rotated. Maybe someone could help with method of solving this problem? Or maybe recommend different methods for this whole task?
That's what I have written so far:
# -*- coding: utf-8 -*- import cv2 import cv import numpy original = cv2.imread("/home/user/my_photo-1.jpg") grayscale = cv2.cvtColor(original, cv2.COLOR_BGR2GRAY) smoothed = cv2.GaussianBlur(grayscale, (5,5), 0) cv2.imshow("original", original) cv2.imshow("grayscale", grayscale) binarized = cv2.adaptiveThreshold(grayscale, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY_INV, 7, 8) binarized = cv2.Canny(grayscale, 50, 200) cv2.imshow("binarized", binarized) cv2.waitKey(0)
Thanks in advance for any response/idea.