Camera tracking integration

===========================

Changes into sensor size use case.

There was problem with vertical sensor size which can't actually
affect on things due to we've got fixed image resolution. So
as soon horizontal size gets defined, both of sensor height
and vertical FOV is known and exposing it into UI makes things
difficult to understand.

That's why vertical sensor size was dropped.

Also added pixel aspect to camera settings fo clip editor.
Solver will sue this value rather than value from display
aspect ratio.

This pixel aspect would be copied to render settings after solving
so things should match now between footage, solving anf footage.
This commit is contained in:
Sergey Sharybin
2011-08-09 15:12:20 +00:00
parent 6058543169
commit dda38732d1
66 changed files with 119 additions and 190 deletions

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 22.3
bpy.context.object.data.sensor_y = 14.9
bpy.context.object.data.sensor_width = 22.3

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 32
bpy.context.object.data.sensor_y = 18
bpy.context.object.data.sensor_width = 32

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 22.2
bpy.context.object.data.sensor_y = 14.7
bpy.context.object.data.sensor_width = 22.2

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 27.9
bpy.context.object.data.sensor_y = 18.6
bpy.context.object.data.sensor_width = 27.9

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 36.0
bpy.context.object.data.sensor_y = 24.0
bpy.context.object.data.sensor_width = 36.0

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 22.3
bpy.context.object.data.sensor_y = 14.9
bpy.context.object.data.sensor_width = 22.3

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 22.3
bpy.context.object.data.sensor_y = 14.9
bpy.context.object.data.sensor_width = 22.3

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 36.0
bpy.context.object.data.sensor_y = 24.0
bpy.context.object.data.sensor_width = 36.0

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 22.3
bpy.context.object.data.sensor_y = 14.9
bpy.context.object.data.sensor_width = 22.3

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 22.3
bpy.context.object.data.sensor_y = 14.9
bpy.context.object.data.sensor_width = 22.3

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 22.3
bpy.context.object.data.sensor_y = 14.9
bpy.context.object.data.sensor_width = 22.3

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 23.6
bpy.context.object.data.sensor_y = 15.8
bpy.context.object.data.sensor_width = 23.6

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 23.1
bpy.context.object.data.sensor_y = 15.4
bpy.context.object.data.sensor_width = 23.1

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 36.0
bpy.context.object.data.sensor_y = 23.9
bpy.context.object.data.sensor_width = 36.0

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 23.6
bpy.context.object.data.sensor_y = 15.8
bpy.context.object.data.sensor_width = 23.6

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 23.6
bpy.context.object.data.sensor_y = 15.6
bpy.context.object.data.sensor_width = 23.6

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 23.6
bpy.context.object.data.sensor_y = 15.6
bpy.context.object.data.sensor_width = 23.6

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 23.6
bpy.context.object.data.sensor_y = 15.8
bpy.context.object.data.sensor_width = 23.6

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 30.0
bpy.context.object.data.sensor_y = 15.0
bpy.context.object.data.sensor_width = 30.0

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 11.1
bpy.context.object.data.sensor_y = 6.24
bpy.context.object.data.sensor_width = 11.1

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 16.65
bpy.context.object.data.sensor_y = 9.36
bpy.context.object.data.sensor_width = 16.65

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 22.2
bpy.context.object.data.sensor_y = 12.6
bpy.context.object.data.sensor_width = 22.2

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 36
bpy.context.object.data.sensor_y = 24
bpy.context.object.data.sensor_width = 36

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 17.3
bpy.context.object.data.sensor_y = 13.0
bpy.context.object.data.sensor_width = 17.3

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 12.52
bpy.context.object.data.sensor_y = 7.41
bpy.context.object.data.sensor_width = 12.52

View File

