@@ -70,6 +70,12 @@ def __init__(self):
70
70
71
71
def publish_from_img (self , img : np .ndarray , timestamp : Time ):
72
72
self .frame_count += 1
73
+ if self .frame_count % self .measurement_count == 0 :
74
+ self .tm .stop ()
75
+ self .fps = (self .frame_count - self .before_frame ) / self .tm .getTimeSec ()
76
+ self .before_frame = self .frame_count
77
+ self .tm .reset ()
78
+ self .tm .start ()
73
79
74
80
masked_img , boxes = self .people_detection_wrapper .detect (img )
75
81
@@ -87,13 +93,6 @@ def publish_from_img(self, img: np.ndarray, timestamp: Time):
87
93
if self .is_debug_mode :
88
94
result_img = np .zeros (img .shape [:2 ]).astype (np .uint8 )
89
95
90
- if self .frame_count % self .measurement_count == 0 :
91
- self .tm .stop ()
92
- self .fps = (self .frame_count - self .before_frame ) / self .tm .getTimeSec ()
93
- self .before_frame = self .frame_count
94
- self .tm .reset ()
95
- self .tm .start ()
96
-
97
96
debug_img = cv2 .cvtColor (result_img , cv2 .COLOR_GRAY2BGR )
98
97
cv2 .putText (debug_img , "frame = " + str (self .frame_count ), (0 , 50 ), cv2 .FONT_HERSHEY_PLAIN , 3 , (0 , 255 , 0 ))
99
98
cv2 .putText (debug_img , 'FPS: {:.2f}' .format (self .fps ),
@@ -109,7 +108,7 @@ def publish_from_img(self, img: np.ndarray, timestamp: Time):
109
108
cv2 .imshow ('Result' , cv2 .hconcat ([img , debug_img , combine_img ]))
110
109
cv2 .waitKey (1 )
111
110
112
- print (f'[{ datetime .datetime .now ()} ] fps : { self .fps } ' , end = '\r ' )
111
+ print (f'[{ datetime .datetime .now ()} ] fps : { self .fps } ' , end = '\r ' )
113
112
114
113
def get_img_callback (self , image_raw : Image ) -> None :
115
114
try :
0 commit comments