Input image:

Code used:
import cv2
import numpy as np
from google.colab.patches import cv2_imshow
# Read the image and convert to grayscale
image = cv2.imread('input.png')
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(gray_image, 127, 255, 0)
contours, hierarchy = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
for i, cnt in enumerate(contours):
hull = cv2.convexHull(cnt)
epsilon = 0.02 * cv2.arcLength(cnt, True)
approx = cv2.approxPolyDP(cnt, epsilon, True)
# Draw approximated polygon
for ap in approx:
cv2.circle(image, tuple(ap[0]), 5, (255, 0, 0), -1)
# Display the result
cv2_imshow(image)
Output:

I've tried using other corner detector methods and some filtering methods such as the gaussian blur without any improvement. Can somebody help me to detect correctly the ending points and the intersection points?



For a point on the lines i.e. a point that is black in your picture imagine counting the points that are slightly closer to it than the lines are thick. You get the biggest count if you at a crossing and the smallest if you're at an end of a line.
An efficient way to count the points near a point in an image is taking the convolution with ones.
I put some white space around the image:
Calculate points that are very dark in the convolution:
Finally I plot the convolution with very light points marked that are not white in the original image: