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

Sergey Sharybin g.ulairi at gmail.com
Mon Jul 11 19:13:27 CEST 2011


Revision: 38311
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38311
Author:   nazgul
Date:     2011-07-11 17:13:27 +0000 (Mon, 11 Jul 2011)
Log Message:
-----------
Camera tracking integration
===========================

- Fixed incorrect usage of RNA structure for
  CameraSolverConstraint.
- Fixed some typos in object_constraint which were
  casting CameraSolver data to FollowTrack data.
- Tracking-related constraints now have got option
  "Use Defult Clip" which makes them use clip set as
  active for scene. Enabled by default.
- Set active blender camera focal length after reconstruction.
- Corrected offset of sequence images. Now first image from sequence
  should be at scene frame 1.

Modified Paths:
--------------
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/properties_object_constraint.py
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
    branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
    branches/soc-2011-tomato/source/blender/editors/object/object_constraint.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h
    branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c
    branches/soc-2011-tomato/source/blender/makesdna/DNA_constraint_types.h
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_constraint.c

Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/properties_object_constraint.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/properties_object_constraint.py	2011-07-11 16:58:16 UTC (rev 38310)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/properties_object_constraint.py	2011-07-11 17:13:27 UTC (rev 38311)
@@ -752,15 +752,22 @@
         col.prop(con, "rotation_range", text="Pivot When")
 
     def FOLLOW_TRACK(self, context, layout, con):
-        layout.prop(con, "clip")
+        layout.prop(con, "use_default_clip")
+
+        if not con.use_default_clip:
+            layout.prop(con, "clip")
+
         layout.prop(con, "track")
 
         row = layout.row()
         row.prop(con, "reference", expand=True)
 
     def CAMERA_SOLVER(self, context, layout, con):
-        layout.prop(con, "clip")
+        layout.prop(con, "use_default_clip")
 
+        if not con.use_default_clip:
+            layout.prop(con, "clip")
+
     def SCRIPT(self, context, layout, con):
         layout.label("Blender 2.5 has no py-constraints")
 

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-07-11 16:58:16 UTC (rev 38310)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py	2011-07-11 17:13:27 UTC (rev 38311)
@@ -127,6 +127,8 @@
             op = col.operator("clip.clear_track_path", text="Clear Track Path")
             op.action = 'ALL'
 
+            layout.operator("clip.apply_follow_track")
+
             col = layout.column(align=True)
             col.label(text="Reconstruction:")
             col.operator("clip.solve_camera")
@@ -257,20 +259,6 @@
         layout.prop(sc, "use_mute_footage")
 
 
-class CLIP_PT_test(bpy.types.Panel):
-    bl_space_type = 'CLIP_EDITOR'
-    bl_region_type = 'TOOLS'
-    bl_label = "Test"
-    bl_options = {'DEFAULT_CLOSED'}
-
-    def draw(self, context):
-        layout = self.layout
-        sc = context.space_data
-
-        layout.operator("clip.apply_follow_track")
-        layout.operator("clip.track_to_fcurves")
-
-
 class CLIP_PT_footage(bpy.types.Panel):
     bl_space_type = 'CLIP_EDITOR'
     bl_region_type = 'UI'

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c	2011-07-11 16:58:16 UTC (rev 38310)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c	2011-07-11 17:13:27 UTC (rev 38311)
@@ -3940,6 +3940,7 @@
 	bFollowTrackConstraint *data= (bFollowTrackConstraint *)cdata;
 
 	data->clip= NULL;
+	data->flag|= FOLLOWTRACK_DEFAULTCLIP;
 }
 
 static void followtrack_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
