Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
333 views
in Technique[技术] by (71.8m points)

python - Drawing verticle lines on video frames in vehicle detection

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...