[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41114] branches/soc-2011-tomato: Camera tracking integration

Sergey Sharybin g.ulairi at gmail.com
Wed Oct 19 14:46:31 CEST 2011


Revision: 41114
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41114
Author:   nazgul
Date:     2011-10-19 12:46:30 +0000 (Wed, 19 Oct 2011)
Log Message:
-----------
Camera tracking integration
===========================

Initial implementation of graph view for movie tracking data.
Used the same UI-side approach as preview region for sequencer:
create region for graph-related information inside clip editor.

It's easier and nicer than trying to hack graph editor which is
currently designed to work with AnimData only. Trying to make it
more abstract to deal with any kind of data doesn't seem be real
benefit for now.

Currently supported displaying per-frame average error and
selected tracks' movement speed (pixels per frame).

Additional changes:
- Collect per-frame average error after solving.
- Split space clip drawing code into different files.
- Added per-frame average solving error.

Modified Paths:
--------------
    branches/soc-2011-tomato/extern/libmv/libmv-capi.cpp
    branches/soc-2011-tomato/extern/libmv/libmv-capi.h
    branches/soc-2011-tomato/release/scripts/modules/bpy_extras/keyconfig_utils.py
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
    branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
    branches/soc-2011-tomato/source/blender/editors/interface/resources.c
    branches/soc-2011-tomato/source/blender/editors/screen/screen_ops.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/CMakeLists.txt
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_ops.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c
    branches/soc-2011-tomato/source/blender/makesdna/DNA_space_types.h
    branches/soc-2011-tomato/source/blender/makesdna/DNA_tracking_types.h
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_space.c
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_userdef.c

Added Paths:
-----------
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw_graph.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw_main.c

Removed Paths:
-------------
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c

Modified: branches/soc-2011-tomato/extern/libmv/libmv-capi.cpp
===================================================================
--- branches/soc-2011-tomato/extern/libmv/libmv-capi.cpp	2011-10-19 00:41:48 UTC (rev 41113)
+++ branches/soc-2011-tomato/extern/libmv/libmv-capi.cpp	2011-10-19 12:46:30 UTC (rev 41114)
@@ -457,6 +457,37 @@
 	return total_error / num_reprojected;
 }
 
+double libmv_reporojectionErrorForImage(libmv_Reconstruction *libmv_reconstruction, int image)
+{
+	libmv::EuclideanReconstruction *reconstruction = &libmv_reconstruction->reconstruction;
+	libmv::CameraIntrinsics *intrinsics = &libmv_reconstruction->intrinsics;
+	libmv::vector<libmv::Marker> markers = libmv_reconstruction->tracks.MarkersInImage(image);
+	const libmv::EuclideanCamera *camera = reconstruction->CameraForImage(image);
+	int num_reprojected = 0;
+	double total_error = 0.0;
+
+	if (!camera)
+		return 0;
+
+	for (int i = 0; i < markers.size(); ++i) {
+		const libmv::EuclideanPoint *point = reconstruction->PointForTrack(markers[i].track);
+
+		if (!point) {
+			continue;
+		}
+
+		num_reprojected++;
+
+		libmv::Marker reprojected_marker = ProjectMarker(*point, *camera, *intrinsics);
+		double ex = reprojected_marker.x - markers[i].x;
+		double ey = reprojected_marker.y - markers[i].y;
+
+		total_error += sqrt(ex*ex + ey*ey);
+	}
+
+	return total_error / num_reprojected;
+}
+
 int libmv_reporojectionCameraForImage(libmv_Reconstruction *libmv_reconstruction, int image, double mat[4][4])
 {
 	libmv::EuclideanReconstruction *reconstruction = &libmv_reconstruction->reconstruction;

Modified: branches/soc-2011-tomato/extern/libmv/libmv-capi.h
===================================================================
--- branches/soc-2011-tomato/extern/libmv/libmv-capi.h	2011-10-19 00:41:48 UTC (rev 41113)
+++ branches/soc-2011-tomato/extern/libmv/libmv-capi.h	2011-10-19 12:46:30 UTC (rev 41114)
@@ -67,6 +67,7 @@
 			double focal_length, double principal_x, double principal_y, double k1, double k2, double k3);
 int libmv_reporojectionPointForTrack(struct libmv_Reconstruction *libmv_reconstruction, int track, double pos[3]);
 double libmv_reporojectionErrorForTrack(struct libmv_Reconstruction *libmv_reconstruction, int track);
