-
Notifications
You must be signed in to change notification settings - Fork 0
/
orien_lines.py
61 lines (33 loc) · 2.78 KB
/
orien_lines.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import cv2
def drawsafelines(image_np,Orientation,Line_Perc1,Line_Perc2):
posii=int(image_np.shape[1]-(image_np.shape[1]/3))
cv2.putText(image_np,'Blue Line : Machine Border Line',
(posii,30),
cv2.FONT_HERSHEY_COMPLEX_SMALL, 0.5, (0,0,255), 1, cv2.LINE_AA)
cv2.putText(image_np, 'Red Line : Safety Border Line',
(posii,50),
cv2.FONT_HERSHEY_COMPLEX_SMALL, 0.5, (255,0,0), 1, cv2.LINE_AA)
if(Orientation=="bt"):
Line_Position1=int(image_np.shape[0]*(Line_Perc1/100))
Line_Position2=int(image_np.shape[0]*(Line_Perc2/100))
cv2.line(img=image_np, pt1=(0, Line_Position1), pt2=(image_np.shape[1], Line_Position1), color=(0, 0, 255), thickness=2, lineType=8, shift=0)
cv2.line(img=image_np, pt1=(0, Line_Position2), pt2=(image_np.shape[1], Line_Position2), color=(255, 0, 0), thickness=2, lineType=8, shift=0)
return Line_Position2;
elif(Orientation=="tb"):
Line_Position1=int(image_np.shape[0]-(image_np.shape[0]*(Line_Perc1/100)))
Line_Position2=int(image_np.shape[0]-(image_np.shape[0]*(Line_Perc2/100)))
cv2.line(img=image_np, pt1=(0, Line_Position1), pt2=(image_np.shape[1], Line_Position1), color=(0, 0, 255), thickness=2, lineType=8, shift=0)
cv2.line(img=image_np, pt1=(0, Line_Position2), pt2=(image_np.shape[1], Line_Position2), color=(255, 0, 0), thickness=2, lineType=8, shift=0)
return Line_Position2;
elif(Orientation=="lr"):
Line_Position1=int(image_np.shape[1]-(image_np.shape[1]*(Line_Perc1/100)))
Line_Position2=int(image_np.shape[1]-(image_np.shape[1]*(Line_Perc2/100)))
cv2.line(img=image_np, pt1=(Line_Position1, 0), pt2=(Line_Position1,image_np.shape[0]), color=(0, 0, 255), thickness=2, lineType=8, shift=0)
cv2.line(img=image_np, pt1=(Line_Position2, 0), pt2=(Line_Position2,image_np.shape[0]), color=(255, 0, 0), thickness=2, lineType=8, shift=0)
return Line_Position2;
elif(Orientation=="rl"):
Line_Position1=int(image_np.shape[1]*(Line_Perc1/100))
Line_Position2=int(image_np.shape[1]*(Line_Perc2/100))
cv2.line(img=image_np, pt1=(Line_Position1, 0), pt2=(Line_Position1,image_np.shape[0]), color=(0, 0, 255), thickness=2, lineType=8, shift=0)
cv2.line(img=image_np, pt1=(Line_Position2, 0), pt2=(Line_Position2,image_np.shape[0]), color=(255, 0, 0), thickness=2, lineType=8, shift=0)
return Line_Position2;