@@ -1,3 +1,2 @@
import bpy
bpy.context.object.data.sensor_x = 24.89
bpy.context.object.data.sensor_y = 18.66
bpy.context.object.data.sensor_width = 24.89

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 32.0
camera.sensor_height = 18.0
camera.units = 'MILLIMETERS'
camera.focal_length = 35.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 22.2
camera.sensor_height = 14.7
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 27.9
camera.sensor_height = 18.6
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 36.0
camera.sensor_height = 24.0
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 22.3
camera.sensor_height = 14.9
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 22.3
camera.sensor_height = 14.9
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 36.0
camera.sensor_height = 24.0
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 22.3
camera.sensor_height = 14.9
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 22.3
camera.sensor_height = 14.9
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 22.3
camera.sensor_height = 14.9
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 23.6
camera.sensor_height = 15.8
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 23.1
camera.sensor_height = 15.4
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 36.0
camera.sensor_height = 23.9
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 23.6
camera.sensor_height = 15.8
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 23.6
camera.sensor_height = 15.6
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 23.6
camera.sensor_height = 15.6
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 23.6
camera.sensor_height = 15.8
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 30.0
camera.sensor_height = 15.0
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 11.1
camera.sensor_height = 6.24
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 16.65
camera.sensor_height = 9.36
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -2,9 +2,9 @@ import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 22.2
camera.sensor_height = 12.6
camera.units = 'MILLIMETERS'
camera.focal_length = 24.0
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -205,8 +205,7 @@ class AddPresetCamera(AddPresetBase, bpy.types.Operator):
]
preset_values = [
"cam.sensor_x",
"cam.sensor_y",
"cam.sensor_width"
]
preset_subdir = "camera"
@@ -329,9 +328,9 @@ class AddPresetTrackingCamera(AddPresetBase, bpy.types.Operator):
preset_values = [
"camera.sensor_width",
"camera.sensor_height",
"camera.units",
"camera.focal_length",
"camera.pixel_aspect",
"camera.k1",
"camera.k2",
"camera.k3"

View File

@@ -76,17 +76,12 @@ class DATA_PT_lens(CameraButtonsPanel, bpy.types.Panel):
col = split.column()
if cam.type == 'PERSP':
col.prop(cam, "lens")
split = layout.split()
col = split.column()
if cam.angle_unit == 'HORIZONTAL':
col.prop(cam, "angle_x")
elif cam.angle_unit == 'VERTICAL':
col.prop(cam, "angle_y")
col = split.column()
col.prop(cam, "angle_unit", text="")
row = col.row()
if cam.lens_unit == 'MILLIMETERS':
row.prop(cam, "lens")
elif cam.lens_unit == 'DEGREES':
row.prop(cam, "angle")
row.prop(cam, "lens_unit", text="")
elif cam.type == 'ORTHO':
col.prop(cam, "ortho_scale")
@@ -133,17 +128,12 @@ class DATA_PT_camera(CameraButtonsPanel, bpy.types.Panel):
row.operator("camera.preset_add", text="", icon="ZOOMIN")
row.operator("camera.preset_add", text="", icon="ZOOMOUT").remove_active = True
split = layout.split()
layout.prop(cam, "sensor_width")
col = split.column(align=True)
col.label(text="Sensor Size:")
col.prop(cam, "sensor_x", text="X")
col.prop(cam, "sensor_y", text="Y")
col = split.column(align=True)
col.label(text="Clipping:")
col.prop(cam, "clip_start", text="Start")
col.prop(cam, "clip_end", text="End")
layout.label(text="Clipping:")
row = layout.row(align=True)
row.prop(cam, "clip_start", text="Start")
row.prop(cam, "clip_end", text="End")
class DATA_PT_camera_display(CameraButtonsPanel, bpy.types.Panel):

View File

@@ -298,16 +298,16 @@ class CLIP_PT_tracking_camera(bpy.types.Panel):
op = row.operator("clip.camera_preset_add", text="", icon="ZOOMOUT")
op.remove_active = True
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)
sub.prop(clip.tracking.camera, "focal_length")
sub.prop(clip.tracking.camera, "units", text="")
col = layout.column(align=True)
col.label(text="Sensor:")
col.prop(clip.tracking.camera, "sensor_width", text="Size")
col.prop(clip.tracking.camera, "pixel_aspect")
col = layout.column()
col.label(text="Principal Point")
row = col.row()