@@ -3953,13 +3954,16 @@
 {
 	Scene *scene= cob->scene;
 	bFollowTrackConstraint *data= con->data;
-	MovieClip *clip= data->clip ? data->clip : scene->clip;
+	MovieClip *clip= data->clip;
 	MovieClipUser user;
 	MovieTrackingTrack *track;
 	MovieTrackingMarker *marker;
 	float tx, ty;
 	int width, height;
 
+	if(data->flag&FOLLOWTRACK_DEFAULTCLIP)
+		clip= scene->clip;
+
 	if(!clip || !data->track[0])
 		return;
 
@@ -3968,7 +3972,7 @@
 	if(!track)
 		return;
 
-	if(data->flag&FOLLOWTRACK_BUNDLE) {
+	if(data->reference==FOLLOWTRACK_BUNDLE) {
 		if(track->flag&TRACK_HAS_BUNDLE) {
 			float pos[3], mat[4][4], obmat[4][4];
 
@@ -4017,6 +4021,7 @@
 	bCameraSolverConstraint *data= (bCameraSolverConstraint *)cdata;
 
 	data->clip= NULL;
+	data->flag|= CAMERASOLVER_DEFAULTCLIP;
 }
 
 static void camerasolver_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
@@ -4030,9 +4035,12 @@
 {
 	Scene *scene= cob->scene;
 	bCameraSolverConstraint *data= con->data;
-	MovieClip *clip= data->clip ? data->clip : scene->clip;
+	MovieClip *clip= data->clip;
 	MovieReconstructedCamera *camera;
 
+	if(data->flag&CAMERASOLVER_DEFAULTCLIP)
+		clip= scene->clip;
+
 	if(clip) {
 		camera= BKE_tracking_get_reconstructed_camera(&clip->tracking, scene->r.cfra);
 

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c	2011-07-11 16:58:16 UTC (rev 38310)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c	2011-07-11 17:13:27 UTC (rev 38311)
@@ -99,7 +99,7 @@
 	   autoguess offset for now. could be something smarter in the future */
 	offset= sequence_guess_offset(clip->name, strlen(head), numlen);
 
-	if(numlen) BLI_stringenc(name, head, tail, numlen, offset+framenr);
+	if(numlen) BLI_stringenc(name, head, tail, numlen, offset+framenr-1);
 	else strncpy(name, clip->name, sizeof(name));
 
 	if(clip->id.lib)

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c	2011-07-11 16:58:16 UTC (rev 38310)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c	2011-07-11 17:13:27 UTC (rev 38311)
@@ -377,7 +377,7 @@
 	MovieTrackingTrack *track;
 
 #ifdef WITH_LIBMV
-	context->region_tracker= libmv_regionTrackerNew(100, 4, 0.2);
+	context->region_tracker= libmv_regionTrackerNew(100, 7, 0.2);
 #endif
 
 	context->settings= *settings;

Modified: branches/soc-2011-tomato/source/blender/editors/object/object_constraint.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/object/object_constraint.c	2011-07-11 16:58:16 UTC (rev 38310)
+++ branches/soc-2011-tomato/source/blender/editors/object/object_constraint.c	2011-07-11 17:13:27 UTC (rev 38311)
@@ -408,16 +408,18 @@
 			else if (curcon->type == CONSTRAINT_TYPE_FOLLOWTRACK) {
 				bFollowTrackConstraint *data = curcon->data;
 
-				if(data->clip != NULL && data->track[0]) {
-					if (!BKE_find_track_by_name(&data->clip->tracking, data->track))
-						curcon->flag |= CONSTRAINT_DISABLE;
+				if((data->flag&CAMERASOLVER_DEFAULTCLIP)==0) {
+					if(data->clip != NULL && data->track[0]) {
+						if (!BKE_find_track_by_name(&data->clip->tracking, data->track))
+							curcon->flag |= CONSTRAINT_DISABLE;
+					}
+					else curcon->flag |= CONSTRAINT_DISABLE;
 				}
-				else curcon->flag |= CONSTRAINT_DISABLE;
 			}
 			else if (curcon->type == CONSTRAINT_TYPE_CAMERASOLVER) {
-				bFollowTrackConstraint *data = curcon->data;
+				bCameraSolverConstraint *data = curcon->data;
 
-				if(data->clip == NULL)
+				if((data->flag&CAMERASOLVER_DEFAULTCLIP)==0 && data->clip == NULL)
 					curcon->flag |= CONSTRAINT_DISABLE;
 			}
 			
@@ -1382,26 +1384,6 @@
 			break;
 		}
 
-		case CONSTRAINT_TYPE_FOLLOWTRACK:
-		{
-			bFollowTrackConstraint *data= con->data;
-
-			if(data->clip == NULL)
-				data->clip= scene->clip;
-
-			break;
-		}
-
-		case CONSTRAINT_TYPE_CAMERASOLVER:
-		{
-			bCameraSolverConstraint *data= con->data;
-
-			if(data->clip == NULL)
-				data->clip= scene->clip;
-
-			break;
-		}
-
 		default:
 			break;
 	}

Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h	2011-07-11 16:58:16 UTC (rev 38310)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h	2011-07-11 17:13:27 UTC (rev 38311)
@@ -81,8 +81,6 @@
 
 void CLIP_OT_slide_marker(struct wmOperatorType *ot);
 
-void CLIP_OT_track_to_fcurves(struct wmOperatorType *ot);
-
 /* clip_draw.c */
 void draw_clip_main(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene);
 void draw_clip_track_widget(const struct bContext *C, void *trackp, void *userp, void *clipp, rcti *rect);

Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c	2011-07-11 16:58:16 UTC (rev 38310)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c	2011-07-11 17:13:27 UTC (rev 38311)
@@ -219,8 +219,6 @@
 	WM_operatortype_append(CLIP_OT_clear_track_path);
 
 	WM_operatortype_append(CLIP_OT_slide_marker);
-
-	WM_operatortype_append(CLIP_OT_track_to_fcurves);
 }
 
 static void clip_keymap(struct wmKeyConfig *keyconf)

Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c	2011-07-11 16:58:16 UTC (rev 38310)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c	2011-07-11 17:13:27 UTC (rev 38311)
@@ -29,10 +29,10 @@
 
 #include "MEM_guardedalloc.h"
 
+#include "DNA_camera_types.h"
 #include "DNA_movieclip_types.h"
 #include "DNA_object_types.h"	/* SELECT */
 #include "DNA_scene_types.h"
-#include "DNA_anim_types.h"
 
 #include "BLI_utildefines.h"
 #include "BLI_math.h"
@@ -45,8 +45,8 @@
 #include "BKE_movieclip.h"
 #include "BKE_tracking.h"
 #include "BKE_global.h"
-#include "BKE_animsys.h"
 #include "BKE_depsgraph.h"
+#include "BKE_report.h"
 #include "BKE_scene.h"
 
 #include "WM_api.h"
@@ -997,16 +997,40 @@
 
 /********************** solve camera operator *********************/
 
-static int solve_camera_exec(bContext *C, wmOperator *UNUSED(op))
+static int solve_camera_exec(bContext *C, wmOperator *op)
 {
 	SpaceClip *sc= CTX_wm_space_clip(C);
 	MovieClip *clip= ED_space_clip(sc);
 	Scene *scene= CTX_data_scene(C);
 
+	if(BLI_countlist(&clip->tracking.tracks)<10) {
+		BKE_report(op->reports, RPT_ERROR, "At least 10 tracks are needed for reconstruction");
+	}
+
 	BKE_tracking_solve_reconstruction(clip);
 
 	scene->clip= clip;
 
+	if(!scene->camera)
+		scene->camera= scene_find_camera(scene);
+
+	if(scene->camera) {
+		float focal= clip->tracking.camera.focal;
+
+		/* set blender camera focal length so result would look fine there */
+		if(focal) {
+			int width, height;
+			Camera *camera= (Camera*)scene->camera->data;
+
+			BKE_movieclip_approx_size(clip, &width, &height);
+
+			if(width)
+				camera->lens= focal*32.0f/(float)width;
+

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list