+double libmv_reporojectionErrorForImage(struct libmv_Reconstruction *libmv_reconstruction, int image);
 int libmv_reporojectionCameraForImage(struct libmv_Reconstruction *libmv_reconstruction, int image, double mat[4][4]);
 double libmv_reprojectionError(struct libmv_Reconstruction *libmv_reconstruction);
 void libmv_destroyReconstruction(struct libmv_Reconstruction *libmv_reconstruction);

Modified: branches/soc-2011-tomato/release/scripts/modules/bpy_extras/keyconfig_utils.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/modules/bpy_extras/keyconfig_utils.py	2011-10-19 00:41:48 UTC (rev 41113)
+++ branches/soc-2011-tomato/release/scripts/modules/bpy_extras/keyconfig_utils.py	2011-10-19 12:46:30 UTC (rev 41114)
@@ -94,6 +94,7 @@
     ('Console', 'CONSOLE', 'WINDOW', []),
     ('Clip', 'CLIP_EDITOR', 'WINDOW', [
         ('Clip Editor', 'CLIP_EDITOR', 'WINDOW', []),
+        ('Clip Graph Editor', 'CLIP_EDITOR', 'WINDOW', []),
         ]),
 
     ('View3D Gesture Circle', 'EMPTY', 'WINDOW', []),

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-10-19 00:41:48 UTC (rev 41113)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py	2011-10-19 12:46:30 UTC (rev 41114)
@@ -45,7 +45,18 @@
 
         if clip:
             layout.prop(sc, "mode", text="")
+            layout.prop(sc, "view", text="", expand=True)
 
+            if sc.view == 'GRAPH':
+                row = layout.row(align=True)
+
+                if sc.show_filters:
+                    row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_DOWN', text="Filters")
+                    row.prop(sc, "show_graph_frames", icon='SEQUENCE', text="")
+                    row.prop(sc, "show_graph_tracks", icon='ANIM', text="")
+                else:
+                    row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_RIGHT', text="Filters")
+
         row = layout.row()
         row.template_ID(sc, "clip", open='clip.open')
 
@@ -891,6 +902,5 @@
 
         layout.operator('clip.stabilize_2d_select')
 
-
 if __name__ == "__main__":  # only for live edit.
     bpy.utils.register_module(__name__)

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c	2011-10-19 00:41:48 UTC (rev 41113)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c	2011-10-19 12:46:30 UTC (rev 41114)
@@ -1235,6 +1235,7 @@
 		if(libmv_reporojectionCameraForImage(libmv_reconstruction, a, matd)) {
 			int i, j;
 			float mat[4][4];
+			float error= libmv_reporojectionErrorForImage(libmv_reconstruction, a);
 
 			for(i=0; i<4; i++)
 				for(j= 0; j<4; j++)
@@ -1250,6 +1251,7 @@
 
 			copy_m4_m4(reconstructed[reconstruction->camnr].mat, mat);
 			reconstructed[reconstruction->camnr].framenr= a;
+			reconstructed[reconstruction->camnr].error= error;
 			reconstruction->camnr++;
 		} else {
 			ok= 0;

Modified: branches/soc-2011-tomato/source/blender/editors/interface/resources.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/interface/resources.c	2011-10-19 00:41:48 UTC (rev 41113)
+++ branches/soc-2011-tomato/source/blender/editors/interface/resources.c	2011-10-19 12:46:30 UTC (rev 41114)
@@ -842,6 +842,8 @@
 	SETCOL(btheme->tclip.lock_marker, 0x7f, 0x7f, 0x7f, 255);
 	SETCOL(btheme->tclip.path_before, 0xff, 0x00, 0x00, 255);
 	SETCOL(btheme->tclip.path_after, 0x00, 0x00, 0xff, 255);
+	SETCOL(btheme->tclip.grid, 0x5e, 0x5e, 0x5e, 255);
+	SETCOL(btheme->tclip.cframe, 0x60, 0xc0, 0x40, 255);
 }
 
 
