Skip to content

Commit f3946ed

Browse files
authored
isodraw count based image (#176)
1 parent 6ca3069 commit f3946ed

2 files changed

Lines changed: 44 additions & 28 deletions

File tree

cpp_tools/vFramer/drawers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ double isoDrawer::updateImage()
155155
int step = inf.count / max_events_to_draw; // a maximum of events to draw
156156

157157
canvas.setTo(white);
158-
iso_drawer.time_draw< window<AE>::iterator >(canvas, input.begin(), input.end(), 0);
158+
iso_drawer.time_draw< window<AE>::iterator >(canvas, input.begin(), input.end(), inf.count);
159159

160160
return inf.timestamp;
161161
}

ev2/event-driven/vis/draw.h

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)