I am working on an application of vehicle detection, the purpose is to check if road is congested or not. The solution that came to my mind is to detect the vehicles moving in each direction separately and then apply limit on the number of vehicles in each direction. I have drawn horizontal lines that detect if the car is moving up or moving down. The problem I am facing is that I am unable to draw vertical lines. If I have height and width of a frame, how can we get parallel vertical lines from that information. One solution for horizontal that I got from somewhere is;
# Upper/Lower Lines
line_up = int(2*(h/6))
line_down = int(3*(h/5))
up_limit = int(1*(h/6))
down_limit = int(4*(h/5))
print("Blue line y:", str(line_down))
print("Red line y:", str(line_up))
line_down_color = (255,0,0)
line_up_color = (0,0,255)
pt1 = [0, line_down]
pt2 = [w, line_down]
pts_L1 = np.array([pt1,pt2], np.int32)
pts_L1 = pts_L1.reshape((-1,1,2))
pt3 = [0, line_up]
pt4 = [w, line_up]
pts_L2 = np.array([pt3,pt4], np.int32)
pts_L2 = pts_L2.reshape((-1,1,2))
pt5 = [0, up_limit]
pt6 = [w, up_limit]
pts_L3 = np.array([pt5,pt6], np.int32)
pts_L3 = pts_L3.reshape((-1,1,2))
pt7 = [0, down_limit]
pt8 = [w, down_limit]
pts_L4 = np.array([pt7,pt8], np.int32)
pts_L4 = pts_L4.reshape((-1,1,2))
I tried to change, variables for vertical lines, like h to w. But I am not getting the desired functionality. Any help in this regard would really be appreciated. I also want to know how ;
line_up = int(2*(h/6))
line_down = int(3*(h/5))
up_limit = int(1*(h/6))
down_limit = int(4*(h/5))
this upper code is helping to get expected horizontal lines.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…