delete [] ypts;
}
-const char* Motion51Main::plugin_title() { return _("Motion51"); }
+const char* Motion51Main::plugin_title() { return N_("Motion51"); }
int Motion51Main::is_realtime() { return 1; }
int Motion51Main::is_multichannel() { return 1; }
FileXML output;
// cause data to be stored directly in text
- output.set_shared_output(keyframe->get_data(), MESSAGESIZE);
+ output.set_shared_output(keyframe->xbuf);
output.tag.set_title("MOTION51");
output.tag.set_property("HORIZ_LIMIT", config.horiz_limit);
output.tag.set_property("VERT_LIMIT", config.vert_limit);
void Motion51Main::read_data(KeyFrame *keyframe)
{
FileXML input;
- input.set_shared_input(keyframe->get_data(), strlen(keyframe->get_data()));
+ input.set_shared_input(keyframe->xbuf);
int result = 0;
while( !(result = input.read_tag()) ) {
delete tmp; tmp = 0;
}
if( !tmp )
- tmp = new VFrame(0, -1, ref->get_w(), ref->get_h(), ref->get_color_model(), -1);
+ tmp = new VFrame(ref->get_w(), ref->get_h(), ref->get_color_model(), 0);
return tmp;
}
}
}
+Motion51VVFrame::Motion51VVFrame(VFrame *vfrm, int n)
+ : VFrame(vfrm->get_data(), -1, vfrm->get_y()-vfrm->get_data(),
+ vfrm->get_u()-vfrm->get_data(), vfrm->get_v()-vfrm->get_data(),
+ vfrm->get_w(), vfrm->get_h(), vfrm->get_color_model(),
+ vfrm->get_bytes_per_line())
+{
+ this->n = n;
+}
+
+int Motion51VVFrame::draw_pixel(int x, int y)
+{
+ VFrame::draw_pixel(x+0, y+0);
+ for( int i=1; i<n; ++i ) {
+ VFrame::draw_pixel(x-i, y-i);
+ VFrame::draw_pixel(x-i, y+i);
+ VFrame::draw_pixel(x+i, y-i);
+ VFrame::draw_pixel(x+i, y+i);
+ }
+ return 0;
+}
void Motion51Main::draw_vectors(VFrame *img)
{
- img->draw_arrow(rx, ry, rx+current_dx, ry+current_dy);
+ int iw = img->get_w(), ih = img->get_h();
+ int mx = iw > ih ? iw : ih;
+ int n = mx/800 + 1;
+ Motion51VVFrame vfrm(img, n);
+ vfrm.set_pixel_color(WHITE);
+ int m = 2; while( m < n ) m <<= 1;
+ vfrm.set_stiple(2*m);
-// img->draw_smooth(rx-rr,ry, rx-rr,ry+rr, rx,ry+rr);
-// img->draw_smooth(rx,ry+rr, rx+rr,ry+rr, rx+rr,ry);
-// img->draw_smooth(rx+rr,ry, rx+rr,ry-rr, rx,ry-rr);
-// img->draw_smooth(rx,ry-rr, rx-rr,ry-rr, rx-rr,ry);
+ vfrm.draw_arrow(rx, ry, rx+current_dx, ry+current_dy);
+// vfrm.draw_smooth(rx-rr,ry, rx-rr,ry+rr, rx,ry+rr);
+// vfrm.draw_smooth(rx,ry+rr, rx+rr,ry+rr, rx+rr,ry);
+// vfrm.draw_smooth(rx+rr,ry, rx+rr,ry-rr, rx,ry-rr);
+// vfrm.draw_smooth(rx,ry-rr, rx-rr,ry-rr, rx-rr,ry);
float rx1 = rx - 0.5*rw;
float ry1 = ry - 0.5*rh;
float rx2 = rx1 + rw;
float ry2 = ry1 + rh;
- img->draw_line(rx1, ry1, rx2, ry1);
- img->draw_line(rx2, ry1, rx2, ry2);
- img->draw_line(rx2, ry2, rx1, ry2);
- img->draw_line(rx1, ry2, rx1, ry1);
+ vfrm.draw_line(rx1, ry1, rx2, ry1);
+ vfrm.draw_line(rx2, ry1, rx2, ry2);
+ vfrm.draw_line(rx2, ry2, rx1, ry2);
+ vfrm.draw_line(rx1, ry2, rx1, ry1);
float sx1 = rx1 - rr, sy1 = ry1 - rr;
float sx2 = rx2 + rr, sy2 = ry2 + rr;
- img->draw_smooth(sx1, ry1, sx1, sy1, rx1, sy1);
- img->draw_line(rx1, sy1, rx2, sy1);
- img->draw_smooth(rx2, sy1, sx2, sy1, sx2, ry1);
- img->draw_line(sx2, ry1, sx2, ry2);
- img->draw_smooth(sx2, ry2, sx2, sy2, rx2, sy2);
- img->draw_line(rx2, sy2, rx1, sy2);
- img->draw_smooth(rx1, sy2, sx1, sy2, sx1, ry2);
- img->draw_line(sx1, ry2, sx1, ry1);
+ vfrm.draw_smooth(sx1, ry1, sx1, sy1, rx1, sy1);
+ vfrm.draw_line(rx1, sy1, rx2, sy1);
+ vfrm.draw_smooth(rx2, sy1, sx2, sy1, sx2, ry1);
+ vfrm.draw_line(sx2, ry1, sx2, ry2);
+ vfrm.draw_smooth(sx2, ry2, sx2, sy2, rx2, sy2);
+ vfrm.draw_line(rx2, sy2, rx1, sy2);
+ vfrm.draw_smooth(rx1, sy2, sx1, sy2, sx1, ry2);
+ vfrm.draw_line(sx1, ry2, sx1, ry1);
double *xp = xpts, *yp = ypts;
for( int i=cir_sz; --i>=0; ++xp, ++yp )
- img->draw_pixel(rx+*xp, ry+*yp);
+ vfrm.draw_pixel(rx+*xp, ry+*yp);
}
int Motion51Main::open_cache_file()
if( key == active_key ) return 1;
if( !active_fp ) {
close_cache_file();
- sprintf(cache_file, "%s.bak", config.tracking_file);
+ snprintf(cache_file, sizeof(cache_file), "%s.bak", config.tracking_file);
::rename(config.tracking_file, cache_file);
if( !(active_fp = fopen(config.tracking_file, "w")) ) {
perror(config.tracking_file);