[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39255] branches/soc-2011-tomato: Camera tracking integration
Sergey Sharybin
g.ulairi at gmail.com
Wed Aug 10 15:59:04 CEST 2011
Revision: 39255
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39255
Author: nazgul
Date: 2011-08-10 13:59:03 +0000 (Wed, 10 Aug 2011)
Log Message:
-----------
Camera tracking integration
===========================
- Fix for reading grease pencil data for movie clips.
- Request from Francois: undistort grease pencil to allow
manual calibration.
Only strokes made in "Cursor" space are getting undistorted,
strokes made in view space are kept unchanged.
This allows to make such workflow of manual calibration:
- Outline straight line in footage with GP.
- [Optional] mute footage.
- Enable Display->Manual Calibration.
- Tweak distortion coefficients until you'll like result.
- [Optional] Use strokes made in viewspace to help checking
of straightness of outlined features.
Not ideal but could be nice addition for grid-only calibration
until proper tools are getting ported to libmv/blender.
Modified Paths:
--------------
branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c
branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
branches/soc-2011-tomato/source/blender/makesdna/DNA_space_types.h
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_space.c
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c
Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py 2011-08-10 12:56:51 UTC (rev 39254)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py 2011-08-10 13:59:03 UTC (rev 39255)
@@ -355,6 +355,7 @@
layout.prop(sc, "lock_selection")
layout.prop(sc, "use_mute_footage")
+ layout.prop(sc, "use_manual_calibration")
clip = sc.clip
if clip:
Modified: branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c 2011-08-10 12:56:51 UTC (rev 39254)
+++ branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c 2011-08-10 13:59:03 UTC (rev 39255)
@@ -5708,8 +5708,6 @@
if(fd->movieclipmap) clip->cache= newmclipadr(fd, clip->cache);
else clip->cache= NULL;
- clip->gpd= newlibadr_us(fd, clip->id.lib, clip->gpd);
-
tracking->reconstruction.cameras= newdataadr(fd, tracking->reconstruction.cameras);
link_list(fd, &tracking->tracks);
@@ -5732,13 +5730,15 @@
clip->tracking.stabilization.scaleibuf= NULL;
}
-static void lib_link_movieclip(FileData *UNUSED(fd), Main *main)
+static void lib_link_movieclip(FileData *fd, Main *main)
{
MovieClip *clip;
clip= main->movieclip.first;
while(clip) {
if(clip->id.flag & LIB_NEEDLINK) {
+ clip->gpd= newlibadr_us(fd, clip->id.lib, clip->gpd);
+
clip->id.flag -= LIB_NEEDLINK;
}
clip= clip->id.next;
Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c 2011-08-10 12:56:51 UTC (rev 39254)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c 2011-08-10 13:59:03 UTC (rev 39255)
@@ -31,6 +31,7 @@
* \ingroup spclip
*/
+#include "DNA_gpencil_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h" /* SELECT */
@@ -776,51 +777,6 @@
*regiony= v2d->mask.ymin + y*(v2d->mask.ymax-v2d->mask.ymin);
}
-static void draw_distorion_grid(MovieTracking *tracking, int width, int height)
-{
- const int n= 9;
- int x, y;
- float pos[2], grid[10][10][2];
- float dx= (float)width/n, dy= (float)height/n;
-
- if(!tracking->camera.focal)
- return;
-
- zero_v2(pos);
-
- for(y= 0; y<=n; y++) {
- for(x= 0; x<=n; x++) {
- BKE_tracking_invert_intrinsics(tracking, pos, grid[y][x]);
-
- grid[y][x][0]/= width;
- grid[y][x][1]/= height;
-
- pos[0]+= dx;
- }
-
- pos[0]= 0.f;
- pos[1]+= dy;
- }
-
- glColor3f(1.f, 0.f, 0.f);
-
- for(y= 0; y<=n; y++) {
- glBegin(GL_LINE_STRIP);
- for(x= 0; x<=n; x++) {
- glVertex2fv(grid[y][x]);
- }
- glEnd();
- }
-
- for(x= 0; x<=n; x++) {
- glBegin(GL_LINE_STRIP);
- for(y= 0; y<=n; y++) {
- glVertex2fv(grid[y][x]);
- }
- glEnd();
- }
-}
-
static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
int width, int height, float zoomx, float zoomy)
{
@@ -954,9 +910,6 @@
glDisable(GL_POINT_SMOOTH);
}
- if(sc->flag&SC_SHOW_GRID)
- draw_distorion_grid(tracking, width, height);
-
glPopMatrix();
if(sc->flag&SC_SHOW_NAMES) {
@@ -980,10 +933,102 @@
glPopMatrix();
}
-static void draw_tracking(SpaceClip *sc, ARegion *ar, MovieClip *clip,
- int width, int height, float zoomx, float zoomy)
+static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int width, int height, float zoomx, float zoomy)
{
- draw_tracking_tracks(sc, ar, clip, width, height, zoomx, zoomy);
+ float x, y;
+ const int n= 9;
+ int i, j;
+ float pos[2], grid[10][10][2];
+ float dx= (float)width/n, dy= (float)height/n;
+ MovieTracking *tracking= &clip->tracking;
+
+ if(!tracking->camera.focal)
+ return;
+
+ if((sc->flag&SC_SHOW_GRID)==0 && (sc->flag&SC_MANUAL_CALIBRATION)==0)
+ return;
+
+ view2d_to_region_float(&ar->v2d, 0.0f, 0.0f, &x, &y);
+
+ glPushMatrix();
+ glTranslatef(x, y, 0);
+ glScalef(zoomx, zoomy, 0);
+ glMultMatrixf(sc->stabmat);
+ glScalef(width, height, 0);
+
+ /* grid */
+ if(sc->flag&SC_SHOW_GRID) {
+ zero_v2(pos);
+
+ for(i= 0; i<=n; i++) {
+ for(j= 0; j<=n; j++) {
+ BKE_tracking_invert_intrinsics(tracking, pos, grid[i][j]);
+
+ grid[i][j][0]/= width;
+ grid[i][j][1]/= height;
+
+ pos[0]+= dx;
+ }
+
+ pos[0]= 0.f;
+ pos[1]+= dy;
+ }
+
+ glColor3f(1.f, 0.f, 0.f);
+
+ for(i= 0; i<=n; i++) {
+ glBegin(GL_LINE_STRIP);
+ for(j= 0; j<=n; j++) {
+ glVertex2fv(grid[i][j]);
+ }
+ glEnd();
+ }
+
+ for(j= 0; j<=n; j++) {
+ glBegin(GL_LINE_STRIP);
+ for(i= 0; i<=n; i++) {
+ glVertex2fv(grid[i][j]);
+ }
+ glEnd();
+ }
+ }
+
+ if(sc->flag&SC_MANUAL_CALIBRATION && clip->gpd) {
+ bGPDlayer *layer= clip->gpd->layers.first;
+
+ glColor4fv(layer->color);
+ glLineWidth(layer->thickness);
+ while(layer) {
+ bGPDframe *frame= layer->frames.first;
+ while(frame) {
+ bGPDstroke *stroke= frame->strokes.first;
+
+ while(stroke) {
+ if(stroke->flag&GP_STROKE_2DSPACE && stroke->totpoints>1) {
+ glBegin(GL_LINE_STRIP);
+ for(i= 0; i<stroke->totpoints-1; i++) {
+ pos[0]= stroke->points[i].x*width;
+ pos[1]= stroke->points[i].y*height;
+
+ BKE_tracking_apply_intrinsics(tracking, pos, pos);
+ glVertex2f(pos[0]/width, pos[1]/height);
+ }
+ glEnd();
+ }
+
+ stroke= stroke->next;
+ }
+
+ frame= frame->next;
+ }
+
+ layer= layer->next;
+ }
+
+ glLineWidth(1.f);
+ }
+
+ glPopMatrix();
}
void draw_clip_main(SpaceClip *sc, ARegion *ar, Scene *scene)
@@ -1015,7 +1060,8 @@
draw_movieclip_buffer(sc, ar, ibuf, width, height, zoomx, zoomy);
IMB_freeImBuf(ibuf);
- draw_tracking(sc, ar, clip, width, height, zoomx, zoomy);
+ draw_tracking_tracks(sc, ar, clip, width, height, zoomx, zoomy);
+ draw_distortion(sc, ar, clip, width, height, zoomx, zoomy);
}
draw_movieclip_cache(sc, ar, clip, scene);
@@ -1032,12 +1078,16 @@
return;
if(onlyv2d) {
- ibuf= ED_space_clip_acquire_buffer(sc);
+ /* if manual calibration is used then grase pencil data is already
+ drawed in draw_distortion */
+ if((sc->flag&SC_MANUAL_CALIBRATION)==0) {
+ ibuf= ED_space_clip_acquire_buffer(sc);
- if(ibuf) {
- draw_gpencil_2dimage(C, ibuf);
+ if(ibuf) {
+ draw_gpencil_2dimage(C, ibuf);
- IMB_freeImBuf(ibuf);
+ IMB_freeImBuf(ibuf);
+ }
}
} else {
draw_gpencil_view2d(C, 0);
Modified: branches/soc-2011-tomato/source/blender/makesdna/DNA_space_types.h
===================================================================
--- branches/soc-2011-tomato/source/blender/makesdna/DNA_space_types.h 2011-08-10 12:56:51 UTC (rev 39254)
+++ branches/soc-2011-tomato/source/blender/makesdna/DNA_space_types.h 2011-08-10 13:59:03 UTC (rev 39255)
@@ -980,6 +980,7 @@
#define SC_SHOW_NAMES (1<<8)
#define SC_SHOW_GRID (1<<9)
#define SC_SHOW_STABLE (1<<10)
+#define SC_MANUAL_CALIBRATION (1<<11)
/* space types, moved from DNA_screen_types.h */
Modified: branches/soc-2011-tomato/source/blender/makesrna/intern/rna_space.c
===================================================================
--- branches/soc-2011-tomato/source/blender/makesrna/intern/rna_space.c 2011-08-10 12:56:51 UTC (rev 39254)
+++ branches/soc-2011-tomato/source/blender/makesrna/intern/rna_space.c 2011-08-10 13:59:03 UTC (rev 39255)
@@ -2739,6 +2739,12 @@
RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_STABLE);
RNA_def_property_ui_text(prop, "Show Stable", "Show stable footage in editor (if stabilization is enabled)");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL);
+
+ /* manual calibration */
+ prop= RNA_def_property(srna, "use_manual_calibration", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_MANUAL_CALIBRATION);
+ RNA_def_property_ui_text(prop, "Manual Calibration", "Use manual calibration helpers");
+ RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL);
}
Modified: branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c 2011-08-10 12:56:51 UTC (rev 39254)
+++ branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c 2011-08-10 13:59:03 UTC (rev 39255)
@@ -300,19 +300,19 @@
/* Radial distortion parameters */
prop= RNA_def_property(srna, "k1", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "k1");
- RNA_def_property_ui_range(prop, 0, 10, .1, 3);
+ RNA_def_property_ui_range(prop, -10, 10, .1, 3);
RNA_def_property_ui_text(prop, "K1", "");
RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
prop= RNA_def_property(srna, "k2", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "k2");
- RNA_def_property_ui_range(prop, 0, 10, .1, 3);
+ RNA_def_property_ui_range(prop, -10, 10, .1, 3);
RNA_def_property_ui_text(prop, "K2", "");
RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
prop= RNA_def_property(srna, "k3", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "k3");
- RNA_def_property_ui_range(prop, 0, 10, .1, 3);
+ RNA_def_property_ui_range(prop, -10, 10, .1, 3);
RNA_def_property_ui_text(prop, "K3", "");
RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
More information about the Bf-blender-cvs
mailing list