Blender V2.61 - r43446

DNA_tracking_types.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): Blender Foundation,
00024  *                 Sergey Sharybin
00025  *
00026  * ***** END GPL LICENSE BLOCK *****
00027  */
00028 
00035 #ifndef DNA_TRACKING_TYPES_H
00036 #define DNA_TRACKING_TYPES_H
00037 
00038 #include "DNA_listBase.h"
00039 
00040 /* match-moving data */
00041 
00042 struct ImBuf;
00043 struct MovieReconstructedCamera;
00044 struct MovieTrackingCamera;
00045 struct MovieTrackingBundle;
00046 struct MovieTrackingMarker;
00047 struct MovieTrackingTrack;
00048 struct MovieTracking;
00049 
00050 typedef struct MovieReconstructedCamera {
00051     int framenr;
00052     float error;
00053     float mat[4][4];
00054 } MovieReconstructedCamera;
00055 
00056 typedef struct MovieTrackingCamera {
00057     void *intrinsics;   /* intrinsics handle */
00058 
00059     float sensor_width; /* width of CCD sensor */
00060     float pixel_aspect; /* pixel aspect ratio */
00061     float pad;
00062     float focal;        /* focal length */
00063     short units;        /* units of focal length user is working with */
00064     short pad1;
00065     float principal[2]; /* principal point */
00066     float k1, k2, k3;   /* radial distortion */
00067 } MovieTrackingCamera;
00068 
00069 typedef struct MovieTrackingMarker {
00070     float pos[2];   /* 2d position of marker on frame (in unified 0..1 space) */
00071     int framenr;    /* number of frame marker is associated with */
00072     int flag;       /* Marker's flag (alive, ...) */
00073 } MovieTrackingMarker;
00074 
00075 typedef struct MovieTrackingTrack {
00076     struct MovieTrackingTrack *next, *prev;
00077 
00078     char name[64];  /* MAX_NAME */
00079 
00080     /* ** setings ** */
00081     float pat_min[2], pat_max[2];       /* positions of left-bottom and right-top corners of pattern (in unified 0..1 space) */
00082     float search_min[2], search_max[2]; /* positions of left-bottom and right-top corners of search area (in unified 0..1 space) */
00083     float offset[2];                    /* offset to "parenting" point */
00084 
00085     /* ** track ** */
00086     int markersnr;                  /* count of markers in track */
00087     int last_marker;                /* most recently used marker */
00088     MovieTrackingMarker *markers;   /* markers in track */
00089 
00090     /* ** reconstruction data ** */
00091     float bundle_pos[3];            /* reconstructed position */
00092     float error;                    /* average track reprojection error */
00093 
00094     int pad;
00095 
00096     /* ** UI editing ** */
00097     int flag, pat_flag, search_flag;    /* flags (selection, ...) */
00098     short transflag;                    /* transform flags */
00099     char pad3[2];
00100     float color[3];                     /* custom color for track */
00101 
00102     /* tracking algorithm to use; can be KLT or SAD */
00103     short frames_limit;     /* number of frames to be tarcked during single tracking session (if TRACKING_FRAMES_LIMIT is set) */
00104     short margin;           /* margin from frame boundaries */
00105     short pattern_match;    /* re-adjust every N frames */
00106 
00107     short tracker;          /* tracking algorithm used for this track */
00108 
00109     /* ** KLT tracker settings ** */
00110     short pyramid_levels, pad2;     /* number of pyramid levels to use for KLT tracking */
00111 
00112     /* ** SAD tracker settings ** */
00113     float minimum_correlation;          /* minimal correlation which is still treated as successful tracking */
00114 } MovieTrackingTrack;
00115 
00116 typedef struct MovieTrackingSettings {
00117     int flag;
00118 
00119     /* ** default tracker settings */
00120     short default_tracker;              /* tracking algorithm used by default */
00121     short default_pyramid_levels;       /* number of pyramid levels to use for KLT tracking */
00122     float default_minimum_correlation;  /* minimal correlation which is still treated as successful tracking */
00123     short default_pattern_size;         /* size of pattern area for new tracks */
00124     short default_search_size;          /* size of search area for new tracks */
00125     short default_frames_limit;         /* number of frames to be tarcked during single tracking session (if TRACKING_FRAMES_LIMIT is set) */
00126     short default_margin;               /* margin from frame boundaries */
00127     short default_pattern_match;        /* re-adjust every N frames */
00128 
00129     /* ** common tracker settings ** */
00130     short speed;            /* speed of tracking */
00131 
00132     /* ** reconstruction settings ** */
00133     int keyframe1, keyframe2;   /* two keyframes for reconstrution initialization */
00134 
00135     /* ** which camera intrinsics to refine. uses on the REFINE_* flags */
00136     short refine_camera_intrinsics, pad2;
00137 
00138     /* ** tool settings ** */
00139 
00140     /* set scale */
00141     float dist;                 /* distance between two bundles used for scene scaling */
00142 
00143     /* cleanup */
00144     int clean_frames, clean_action;
00145     float clean_error;
00146 
00147     /* set object scale */
00148     float object_distance;      /* distance between two bundles used for object scaling */
00149 } MovieTrackingSettings;
00150 
00151 typedef struct MovieTrackingStabilization {
00152     int flag;
00153     int tot_track, act_track;       /* total number and index of active track in list */
00154 
00155     /* 2d stabilization */
00156     float maxscale;         /* max auto-scale factor */
00157     MovieTrackingTrack *rot_track;  /* track used to stabilize rotation */
00158 
00159     float locinf, scaleinf, rotinf; /* influence on location, scale and rotation */
00160 
00161     /* some pre-computing run-time variables */
00162     int ok, pad;                /* are precomputed values and scaled buf relevant? */
00163     float scale;                /* autoscale factor */
00164 
00165     struct ImBuf *scaleibuf;    /* currently scaled ibuf */
00166 } MovieTrackingStabilization;
00167 
00168 typedef struct MovieTrackingReconstruction {
00169     int flag;
00170 
00171     float error;        /* average error of reconstruction */
00172 
00173     int last_camera;        /* most recently used camera */
00174     int camnr;              /* number of reconstructed cameras */
00175     struct MovieReconstructedCamera *cameras;   /* reconstructed cameras */
00176 } MovieTrackingReconstruction;
00177 
00178 typedef struct MovieTrackingObject {
00179     struct MovieTrackingObject *next, *prev;
00180 
00181     char name[64];          /* Name of tracking object, MAX_NAME */
00182     int flag;
00183     float scale;            /* scale of object solution in amera space */
00184 
00185     ListBase tracks;        /* list of tracks use to tracking this object */
00186     MovieTrackingReconstruction reconstruction; /* reconstruction data for this object */
00187 } MovieTrackingObject;
00188 
00189 typedef struct MovieTrackingStats {
00190     char message[256];
00191 } MovieTrackingStats;
00192 
00193 typedef struct MovieTracking {
00194     MovieTrackingSettings settings; /* different tracking-related settings */
00195     MovieTrackingCamera camera;     /* camera intrinsics */
00196     ListBase tracks;                /* list of tracks used for camera object */
00197     MovieTrackingReconstruction reconstruction; /* reconstruction data for camera object */
00198     MovieTrackingStabilization stabilization;   /* stabilization data */
00199     MovieTrackingTrack *act_track;      /* active track */
00200 
00201     ListBase objects;
00202     int objectnr, tot_object;       /* index of active object and total number of objects */
00203 
00204     MovieTrackingStats *stats;      /* statistics displaying in clip editor */
00205 } MovieTracking;
00206 
00207 /* MovieTrackingCamera->units */
00208 enum {
00209     CAMERA_UNITS_PX = 0,
00210     CAMERA_UNITS_MM
00211 };
00212 
00213 /* MovieTrackingMarker->flag */
00214 #define MARKER_DISABLED (1<<0)
00215 #define MARKER_TRACKED  (1<<1)
00216 #define MARKER_GRAPH_SEL (1<<2)
00217 
00218 /* MovieTrackingTrack->flag */
00219 #define TRACK_HAS_BUNDLE    (1<<1)
00220 #define TRACK_DISABLE_RED   (1<<2)
00221 #define TRACK_DISABLE_GREEN (1<<3)
00222 #define TRACK_DISABLE_BLUE  (1<<4)
00223 #define TRACK_HIDDEN        (1<<5)
00224 #define TRACK_LOCKED        (1<<6)
00225 #define TRACK_CUSTOMCOLOR   (1<<7)
00226 #define TRACK_USE_2D_STAB   (1<<8)
00227 #define TRACK_PREVIEW_GRAYSCALE (1<<9)
00228 
00229 /* MovieTrackingTrack->tracker */
00230 #define TRACKER_KLT     0
00231 #define TRACKER_SAD     1
00232 #define TRACKER_HYBRID      2
00233 
00234 /* MovieTrackingTrack->adjframes */
00235 #define TRACK_MATCH_KEYFRAME        0
00236 #define TRACK_MATCH_PREVFRAME       1
00237 
00238 /* MovieTrackingSettings->flag */
00239 #define TRACKING_SETTINGS_SHOW_DEFAULT_EXPANDED (1<<0)
00240 
00241 /* MovieTrackingSettings->speed */
00242 #define TRACKING_SPEED_FASTEST      0
00243 #define TRACKING_SPEED_REALTIME     1
00244 #define TRACKING_SPEED_HALF         2
00245 #define TRACKING_SPEED_QUARTER      4
00246 #define TRACKING_SPEED_DOUBLE       5
00247 
00248 /* MovieTrackingSettings->refine_camera_intrinsics */
00249 #define REFINE_FOCAL_LENGTH         (1<<0)
00250 #define REFINE_PRINCIPAL_POINT      (1<<1)
00251 #define REFINE_RADIAL_DISTORTION_K1 (1<<2)
00252 #define REFINE_RADIAL_DISTORTION_K2 (1<<4)
00253 
00254 /* MovieTrackingStrabilization->flag */
00255 #define TRACKING_2D_STABILIZATION   (1<<0)
00256 #define TRACKING_AUTOSCALE          (1<<1)
00257 #define TRACKING_STABILIZE_ROTATION (1<<2)
00258 
00259 /* MovieTrackingReconstruction->flag */
00260 #define TRACKING_RECONSTRUCTED  (1<<0)
00261 
00262 /* MovieTrackingObject->flag */
00263 #define TRACKING_OBJECT_CAMERA      (1<<0)
00264 
00265 #define TRACKING_CLEAN_SELECT           0
00266 #define TRACKING_CLEAN_DELETE_TRACK     1
00267 #define TRACKING_CLEAN_DELETE_SEGMENT   2
00268 
00269 #endif