diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-01-04 19:25:43 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-01-04 19:25:43 +0400 |
commit | a4604c457dd422f0c9745062dad762dfbc09fdaf (patch) | |
tree | e2ecdc594d906cd554e3f1fd894b90d62ad9f14a /source/blender/blenkernel | |
parent | 49cf3c76a93c8e41ddbece82f629e90c21651d19 (diff) |
Camera tracking: more accurate track preview widget
- Added 1px extra margin to deal with bicubic interpolation nicely
- Code should be a bit more clear now
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/movieclip.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/tracking.c | 33 |
2 files changed, 25 insertions, 12 deletions
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index ab963f1e78c..4c78ab13874 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -860,7 +860,9 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip undist_marker.pos[1]/= height*aspy; } - tmpibuf= BKE_tracking_get_pattern_imbuf(ibuf, track, &undist_marker, 1, 1, scopes->track_pos, NULL); + /* NOTE: margin should be kept in sync with value from ui_draw_but_TRACKPREVIEW */ + tmpibuf= BKE_tracking_get_pattern_imbuf(ibuf, track, &undist_marker, 2 /* margin */, + 1 /* anchor */, scopes->track_pos, NULL); if(tmpibuf->rect_float) IMB_rect_from_float(tmpibuf); diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 7bfc7a8ef87..ff76fc14755 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -999,17 +999,24 @@ static ImBuf *get_area_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTracki if(anchored) add_v2_v2(mpos, track->offset); + if(pos) + zero_v2(pos); + x= mpos[0]*ibuf->x; y= mpos[1]*ibuf->y; - x1= x-(int)(-min[0]*ibuf->x); - y1= y-(int)(-min[1]*ibuf->y); - x2= x+(int)(max[0]*ibuf->x); - y2= y+(int)(max[1]*ibuf->y); - /* dimensions should be odd */ - w= (x2-x1)|1; - h= (y2-y1)|1; + w= (max[0]-min[0])*ibuf->x; + h= (max[1]-min[1])*ibuf->y; + + w= w|1; + h= h|1; + x1= x-(int)(w/2.0f); + y1= y-(int)(h/2.0f); + x2= x+(int)(w/2.0f); + y2= y+(int)(h/2.0f); + + /* dimensions should be odd */ tmpibuf= IMB_allocImBuf(w+margin*2, h+margin*2, 32, IB_rect); IMB_rectcpy(tmpibuf, ibuf, 0, 0, x1-margin, y1-margin, w+margin*2, h+margin*2); @@ -1023,13 +1030,17 @@ static ImBuf *get_area_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTracki origin[1]= y1-margin; } - if ((track->flag & TRACK_PREVIEW_GRAYSCALE) || - (track->flag & TRACK_DISABLE_RED) || - (track->flag & TRACK_DISABLE_GREEN) || - (track->flag & TRACK_DISABLE_BLUE) ) { + if((track->flag & TRACK_PREVIEW_GRAYSCALE) || + (track->flag & TRACK_DISABLE_RED) || + (track->flag & TRACK_DISABLE_GREEN) || + (track->flag & TRACK_DISABLE_BLUE)) + { disable_imbuf_channels(tmpibuf, track, 1 /* grayscale */); } + tmpibuf->ftype= PNG; + IMB_saveiff(tmpibuf, "/tmp/1.png", IB_rect); + return tmpibuf; } |