[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41285] branches/soc-2011-tomato/source/ blender: Camera tracking integration
Sergey Sharybin
g.ulairi at gmail.com
Tue Oct 25 21:06:54 CEST 2011
Revision: 41285
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41285
Author: nazgul
Date: 2011-10-25 19:06:53 +0000 (Tue, 25 Oct 2011)
Log Message:
-----------
Camera tracking integration
===========================
More fixes for reports from codereview.
Modified Paths:
--------------
branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h
branches/soc-2011-tomato/source/blender/blenkernel/intern/depsgraph.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/makesdna/DNA_movieclip_types.h
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c
Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h 2011-10-25 18:30:09 UTC (rev 41284)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h 2011-10-25 19:06:53 UTC (rev 41285)
@@ -98,7 +98,7 @@
struct ImBuf *BKE_tracking_stabilize(struct MovieTracking *tracking, int framenr, struct ImBuf *ibuf, float loc[2], float *scale, float *angle);
void BKE_tracking_stabdata_to_mat4(int width, int height, float loc[2], float scale, float angle, float mat[4][4]);
-/* Distoriton/Undistortion */
+/* Distortion/Undistortion */
struct MovieDistortion *BKE_tracking_distortion_create(void);
struct MovieDistortion *BKE_tracking_distortion_copy(struct MovieDistortion *distortion);
struct ImBuf *BKE_tracking_distortion_exec(struct MovieDistortion *distortion, struct MovieTracking *tracking,
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/depsgraph.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/depsgraph.c 2011-10-25 18:30:09 UTC (rev 41284)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/depsgraph.c 2011-10-25 19:06:53 UTC (rev 41285)
@@ -2030,18 +2030,6 @@
flush_pointcache_reset(sce, itA->node, lasttime, 0);
}
}
-
- /* also all objects which are parented to tracking data should be re-calculated */
- for(ob=bmain->object.first; ob; ob= ob->id.next){
- bConstraint *con;
- for (con = ob->constraints.first; con; con=con->next) {
- bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
- if(ELEM(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER)) {
- ob->recalc |= OB_RECALC_OB;
- break;
- }
- }
- }
}
dag_tag_renderlayers(sce, lay);
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c 2011-10-25 18:30:09 UTC (rev 41284)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c 2011-10-25 19:06:53 UTC (rev 41285)
@@ -48,10 +48,13 @@
#include "MEM_guardedalloc.h"
+#include "DNA_constraint_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_movieclip_types.h"
-#include "DNA_object_types.h" /* SELECT */
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_view3d_types.h"
#include "BLI_utildefines.h"
@@ -61,6 +64,7 @@
#include "BLI_mempool.h"
#include "BLI_threads.h"
+#include "BKE_constraint.h"
#include "BKE_library.h"
#include "BKE_global.h"
#include "BKE_main.h"
@@ -79,7 +83,7 @@
{
char num[FILE_MAX]= {0};
- strncpy(num, full_name+head_len, numlen);
+ BLI_strncpy(num, full_name+head_len, numlen);
return atoi(num);
}
@@ -259,7 +263,7 @@
/*********************** image buffer cache *************************/
typedef struct MovieClipCache {
- /* regular moive cache */
+ /* regular movie cache */
struct MovieCache *moviecache;
/* cache for stable shot */
@@ -1004,21 +1008,56 @@
bScreen *scr;
ScrArea *area;
SpaceLink *sl;
+ Scene *sce;
+ Object *ob;
- /* text space */
for(scr= bmain->screen.first; scr; scr= scr->id.next) {
for(area= scr->areabase.first; area; area= area->next) {
for(sl= area->spacedata.first; sl; sl= sl->next) {
if(sl->spacetype==SPACE_CLIP) {
- SpaceClip *sc= (SpaceClip*) sl;
+ SpaceClip *sc= (SpaceClip *) sl;
- if(sc->clip==clip) {
+ if(sc->clip==clip)
sc->clip= NULL;
+ }
+ else if(sl->spacetype==SPACE_VIEW3D) {
+ View3D *v3d= (View3D *) sl;
+ BGpic *bgpic;
+
+ for(bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) {
+ if(bgpic->clip==clip)
+ bgpic->clip= NULL;
}
}
}
}
}
+ for(sce= bmain->scene.first; sce; sce= sce->id.next) {
+ if(sce->clip==clip)
+ sce->clip= NULL;
+ }
+
+ for(ob= bmain->object.first; ob; ob= ob->id.next) {
+ bConstraint *con= ob->constraints.first;
+
+ for (con= ob->constraints.first; con; con= con->next) {
+ bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
+
+ if(cti->type==CONSTRAINT_TYPE_FOLLOWTRACK) {
+ bFollowTrackConstraint *data= (bFollowTrackConstraint *) con->data;
+
+ if(data->clip==clip)
+ data->clip= NULL;
+ }
+ else if(cti->type==CONSTRAINT_TYPE_CAMERASOLVER) {
+ bCameraSolverConstraint *data= (bCameraSolverConstraint *) con->data;
+
+ if(data->clip==clip)
+ data->clip= NULL;
+ }
+ }
+ }
+
clip->id.us= 0;
}
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c 2011-10-25 18:30:09 UTC (rev 41284)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c 2011-10-25 19:06:53 UTC (rev 41285)
@@ -727,13 +727,13 @@
int pixel= tmpibuf->x*y + x;
if(tmpibuf->rect_float) {
- float *rrgbf= ibuf->rect_float + pixel*4;
+ float *rrgbf= tmpibuf->rect_float + pixel*4;
- *fp= (0.2126*rrgbf[0] + 0.7152*rrgbf[1] + 0.0722*rrgbf[2])/255;
+ *fp= 0.2126*rrgbf[0] + 0.7152*rrgbf[1] + 0.0722*rrgbf[2];
} else {
char *rrgb= (char*)tmpibuf->rect + pixel*4;
- *fp= (0.2126*rrgb[0] + 0.7152*rrgb[1] + 0.0722*rrgb[2])/255;
+ *fp= FTOCHAR(0.2126*rrgb[0] + 0.7152*rrgb[1] + 0.0722*rrgb[2]);
}
fp++;
@@ -745,12 +745,39 @@
return pixels;
}
+static unsigned char *get_ucharbuf(ImBuf *ibuf)
+{
+ int x, y;
+ unsigned char *pixels, *cp;
+
+ cp= pixels= MEM_callocN(ibuf->x*ibuf->y*sizeof(unsigned char), "tracking ucharBuf");
+ for(y= 0; y<ibuf->y; y++) {
+ for (x= 0; x<ibuf->x; x++) {
+ int pixel= ibuf->x*y + x;
+
+ if(ibuf->rect_float) {
+ float *rrgbf= ibuf->rect_float + pixel*4;
+
+ *cp= FTOCHAR(0.2126f*rrgbf[0] + 0.7152f*rrgbf[1] + 0.0722f*rrgbf[2]);
+ } else {
+ char *rrgb= (char*)ibuf->rect + pixel*4;
+
+ *cp= 0.2126f*rrgb[0] + 0.7152f*rrgb[1] + 0.0722f*rrgb[2];
+ }
+
+ cp++;
+ }
+ }
+
+ return pixels;
+}
+
static unsigned char *get_search_bytebuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker,
int *width_r, int *height_r, float pos[2], int origin[2])
{
ImBuf *tmpibuf;
- unsigned char *pixels, *fp;
- int x, y, width, height;
+ unsigned char *pixels;
+ int width, height;
width= (track->search_max[0]-track->search_min[0])*ibuf->x;
height= (track->search_max[1]-track->search_min[1])*ibuf->y;
@@ -761,25 +788,8 @@
*width_r= width;
*height_r= height;
- fp= pixels= MEM_callocN(width*height*sizeof(unsigned char), "tracking byteBuf");
- for(y= 0; y<(int)height; y++) {
- for (x= 0; x<(int)width; x++) {
- int pixel= tmpibuf->x*y + x;
+ pixels= get_ucharbuf(tmpibuf);
- if(tmpibuf->rect_float) {
- float *rrgbf= ibuf->rect_float + pixel*4;
-
- *fp= (0.2126*rrgbf[0] + 0.7152*rrgbf[1] + 0.0722*rrgbf[2]);
- } else {
- char *rrgb= (char*)tmpibuf->rect + pixel*4;
-
- *fp= (0.2126*rrgb[0] + 0.7152*rrgb[1] + 0.0722*rrgb[2]);
- }
-
- fp++;
- }
- }
-
IMB_freeImBuf(tmpibuf);
return pixels;
@@ -1496,35 +1506,6 @@
#endif
}
-#ifdef WITH_LIBMV
-static unsigned char *get_ucharbuf(ImBuf *ibuf)
-{
- int x, y;
- unsigned char *pixels, *fp;
-
- fp= pixels= MEM_callocN(ibuf->x*ibuf->y*sizeof(unsigned char), "tracking ucharBuf");
- for(y= 0; y<ibuf->y; y++) {
- for (x= 0; x<ibuf->x; x++) {
- int pixel= ibuf->x*y + x;
-
- if(ibuf->rect_float) {
- float *rrgbf= ibuf->rect_float + pixel*4;
-
- *fp= 0.2126f*rrgbf[0] + 0.7152f*rrgbf[1] + 0.0722f*rrgbf[2];
- } else {
- char *rrgb= (char*)ibuf->rect + pixel*4;
-
- *fp= 0.2126f*rrgb[0] + 0.7152f*rrgb[1] + 0.0722f*rrgb[2];
- }
-
- fp++;
- }
- }
-
- return pixels;
-}
-#endif
-
static int point_in_stroke(bGPDstroke *stroke, float x, float y)
{
int i, prev;
Modified: branches/soc-2011-tomato/source/blender/makesdna/DNA_movieclip_types.h
===================================================================
--- branches/soc-2011-tomato/source/blender/makesdna/DNA_movieclip_types.h 2011-10-25 18:30:09 UTC (rev 41284)
+++ branches/soc-2011-tomato/source/blender/makesdna/DNA_movieclip_types.h 2011-10-25 19:06:53 UTC (rev 41285)
@@ -86,7 +86,7 @@
} MovieClip;
typedef struct MovieClipScopes {
- int ok; /* 1 means scopes are ok and re-calculaito is unneeded */
+ int ok; /* 1 means scopes are ok and recalculation is unneeded */
int track_preview_height; /* height of track preview widget */
struct ImBuf *track_preview; /* ImBuf displayed in track preview */
float track_pos[2]; /* sub-pizel position of marker in track ImBuf */
Modified: branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c 2011-10-25 18:30:09 UTC (rev 41284)
+++ branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c 2011-10-25 19:06:53 UTC (rev 41285)
@@ -96,30 +96,25 @@
static void rna_tracking_trackerPattern_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
- MovieClip *clip= (MovieClip*)ptr->id.data;
- MovieTrackingTrack *track;
+ MovieTrackingTrack *track= (MovieTrackingTrack *)ptr->data;
- /* XXX: clamp modified marker only */
- track= clip->tracking.tracks.first;
- while(track) {
- BKE_tracking_clamp_track(track, CLAMP_PAT_DIM);
- track= track->next;
- }
+ BKE_tracking_clamp_track(track, CLAMP_PAT_DIM);
}
static void rna_tracking_trackerSearch_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
- MovieClip *clip= (MovieClip*)ptr->id.data;
- MovieTrackingTrack *track;
+ MovieTrackingTrack *track= (MovieTrackingTrack *)ptr->data;
- /* XXX: clamp modified marker only */
- track= clip->tracking.tracks.first;
- while(track) {
- BKE_tracking_clamp_track(track, CLAMP_SEARCH_DIM);
- track= track->next;
- }
+ BKE_tracking_clamp_track(track, CLAMP_SEARCH_DIM);
}
+static int rna_tracking_markers_length(PointerRNA *ptr)
+{
+ MovieTrackingTrack *track= (MovieTrackingTrack *)ptr->data;
+
+ return track->markersnr;
+}
+
static float rna_trackingCamera_focal_get(PointerRNA *ptr)
{
MovieClip *clip= (MovieClip*)ptr->id.data;
@@ -475,6 +470,7 @@
prop= RNA_def_property(srna, "markers", PROP_COLLECTION, PROP_NONE);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list