View File

@@ -71,7 +71,7 @@ void BKE_tracking_sync(struct MovieTrackingContext *context);
void BKE_tracking_sync_user(struct MovieClipUser *user, struct MovieTrackingContext *context);
int BKE_tracking_next(struct MovieTrackingContext *context);
float BKE_tracking_solve_reconstruction(struct MovieTracking *tracking, int width, int height, float aspx, float aspy);
float BKE_tracking_solve_reconstruction(struct MovieTracking *tracking, int width, int height);
void BKE_track_unique_name(struct MovieTracking *tracking, struct MovieTrackingTrack *track);
struct MovieTrackingTrack *BKE_find_track_by_name(struct MovieTracking *tracking, const char *name);

View File

@@ -341,7 +341,6 @@ static MovieClip *movieclip_alloc(const char *name)
clip->aspx= clip->aspy= 1.0f;
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;
@@ -599,7 +598,7 @@ void BKE_movieclip_aspect(MovieClip *clip, float *aspx, float *aspy)
*aspx= *aspy= 1.0;
/* x is always 1 */
*aspy = clip->aspy/clip->aspx;
*aspy = clip->aspy/clip->aspx/clip->tracking.camera.pixel_aspect;
}
/* get segments of cached frames. useful for debugging cache policies */

View File

@@ -713,7 +713,6 @@ void *add_camera(const char *name)
cam->lens= 35.0f;
cam->sensor_x = 32.f;
cam->sensor_y = 18.f;
cam->clipsta= 0.1f;
cam->clipend= 100.0f;
cam->drawsize= 0.5f;

View File