@@ -1671,6 +1673,8 @@
 				SETCOL(btheme->tclip.lock_marker, 0x7f, 0x7f, 0x7f, 255);
 				SETCOL(btheme->tclip.path_before, 0xff, 0x00, 0x00, 255);
 				SETCOL(btheme->tclip.path_after, 0x00, 0x00, 0xff, 255);
+				SETCOL(btheme->tclip.grid, 0x5e, 0x5e, 0x5e, 255);
+				SETCOL(btheme->tclip.cframe, 0x60, 0xc0, 0x40, 255);
 			}
 		}
 	}

Modified: branches/soc-2011-tomato/source/blender/editors/screen/screen_ops.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/screen/screen_ops.c	2011-10-19 00:41:48 UTC (rev 41113)
+++ branches/soc-2011-tomato/source/blender/editors/screen/screen_ops.c	2011-10-19 12:46:30 UTC (rev 41114)
@@ -2804,6 +2804,8 @@
 				if(redraws & (TIME_SEQ|TIME_ALL_ANIM_WIN))
 					return 1;
 				break;
+			case SPACE_CLIP:
+				return 1;
 		}
 	}
 	return 0;

Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/CMakeLists.txt
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/CMakeLists.txt	2011-10-19 00:41:48 UTC (rev 41113)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/CMakeLists.txt	2011-10-19 12:46:30 UTC (rev 41114)
@@ -41,7 +41,8 @@
 
 set(SRC
 	space_clip.c
-	clip_draw.c
+	clip_draw_graph.c
+	clip_draw_main.c
 	clip_toolbar.c
 	clip_ops.c
 	tracking_ops.c

Deleted: 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-10-19 00:41:48 UTC (rev 41113)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c	2011-10-19 12:46:30 UTC (rev 41114)
@@ -1,1262 +0,0 @@
-/*
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2011 Blender Foundation.
- * All rights reserved.
- *
- *
- * Contributor(s): Blender Foundation,
- *                 Sergey Sharybin
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/space_clip/clip_draw.c
- *  \ingroup spclip
- */
-
-#include "DNA_gpencil_types.h"
-#include "DNA_movieclip_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_object_types.h"	/* SELECT */
-
-#include "MEM_guardedalloc.h"
-
-#include "BKE_context.h"
-#include "BKE_movieclip.h"
-#include "BKE_tracking.h"
-
-#include "IMB_imbuf_types.h"
-#include "IMB_imbuf.h"
-
-#include "BLI_utildefines.h"
-#include "BLI_math.h"
-#include "BLI_string.h"
-#include "BLI_rect.h"
-#include "BLI_math_base.h"
-
-#include "ED_screen.h"
-#include "ED_clip.h"
-#include "ED_gpencil.h"
-
-#include "BIF_gl.h"
-#include "BIF_glutil.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "UI_resources.h"
-#include "UI_view2d.h"
-
-#include "RNA_access.h"
-
-#include "BLF_api.h"
-
-#include "clip_intern.h"	// own include
-
-/*********************** main area drawing *************************/
-
-static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Scene *scene)
-{
-	float x;
-	int *points, totseg, i, a;
-	float sfra= SFRA, efra= EFRA, framelen= ar->winx/(efra-sfra+1), fontsize, fontwidth;
-	uiStyle *style= U.uistyles.first;
-	int fontid= style->widget.uifont_id;
-	char str[32];
-
-	glEnable(GL_BLEND);
-
-	/* cache background */
-	glColor4ub(128, 128, 255, 64);
-	glRecti(0, 0, ar->winx, 8);
-
-	/* cached segments -- could be usefu lto debug caching strategies */
-	BKE_movieclip_get_cache_segments(clip, &sc->user, &totseg, &points);
-	if(totseg) {
-		glColor4ub(128, 128, 255, 128);
-
-		for(a= 0; a<totseg; a++) {
-			float x1, x2;
-

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list