X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fmotion-cv%2Fmotion-cv.C;h=e8249bb0233aceb62b6a109aa834559875c3013d;hb=853407b57330e275b6c58432c678159b2eac00db;hp=5e4a1c19cd2196d4438467ee9aa4ee8df7fb8edb;hpb=e0fc7bf81ed20c8fb98de25151a8e3b6aaedc55a;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/plugins/motion-cv/motion-cv.C b/cinelerra-5.1/plugins/motion-cv/motion-cv.C index 5e4a1c19..e8249bb0 100644 --- a/cinelerra-5.1/plugins/motion-cv/motion-cv.C +++ b/cinelerra-5.1/plugins/motion-cv/motion-cv.C @@ -206,7 +206,7 @@ MotionCVMain::~MotionCVMain() delete rotate_target_dst; } -const char *MotionCVMain::plugin_title() { return _("MotionCV"); } +const char *MotionCVMain::plugin_title() { return N_("MotionCV"); } int MotionCVMain::is_realtime() { return 1; } int MotionCVMain::is_multichannel() { return 1; } @@ -261,7 +261,7 @@ void MotionCVMain::save_data(KeyFrame *keyframe) // cause data to be stored directly in text output.set_shared_output(keyframe->get_data(), MESSAGESIZE); - output.tag.set_title("MOTION"); + output.tag.set_title("MOTIONCV"); output.tag.set_property("BLOCK_COUNT", config.block_count); output.tag.set_property("GLOBAL_POSITIONS", config.global_positions); @@ -290,7 +290,7 @@ void MotionCVMain::save_data(KeyFrame *keyframe) output.tag.set_property("HORIZONTAL_ONLY", config.horizontal_only); output.tag.set_property("VERTICAL_ONLY", config.vertical_only); output.append_tag(); - output.tag.set_title("/MOTION"); + output.tag.set_title("/MOTIONCV"); output.append_tag(); output.terminate_string(); } @@ -302,7 +302,7 @@ void MotionCVMain::read_data(KeyFrame *keyframe) int result = 0; while( !(result = input.read_tag()) ) { - if( input.tag.title_is("MOTION") ) { + if( input.tag.title_is("MOTIONCV") ) { config.block_count = input.tag.get_property("BLOCK_COUNT", config.block_count); config.global_positions = input.tag.get_property("GLOBAL_POSITIONS", config.global_positions); config.rotate_positions = input.tag.get_property("ROTATE_POSITIONS", config.rotate_positions); @@ -342,7 +342,7 @@ void MotionCVMain::allocate_temp(int w, int h, int color_model) temp_frame = 0; } if( !temp_frame ) - temp_frame = new VFrame(w, h, color_model); + temp_frame = new VFrame(w, h, color_model, 0); } void MotionCVMain::process_global() @@ -652,7 +652,7 @@ printf("MotionCVMain::process_buffer 1 start_position=%jd\n", start_position); config.mode2 == MotionCVConfig::SAVE ) { reset_cache_file(); char save_file[BCTEXTLEN]; - sprintf(save_file, "%s.sav", config.tracking_file); + snprintf(save_file, sizeof(save_file), "%s.sav", config.tracking_file); #ifdef DEBUG printf("MotionCVMain::process_buffer 2 rename tracking file: %s to %s\n", config.tracking_file, save_file); @@ -1039,79 +1039,37 @@ void MotionCVMain::draw_vectors(VFrame *frame) } } -void MotionCVMain::draw_pixel(VFrame *frame, int x, int y) -{ - if( !(x >= 0 && y >= 0 && x < frame->get_w() && y < frame->get_h()) ) - return; -#define DRAW_PIXEL(model, x, y, components, do_yuv, max, type) \ - case model: { \ - type **rows = (type**)frame->get_rows(); \ - rows[y][x * components] = max - rows[y][x * components]; \ - if( !do_yuv ) { \ - rows[y][x * components + 1] = max - rows[y][x * components + 1]; \ - rows[y][x * components + 2] = max - rows[y][x * components + 2]; \ - } \ - else { \ - rows[y][x * components + 1] = (max / 2 + 1) - rows[y][x * components + 1]; \ - rows[y][x * components + 2] = (max / 2 + 1) - rows[y][x * components + 2]; \ - } \ - if( components == 4 ) \ - rows[y][x * components + 3] = max; \ -} break +MotionCvVVFrame::MotionCvVVFrame(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; +} - switch( frame->get_color_model() ) { - DRAW_PIXEL(BC_RGB888,x, y, 3, 0, 0xff, unsigned char); - DRAW_PIXEL(BC_RGBA8888,x, y, 4, 0, 0xff, unsigned char); - DRAW_PIXEL(BC_RGB_FLOAT,x, y, 3, 0, 1.0, float); - DRAW_PIXEL(BC_RGBA_FLOAT,x, y, 4, 0, 1.0, float); - DRAW_PIXEL(BC_YUV888,x, y, 3, 1, 0xff, unsigned char); - DRAW_PIXEL(BC_YUVA8888,x, y, 4, 1, 0xff, unsigned char); - DRAW_PIXEL(BC_RGB161616,x, y, 3, 0, 0xffff, uint16_t); - DRAW_PIXEL(BC_YUV161616,x, y, 3, 1, 0xffff, uint16_t); - DRAW_PIXEL(BC_RGBA16161616,x, y, 4, 0, 0xffff, uint16_t); - DRAW_PIXEL(BC_YUVA16161616,x, y, 4, 1, 0xffff, uint16_t); +int MotionCvVVFrame::draw_pixel(int x, int y) +{ + VFrame::draw_pixel(x+0, y+0); + for( int i=1; i h ) { -// Flip coordinates so x1 < x2 - if( x2 < x1 ) { - y2 ^= y1; y1 ^= y2; y2 ^= y1; - x1 ^= x2; x2 ^= x1; x1 ^= x2; - } - int numerator = y2 - y1; - int denominator = x2 - x1; - for( int i = x1; i < x2; i++ ) { - int y = y1 + (int64_t) (i - x1) - * (int64_t) numerator / (int64_t) denominator; - draw_pixel(frame, i, y); - } - } - else { -// Flip coordinates so y1 < y2 - if( y2 < y1 ) { - y2 ^= y1; y1 ^= y2; y2 ^= y1; - x1 ^= x2; x2 ^= x1; x1 ^= x2; - } - int numerator = x2 - x1; - int denominator = y2 - y1; - for( int i = y1; i < y2; i++ ) { - int x = x1 + (int64_t) (i - y1) - * (int64_t) numerator / (int64_t) denominator; - draw_pixel(frame, x, i); - } - } -//printf("MotionCVMain::draw_line 2\n"); + int iw = frame->get_w(), ih = frame->get_h(); + int mx = iw > ih ? iw : ih; + int n = mx/800 + 1; + MotionCvVVFrame vfrm(frame, n); + vfrm.set_pixel_color(WHITE); + int m = 2; while( m < n ) m <<= 1; + vfrm.set_stiple(2*m); + vfrm.draw_line(x1,y1, x2,y2); } #define ARROW_SIZE 10 @@ -1320,7 +1278,7 @@ int MotionCVMain::put_cache_line(const char *line) 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);