Camera tracking integration
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 14 Jul 2011 15:21:55 +0000 (15:21 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 14 Jul 2011 15:21:55 +0000 (15:21 +0000)
===========================

Changes to tracking camers settings, so they could
be copied to Blender camera on reconstruction.

Sensor height doesn't make any sense yet for tracking camera.

release/scripts/startup/bl_operators/presets.py
release/scripts/startup/bl_ui/space_clip.py
source/blender/blenkernel/intern/movieclip.c
source/blender/editors/space_clip/tracking_ops.c
source/blender/makesdna/DNA_tracking_types.h
source/blender/makesrna/intern/rna_tracking.c

index c53aa2d1209a322608cbbcbf23065fba6e422ab8..75dfafc663fcc4359c65c839f87b8e2014798857 100644 (file)
@@ -308,6 +308,7 @@ class AddPresetTrackingCamera(AddPresetBase, bpy.types.Operator):
     preset_values = [
         "camera.focal_length",
         "camera.sensor_width",
+        "camera.sensor_height",
         "camera.units",
         "camera.k1",
         "camera.k2",
index 75cdc379b48485b01a8f3ba3bdadc0a277b55f77..ac7725b342625c914ddd612a14bd40ec89768d0d 100644 (file)
@@ -273,7 +273,10 @@ class CLIP_PT_tracking_camera(bpy.types.Panel):
         op = row.operator("clip.camera_preset_add", text="", icon="ZOOMOUT")
         op.remove_active = True
 
-        layout.prop(clip.tracking.camera, "sensor_width")
+        layout.label(text="Sensor:")
+        row = layout.row(align=True)
+        row.prop(clip.tracking.camera, "sensor_width", text="X")
+        row.prop(clip.tracking.camera, "sensor_height", text="Y")
 
         row = layout.row(align=True)
         sub = row.split(percentage=0.65)
index 0e08c788be40b0c18016db86d19abcb91c2a2a3b..ef3cd1eb4508861b3a0db1c66e02099aaedbd8b7 100644 (file)
@@ -215,6 +215,7 @@ static MovieClip *movieclip_alloc(const char *name)
        clip= alloc_libblock(&G.main->movieclip, ID_MC, name);
 
        clip->tracking.camera.sensor_width= 35.0f;
+       clip->tracking.camera.sensor_height= 18.0f;
        clip->tracking.camera.units= CAMERA_UNITS_MM;
 
        clip->tracking.settings.frames_limit= 20;
index c6a4672148daeb3531dd698fabb5c12a7a150982..236f4854cfac1b12263c6660446bc43a751dbdfb 100644 (file)
@@ -1023,14 +1023,19 @@ static int solve_camera_exec(bContext *C, wmOperator *op)
                scene->camera= scene_find_camera(scene);
 
        if(scene->camera) {
-               float focal= clip->tracking.camera.focal;
+               MovieTracking *tracking= &clip->tracking;
+               float focal= tracking->camera.focal;
 
                /* set blender camera focal length so result would look fine there */
                if(focal) {
                        Camera *camera= (Camera*)scene->camera->data;
 
-                       if(clip->lastsize[0])
-                               camera->lens= focal*32.0f/(float)clip->lastsize[0];
+                       if(clip->lastsize[0]) {
+                               camera->sensor_x= tracking->camera.sensor_width;
+                               camera->sensor_y= tracking->camera.sensor_height;
+
+                               camera->lens= focal*camera->sensor_x/(float)clip->lastsize[0];
+                       }
 
                        WM_event_add_notifier(C, NC_OBJECT, camera);
                }
index 0608890bc634efd7cfd70729d91a12522f6069fa..c3b315d2269ec39ccefe6a9bfdef784cae136fd6 100644 (file)
@@ -54,7 +54,9 @@ typedef struct MovieReconstructedCamera {
 } MovieReconstructedCamera;
 
 typedef struct MovieTrackingCamera {
-       float sensor_width;     /* width of CCD sensor */
+       float sensor_width;             /* width of CCD sensor */
+       float sensor_height;    /* height of CCD sensor */
+       float pad2;
        float focal;            /* focal length */
        short units;            /* units of focal length user is working with */
        short pad;
index b876c96fff8253ceec1d65133acd1a58d2a8ab57..7e8d6a951f94938e24dd9d4c0521f6bfc6309240 100644 (file)
@@ -218,6 +218,13 @@ static void rna_def_trackingCamera(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Sensor Width", "Width of CCD sensor in millimeters");
        RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
 
+       /* Sensor height */
+       prop= RNA_def_property(srna, "sensor_height", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "sensor_height");
+       RNA_def_property_range(prop, 0.0f, 500.0f);
+       RNA_def_property_ui_text(prop, "Sensor Height", "Height of CCD sensor in millimeters");
+       RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
+
        /* Focal Length */
        prop= RNA_def_property(srna, "focal_length", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "focal");