@@ -117,7 +117,7 @@ class isoImager
117117 }
118118
119119 template <typename T>
120- void time_draw (cv::Mat img, T begin, T end, int step = 1 ) {
120+ void time_draw (cv::Mat img, T begin, T end, int count ) {
121121
122122 // if there is nothing to draw, just draw the frame
123123 if (begin == end)
@@ -126,42 +126,58 @@ class isoImager
126126 return ;
127127 }
128128
129- // otherwise draw the events
130- double t0 = begin.timestamp ();
131129 double tf = end.timestamp ();
132- if (step < 1 ) step = 1 ;
133- int counter = 0 ;
134- for ( auto a = begin; a != end; a++) {
130+ int remaining = count ;
131+ int skip = (count - 2e6 ) / 2e6 ;
132+ if (skip < 1 ) skip = 1 ;
135133
134+ // draw with skipping (2e6)
135+ auto a = begin;
136+ while (remaining > 1e6 )
137+ {
136138 double dt = tf - (a.timestamp ());
137- if (dt < 0 )
138- break ;
139-
140- if (dt < 0.05 ) {
141- int x = a->x ;
142- int y = a->y ;
143- double z = 0 ;
144- ps.pttr (x, y, z);
145- if (x < 0 || x >= img.cols || y < 0 || y >= img.rows )
146- continue ;
147- if (a->p )
148- img.at <cv::Vec3b>(y, x) = aqua;
149- else
150- img.at <cv::Vec3b>(y, x) = violet;
151- }
152-
153- if (counter++ % step) continue ;
139+ int x = a->x ;
140+ int y = a->y ;
141+ ps.pttr (x, y, dt);
142+ if (a->p )
143+ img.at <cv::Vec3b>(y, x) -= naqua;
144+ else
145+ img.at <cv::Vec3b>(y, x) -= nviolet;
146+ std::advance (a, skip);
147+ remaining-=skip;
148+ }
154149
150+ // draw the most recent 2e6 without skipping
151+ while (remaining > 10000 )
152+ {
153+ double dt = tf - (a.timestamp ());
155154 int x = a->x ;
156155 int y = a->y ;
157- double z = dt;
158- ps.pttr (x, y, z);
159- if (x < 0 || x >= img.cols || y < 0 || y >= img.rows )
160- continue ;
156+ ps.pttr (x, y, dt);
161157 if (a->p )
162158 img.at <cv::Vec3b>(y, x) -= naqua;
163159 else
164160 img.at <cv::Vec3b>(y, x) -= nviolet;
161+ a++;
162+ remaining--;
163+ }
164+
165+ // draw while placing an image on the front surface
166+ while (a != end) {
167+
168+ double dt = tf - (a.timestamp ()), z = 0.0 ;
169+ int x1 = a->x , x2 = a->x ;
170+ int y1 = a->y , y2 = a->y ;
171+ ps.pttr (x1, y1, dt);
172+ ps.pttr (x2, y2, z);
173+ if (a->p ) {
174+ img.at <cv::Vec3b>(y1, x1) -= naqua;
175+ img.at <cv::Vec3b>(y2, x2) = aqua;
176+ } else {
177+ img.at <cv::Vec3b>(y1, x1) -= nviolet;
178+ img.at <cv::Vec3b>(y2, x2) = violet;
179+ }
180+ a++;
165181 }
166182
167183 img -= base_image;
0 commit comments