@@ -1007,16 +1007,17 @@ static int retrive_libmv_reconstruct(MovieTracking *tracking, struct libmv_Recon
#endif
float BKE_tracking_solve_reconstruction(MovieTracking *tracking, int width, int height, float aspx, float aspy)
float BKE_tracking_solve_reconstruction(MovieTracking *tracking, int width, int height)
{
#if WITH_LIBMV
{
MovieTrackingCamera *camera= &tracking->camera;
struct libmv_Tracks *tracks= create_libmv_tracks(tracking, width*aspx, height*aspy);
float aspy= 1.f/tracking->camera.pixel_aspect;
struct libmv_Tracks *tracks= create_libmv_tracks(tracking, width, height*aspy);
struct libmv_Reconstruction *reconstruction = libmv_solveReconstruction(tracks,
tracking->settings.keyframe1, tracking->settings.keyframe2,
camera->focal,
camera->principal[0]*aspx, camera->principal[1]*aspy,
camera->principal[0], camera->principal[1]*aspy,
camera->k1, camera->k2, camera->k3);
float error= libmv_reprojectionError(reconstruction);

View File

@@ -183,9 +183,7 @@ void quat_apply_track(float quat[4], short axis, short upflag);
void vec_apply_track(float vec[3], short axis);
float focallength_to_hfov(float focal_length, float sensor_x);
float focallength_to_vfov(float focal_length, float sensor_y);
float hfov_to_focallength(float hfov, float sensor_x);
float vfov_to_focallength(float vfov, float sensor_y);
float angle_wrap_rad(float angle);
float angle_wrap_deg(float angle);

View File

@@ -1671,27 +1671,11 @@ float focallength_to_hfov(float focal_length, float sensor_x)
return 2.0f * atanf((sensor_x/2.0f) / focal_length);
}
float focallength_to_vfov(float focal_length, float sensor_y)
{
return 2.0f * atanf((sensor_y/2.0f) / focal_length);
}
float hfov_to_focallength(float hfov, float sensor_x)
{
return (sensor_x/2.0f) / tanf(hfov * 0.5f);
}
float vfov_to_focallength(float vfov, float sensor_y)
{
return (sensor_y/2.0f) / tanf(vfov * 0.5f);
}
/* takes into account subject distance */
//float focus_dist_to_fov(float focal_length, float sensor_x, float dist)
//{
// return 2.f * atanf( (sensor_x * (dist - focal_length)) / (2.f * dist * focal_length));
//}
/* 'mod_inline(-3,4)= 1', 'fmod(-3,4)= -3' */
static float mod_inline(float a, float b)
{

View File

@@ -11859,12 +11859,14 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
if(clip->proxy.quality==0)
clip->proxy.quality= 90;
if(clip->tracking.camera.pixel_aspect<0.01f)
clip->tracking.camera.pixel_aspect= 1.f;
}
for(cam= main->camera.first; cam; cam= cam->id.next) {
if (cam->sensor_x < 0.01f) {
cam->sensor_x = 32.f;
cam->sensor_y = 18.f;
}
}
}

View File

@@ -910,13 +910,13 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
}
if(sc->flag&SC_SHOW_BUNDLES) {
float pos[4], vec[4], mat[4][4], aspx, aspy;
float pos[4], vec[4], mat[4][4], aspy;
glEnable(GL_POINT_SMOOTH);
glPointSize(3.0f);
BKE_movieclip_aspect(clip, &aspx, &aspy);
BKE_tracking_projection_matrix(tracking, framenr, width*aspx, height*aspy, mat);
aspy= 1.f/clip->tracking.camera.pixel_aspect;
BKE_tracking_projection_matrix(tracking, framenr, width, height*aspy, mat);
track= tracking->tracks.first;
while(track) {

View File

@@ -478,7 +478,7 @@ static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar)
h= height;
if(clip)
h*= clip->aspy/clip->aspx;
h*= clip->aspy/clip->aspx/clip->tracking.camera.pixel_aspect;
winx= ar->winrct.xmax - ar->winrct.xmin + 1;
winy= ar->winrct.ymax - ar->winrct.ymin + 1;

View File

@@ -1470,7 +1470,7 @@ static int solve_camera_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
MovieTracking *tracking= &clip->tracking;
int width, height;
float error, aspx, aspy;
float error;
if(!check_solve_track_count(tracking)) {
BKE_report(op->reports, RPT_ERROR, "At least 10 tracks on both of keyframes are needed for reconstruction");
@@ -1479,9 +1479,8 @@ static int solve_camera_exec(bContext *C, wmOperator *op)
/* could fail if footage uses images with different sizes */
BKE_movieclip_acquire_size(clip, NULL, &width, &height);
BKE_movieclip_aspect(clip, &aspx, &aspy);
error= BKE_tracking_solve_reconstruction(tracking, width, height, aspx, aspy);
error= BKE_tracking_solve_reconstruction(tracking, width, height);
if(error<0)
BKE_report(op->reports, RPT_WARNING, "Some data failed to reconstruct, see console for details");
@@ -1500,11 +1499,18 @@ static int solve_camera_exec(bContext *C, wmOperator *op)
if(focal) {
Camera *camera= (Camera*)scene->camera->data;
if(clip->lastsize[0]) {
camera->sensor_x= tracking->camera.sensor_width;
camera->sensor_y= tracking->camera.sensor_height;
camera->sensor_x= tracking->camera.sensor_width;
camera->lens= focal*camera->sensor_x/width;
camera->lens= focal*camera->sensor_x/(float)clip->lastsize[0];
scene->r.xsch= width;
scene->r.ysch= height;
if(tracking->camera.pixel_aspect > 1.0f) {
scene->r.xasp= tracking->camera.pixel_aspect;
scene->r.yasp= 1.f;
} else {
scene->r.xasp= 1.f;
scene->r.yasp= 1.f / tracking->camera.pixel_aspect;
}
WM_event_add_notifier(C, NC_OBJECT, camera);

View File

@@ -1243,7 +1243,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
uiSetRoundBox(15);
uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0);
}
#if 0 /* XXX: ... */
if (ca && (ca->flag & CAM_SHOWSENSOR)) {
/* assume fixed sensor width for now */
float sensor_scale = (x2i-x1i) / ca->sensor_x;
@@ -1257,6 +1257,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
uiDrawBox(GL_LINE_LOOP, x1i, sy1, x2i, sy2, 2.0);
}
#endif
}
setlinestyle(0);

View File

@@ -53,8 +53,7 @@ typedef struct Camera {
float passepartalpha;
float clipsta, clipend;
float lens, ortho_scale, drawsize;
float hfov, vfov;
float sensor_x, sensor_y;
float sensor_x, pad;
float shiftx, shifty;
/* yafray: dof params */

View File

@@ -55,8 +55,8 @@ typedef struct MovieReconstructedCamera {
} MovieReconstructedCamera;
typedef struct MovieTrackingCamera {
float sensor_width; /* width of CCD sensor */
float sensor_height; /* height of CCD sensor */
float sensor_width; /* width of CCD sensor */
float pixel_aspect; /* pixel aspect ratio */
float pad2;
float focal; /* focal length */
short units; /* units of focal length user is working with */

View File

@@ -45,30 +45,18 @@
#include "BKE_depsgraph.h"
/* only for rad/deg conversion! can remove later */
static float rna_Camera_angle_x_get(PointerRNA *ptr)
static float rna_Camera_angle_get(PointerRNA *ptr)
{
Camera *cam= ptr->id.data;
return focallength_to_hfov(cam->lens, cam->sensor_x);
}
static float rna_Camera_angle_y_get(PointerRNA *ptr)
{
Camera *cam= ptr->id.data;
return focallength_to_vfov(cam->lens, cam->sensor_y);
}
static void rna_Camera_angle_x_set(PointerRNA *ptr, float value)
static void rna_Camera_angle_set(PointerRNA *ptr, float value)
{
Camera *cam= ptr->id.data;
cam->lens= hfov_to_focallength(value, cam->sensor_x);
}
static void rna_Camera_angle_y_set(PointerRNA *ptr, float value)
{
Camera *cam= ptr->id.data;
cam->lens= vfov_to_focallength(value, cam->sensor_y);
}
static void rna_Camera_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
Camera *camera= (Camera*)ptr->id.data;
@@ -96,9 +84,9 @@ void RNA_def_camera(BlenderRNA *brna)
{CAM_DTX_HARMONY_TRI_A, "HARMONY_TRIANGLE_A", 0, "Harmonious Triangle A", ""},
{CAM_DTX_HARMONY_TRI_B, "HARMONY_TRIANGLE_B", 0, "Harmonious Triangle B", ""},
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem prop_angle_unit_items[] = {
{0, "HORIZONTAL", 0, "Horizontal", ""},
{CAM_ANGLETOGGLE, "VERTICAL", 0, "Vertical", ""},
static EnumPropertyItem prop_lens_unit_items[] = {
{0, "MILLIMETERS", 0, "Millimeters", ""},
{CAM_ANGLETOGGLE, "DEGREES", 0, "Degrees", ""},
{0, NULL, 0, NULL, NULL}};
srna= RNA_def_struct(brna, "Camera", "ID");
@@ -125,18 +113,11 @@ void RNA_def_camera(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Passepartout Alpha", "Opacity (alpha) of the darkened overlay in Camera view");
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
prop= RNA_def_property(srna, "angle_x", PROP_FLOAT, PROP_ANGLE);
prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_range(prop, M_PI * (0.367/180.0), M_PI * (172.847/180.0));
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Field of View", "Camera lens horizontal field of view in degrees");
RNA_def_property_float_funcs(prop, "rna_Camera_angle_x_get", "rna_Camera_angle_x_set", NULL);
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update");
prop= RNA_def_property(srna, "angle_y", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_range(prop, M_PI * (0.367/180.0), M_PI * (172.847/180.0));
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Field of View", "Camera lens vertical field of view in degrees");
RNA_def_property_float_funcs(prop, "rna_Camera_angle_y_get", "rna_Camera_angle_y_set", NULL);
RNA_def_property_float_funcs(prop, "rna_Camera_angle_get", "rna_Camera_angle_set", NULL);
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update");
prop= RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_DISTANCE);
@@ -157,17 +138,11 @@ void RNA_def_camera(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Focal Length", "Perspective Camera lens value in millimeters");
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update");
prop= RNA_def_property(srna, "sensor_x", PROP_FLOAT, PROP_NONE);
prop= RNA_def_property(srna, "sensor_width", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "sensor_x");
RNA_def_property_range(prop, 1.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 1.0f, 100.f, 1, 2);
RNA_def_property_ui_text(prop, "Sensor X", "Horizontal size of the image sensor area in millimeters");
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update");
prop= RNA_def_property(srna, "sensor_y", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 1.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 1.0f, 100.f, 1, 2);
RNA_def_property_ui_text(prop, "Sensor Y", "Vertical size of the image sensor area in millimeters");
RNA_def_property_ui_text(prop, "Sensor", "Horizontal size of the image sensor area in millimeters");
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update");
prop= RNA_def_property(srna, "ortho_scale", PROP_FLOAT, PROP_NONE);
@@ -234,10 +209,10 @@ void RNA_def_camera(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show Sensor Size", "Show sensor size (film gate) in Camera view");
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
prop= RNA_def_property(srna, "angle_unit", PROP_ENUM, PROP_NONE);
prop= RNA_def_property(srna, "lens_unit", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_items(prop, prop_angle_unit_items);
RNA_def_property_ui_text(prop, "Angle Unit", "Unit to edit lens in for the user interface");
RNA_def_property_enum_items(prop, prop_lens_unit_items);
RNA_def_property_ui_text(prop, "Lens Unit", "Unit to edit lens in for the user interface");
prop= RNA_def_property(srna, "use_panorama", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_PANORAMA);

View File

@@ -220,6 +220,7 @@ static void rna_def_movieclip(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "aspx");
RNA_def_property_array(prop, 2);
RNA_def_property_range(prop, 0.1f, 5000.0f);
RNA_def_property_ui_range(prop, 0.1f, 5000.0f, 1, 2);
RNA_def_property_ui_text(prop, "Display Aspect", "Display Aspect for this clip, does not affect rendering");
RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);

View File

@@ -268,18 +268,11 @@ static void rna_def_trackingCamera(BlenderRNA *brna)
srna= RNA_def_struct(brna, "MovieTrackingCamera", NULL);
RNA_def_struct_ui_text(srna, "Movie tracking camera data", "Match-moving camera data for tracking");
/* Sensor Wdth */
/* Sensor */
prop= RNA_def_property(srna, "sensor_width", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "sensor_width");
RNA_def_property_range(prop, 0.0f, 500.0f);
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_ui_text(prop, "Sensor", "Width of CCD sensor in millimeters");
RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
/* Focal Length */
@@ -322,6 +315,14 @@ static void rna_def_trackingCamera(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0, 10, .1, 3);
RNA_def_property_ui_text(prop, "K3", "");
RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
/* pixel aspect */
prop= RNA_def_property(srna, "pixel_aspect", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "pixel_aspect");
RNA_def_property_range(prop, 0.1f, 5000.0f);
RNA_def_property_ui_range(prop, 0.1f, 5000.0f, 1, 2);
RNA_def_property_ui_text(prop, "Pixel Aspect", "Pixel aspect ratio");
RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
}
static void rna_def_trackingMarker(BlenderRNA *brna)