[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39052] branches/soc-2011-salad: Merging r38953 through r39051 from soc-2011-tomato into soc-2011-salad

Sergey Sharybin g.ulairi at gmail.com
Fri Aug 5 08:59:36 CEST 2011


Revision: 39052
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39052
Author:   nazgul
Date:     2011-08-05 06:59:36 +0000 (Fri, 05 Aug 2011)
Log Message:
-----------
Merging r38953 through r39051 from soc-2011-tomato into soc-2011-salad

Revision Links:
--------------
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38953
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39051

Modified Paths:
--------------
    branches/soc-2011-salad/extern/libmv/libmv-capi.cpp
    branches/soc-2011-salad/extern/libmv/libmv-capi.h
    branches/soc-2011-salad/release/scripts/startup/bl_ui/space_clip.py
    branches/soc-2011-salad/source/blender/blenkernel/BKE_moviecache.h
    branches/soc-2011-salad/source/blender/blenkernel/BKE_movieclip.h
    branches/soc-2011-salad/source/blender/blenkernel/BKE_sequencer.h
    branches/soc-2011-salad/source/blender/blenkernel/BKE_tracking.h
    branches/soc-2011-salad/source/blender/blenkernel/intern/movieclip.c
    branches/soc-2011-salad/source/blender/blenkernel/intern/seqcache.c
    branches/soc-2011-salad/source/blender/blenkernel/intern/tracking.c
    branches/soc-2011-salad/source/blender/editors/include/ED_clip.h
    branches/soc-2011-salad/source/blender/editors/interface/resources.c
    branches/soc-2011-salad/source/blender/editors/space_clip/CMakeLists.txt
    branches/soc-2011-salad/source/blender/editors/space_clip/clip_draw.c
    branches/soc-2011-salad/source/blender/editors/space_clip/clip_editor.c
    branches/soc-2011-salad/source/blender/editors/space_clip/clip_intern.h
    branches/soc-2011-salad/source/blender/editors/space_clip/clip_ops.c
    branches/soc-2011-salad/source/blender/editors/space_clip/space_clip.c
    branches/soc-2011-salad/source/blender/editors/space_clip/tracking_ops.c
    branches/soc-2011-salad/source/blender/editors/transform/transform_conversions.c
    branches/soc-2011-salad/source/blender/editors/transform/transform_generics.c
    branches/soc-2011-salad/source/blender/makesdna/DNA_tracking_types.h
    branches/soc-2011-salad/source/blender/makesrna/intern/rna_tracking.c

Added Paths:
-----------
    branches/soc-2011-salad/release/scripts/presets/camera/Canon_1100D.py
    branches/soc-2011-salad/release/scripts/presets/camera/Canon_1D.py
    branches/soc-2011-salad/release/scripts/presets/camera/Canon_1DS.py
    branches/soc-2011-salad/release/scripts/presets/camera/Canon_500D.py
    branches/soc-2011-salad/release/scripts/presets/camera/Canon_550D.py
    branches/soc-2011-salad/release/scripts/presets/camera/Canon_5D.py
    branches/soc-2011-salad/release/scripts/presets/camera/Canon_600D.py
    branches/soc-2011-salad/release/scripts/presets/camera/Canon_60D.py
    branches/soc-2011-salad/release/scripts/presets/camera/Canon_7D.py
    branches/soc-2011-salad/release/scripts/presets/camera/Nikon_D300S.py
    branches/soc-2011-salad/release/scripts/presets/camera/Nikon_D3100.py
    branches/soc-2011-salad/release/scripts/presets/camera/Nikon_D35.py
    branches/soc-2011-salad/release/scripts/presets/camera/Nikon_D5000.py
    branches/soc-2011-salad/release/scripts/presets/camera/Nikon_D5100.py
    branches/soc-2011-salad/release/scripts/presets/camera/Nikon_D7000.py
    branches/soc-2011-salad/release/scripts/presets/camera/Nikon_D90.py
    branches/soc-2011-salad/release/scripts/presets/camera/Red_Epic.py
    branches/soc-2011-salad/release/scripts/presets/camera/Red_One_2K.py
    branches/soc-2011-salad/release/scripts/presets/camera/Red_One_3K.py
    branches/soc-2011-salad/release/scripts/presets/camera/Red_One_4K.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Canon_1100D.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Canon_1D.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Canon_1DS.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Canon_500D.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Canon_550D.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Canon_5D.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Canon_600D.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Canon_60D.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Canon_7D.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Nikon_D300S.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Nikon_D3100.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Nikon_D35.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Nikon_D5000.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Nikon_D5100.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Nikon_D7000.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Nikon_D90.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Red_Epic.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Red_One_2K.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Red_One_3K.py
    branches/soc-2011-salad/release/scripts/presets/tracking_camera/Red_One_4K.py
    branches/soc-2011-salad/source/blender/editors/space_clip/clip_toolbar.c

Removed Paths:
-------------
    branches/soc-2011-salad/source/blender/editors/space_clip/clip_header.c

Property Changed:
----------------
    branches/soc-2011-salad/


Property changes on: branches/soc-2011-salad
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-30783,30792-30793,30797-30798,30815
/branches/soc-2011-carrot:36854,37548,37564,37602,37622,37848,38043,38064,38226,38231,38282,38620,38661-38662,39001,39009
/branches/soc-2011-cucumber:36829-36994
/branches/soc-2011-onion:36833-38309
/branches/soc-2011-pepper:36830-38934
/branches/soc-2011-tomato:36831-38952
/trunk/blender:36834-39050
   + /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-30783,30792-30793,30797-30798,30815
/branches/soc-2011-carrot:36854,37548,37564,37602,37622,37848,38043,38064,38226,38231,38282,38620,38661-38662,39001,39009
/branches/soc-2011-cucumber:36829-36994
/branches/soc-2011-onion:36833-38309
/branches/soc-2011-pepper:36830-38934
/branches/soc-2011-tomato:36831-39051
/trunk/blender:36834-39050

Modified: branches/soc-2011-salad/extern/libmv/libmv-capi.cpp
===================================================================
--- branches/soc-2011-salad/extern/libmv/libmv-capi.cpp	2011-08-05 06:49:02 UTC (rev 39051)
+++ branches/soc-2011-salad/extern/libmv/libmv-capi.cpp	2011-08-05 06:59:36 UTC (rev 39052)
@@ -67,6 +67,11 @@
 
 typedef struct libmv_Reconstruction {
 	libmv::Reconstruction reconstruction;
+
+	/* used for per-track average error calculation after reconstruction */
+	libmv::Tracks tracks;
+	libmv::CameraIntrinsics intrinsics;
+
 	double error;
 } libmv_Reconstruction;
 
@@ -261,7 +266,7 @@
 }
 #endif
 
-int libmv_regionTrackerTrack(libmv_RegionTracker *tracker, const float *ima1, const float *ima2,
+int libmv_regionTrackerTrack(libmv_RegionTracker *libmv_tracker, const float *ima1, const float *ima2,
 			 int width, int height, int half_window_size,
 			 double x1, double y1, double *x2, double *y2)
 {
@@ -269,8 +274,8 @@
 	libmv::TrkltRegionTracker *trklt_region_tracker;
 	libmv::FloatImage old_patch, new_patch;
 
-	trklt_region_tracker = tracker->trklt_region_tracker;
-	region_tracker = tracker->region_tracker;
+	trklt_region_tracker = libmv_tracker->trklt_region_tracker;
+	region_tracker = libmv_tracker->region_tracker;
 
 	trklt_region_tracker->half_window_size = half_window_size;
 
@@ -294,29 +299,29 @@
 #endif
 }
 
-void libmv_regionTrackerDestroy(libmv_RegionTracker *tracker)
+void libmv_regionTrackerDestroy(libmv_RegionTracker *libmv_tracker)
 {
-	delete tracker->region_tracker;
-	delete tracker;
+	delete libmv_tracker->region_tracker;
+	delete libmv_tracker;
 }
 
 /* ************ Tracks ************ */
 
 libmv_Tracks *libmv_tracksNew(void)
 {
-	libmv::Tracks *tracks = new libmv::Tracks();
+	libmv::Tracks *libmv_tracks = new libmv::Tracks();
 
-	return (libmv_Tracks *)tracks;
+	return (libmv_Tracks *)libmv_tracks;
 }
 
-void libmv_tracksInsert(struct libmv_Tracks *tracks, int image, int track, double x, double y)
+void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y)
 {
-	((libmv::Tracks*)tracks)->Insert(image, track, x, y);
+	((libmv::Tracks*)libmv_tracks)->Insert(image, track, x, y);
 }
 
-void libmv_tracksDestroy(libmv_Tracks *tracks)
+void libmv_tracksDestroy(libmv_Tracks *libmv_tracks)
 {
-	delete (libmv::Tracks*)tracks;
+	delete (libmv::Tracks*)libmv_tracks;
 }
 
 /* ************ Reconstruction solver ************ */
@@ -326,18 +331,18 @@
 {
 	/* Invert the camera intrinsics. */
 	libmv::vector<libmv::Marker> markers = ((libmv::Tracks*)tracks)->AllMarkers();
-	libmv::CameraIntrinsics intrinsics;
 	libmv_Reconstruction *libmv_reconstruction = new libmv_Reconstruction();
 	libmv::Reconstruction *reconstruction = &libmv_reconstruction->reconstruction;
+	libmv::CameraIntrinsics *intrinsics = &libmv_reconstruction->intrinsics;
 
-	intrinsics.SetFocalLength(focal_length, focal_length);
-	intrinsics.SetPrincipalPoint(principal_x, principal_y);
-	intrinsics.SetRadialDistortion(k1, k2, k3);
+	intrinsics->SetFocalLength(focal_length, focal_length);
+	intrinsics->SetPrincipalPoint(principal_x, principal_y);
+	intrinsics->SetRadialDistortion(k1, k2, k3);
 
 	if(focal_length) {
 		/* do a lens undistortion if focal length is non-zero only */
 		for (int i = 0; i < markers.size(); ++i) {
-			intrinsics.InvertIntrinsics(markers[i].x,
+			intrinsics->InvertIntrinsics(markers[i].x,
 				markers[i].y,
 				&(markers[i].x),
 				&(markers[i].y));
@@ -352,8 +357,10 @@
 	libmv::ReconstructTwoFrames(keyframe_markers, reconstruction);
 	libmv::Bundle(normalized_tracks, reconstruction);
 	libmv::CompleteReconstruction(normalized_tracks, reconstruction);
-	libmv_reconstruction->error = libmv::ReprojectionError(*(libmv::Tracks *)tracks, *reconstruction, intrinsics);
 
+	libmv_reconstruction->tracks = *(libmv::Tracks *)tracks;
+	libmv_reconstruction->error = libmv::ReprojectionError(*(libmv::Tracks *)tracks, *reconstruction, *intrinsics);
+
 	return (libmv_Reconstruction *)libmv_reconstruction;
 }
 
@@ -373,6 +380,49 @@
 	return 0;
 }
 
+static libmv::Marker ProjectMarker(const libmv::Point &point, const libmv::Camera &camera,
+			const libmv::CameraIntrinsics &intrinsics) {
+	libmv::Vec3 projected = camera.R * point.X + camera.t;
+	projected /= projected(2);
+
+	libmv::Marker reprojected_marker;
+	intrinsics.ApplyIntrinsics(projected(0), projected(1), &reprojected_marker.x, &reprojected_marker.y);
+
+	reprojected_marker.image = camera.image;
+	reprojected_marker.track = point.track;
+
+	return reprojected_marker;
+}
+
+double libmv_reporojectionErrorForTrack(libmv_Reconstruction *libmv_reconstruction, int track)
+{
+	libmv::Reconstruction *reconstruction = &libmv_reconstruction->reconstruction;
+	libmv::CameraIntrinsics *intrinsics = &libmv_reconstruction->intrinsics;
+	libmv::vector<libmv::Marker> markers =  libmv_reconstruction->tracks.MarkersForTrack(track);
+
+	int num_reprojected = 0;
+	double total_error = 0.0;
+
+	for (int i = 0; i < markers.size(); ++i) {
+		const libmv::Camera *camera = reconstruction->CameraForImage(markers[i].image);
+		const libmv::Point *point = reconstruction->PointForTrack(markers[i].track);
+
+		if (!camera || !point) {
+			continue;
+		}
+
+		num_reprojected++;
+
+		libmv::Marker reprojected_marker = ProjectMarker(*point, *camera, *intrinsics);
+		double ex = reprojected_marker.x - markers[i].x;
+		double ey = reprojected_marker.y - markers[i].y;
+
+		total_error += sqrt(ex*ex + ey*ey);
+	}
+
+	return total_error / num_reprojected;
+}
+
 int libmv_reporojectionCameraForImage(libmv_Reconstruction *libmv_reconstruction, int image, double mat[4][4])
 {
 	libmv::Reconstruction *reconstruction = &libmv_reconstruction->reconstruction;
@@ -406,7 +456,7 @@
 	return 0;
 }
 
-float libmv_reprojectionError(libmv_Reconstruction *libmv_reconstruction)
+double libmv_reprojectionError(libmv_Reconstruction *libmv_reconstruction)
 {
 	return libmv_reconstruction->error;
 }
@@ -421,21 +471,21 @@
 struct libmv_Corners *libmv_detectCorners(unsigned char *data, int width, int height, int stride)
 {
 	std::vector<libmv::Corner> detect= libmv::Detect(data, width, height, stride);
-	std::vector<libmv::Corner> *corners= new std::vector<libmv::Corner>();
+	std::vector<libmv::Corner> *libmv_corners= new std::vector<libmv::Corner>();
 
-	corners->insert(corners->begin(), detect.begin(), detect.end());
+	libmv_corners->insert(libmv_corners->begin(), detect.begin(), detect.end());
 
-	return (libmv_Corners *)corners;
+	return (libmv_Corners *)libmv_corners;
 }
 
-int libmv_countCorners(struct libmv_Corners *corners)
+int libmv_countCorners(struct libmv_Corners *libmv_corners)
 {
-	return ((std::vector<libmv::Corner> *)corners)->size();
+	return ((std::vector<libmv::Corner> *)libmv_corners)->size();
 }
 
-void libmv_getCorner(struct libmv_Corners *corners, int number, float *x, float *y, float *score, float *size)
+void libmv_getCorner(struct libmv_Corners *libmv_corners, int number, double *x, double *y, double *score, double *size)
 {
-	libmv::Corner corner = ((std::vector<libmv::Corner> *)corners)->at(number);
+	libmv::Corner corner = ((std::vector<libmv::Corner> *)libmv_corners)->at(number);
 
 	*x = corner.x;
 	*y = corner.y;
@@ -443,9 +493,9 @@
 	*size = corner.size;
 }
 
-void libmv_destroyCorners(struct libmv_Corners *corners)
+void libmv_destroyCorners(struct libmv_Corners *libmv_corners)
 {
-	delete (std::vector<libmv::Corner> *)corners;
+	delete (std::vector<libmv::Corner> *)libmv_corners;
 }
 
 /* ************ utils ************ */

Modified: branches/soc-2011-salad/extern/libmv/libmv-capi.h
===================================================================
--- branches/soc-2011-salad/extern/libmv/libmv-capi.h	2011-08-05 06:49:02 UTC (rev 39051)
+++ branches/soc-2011-salad/extern/libmv/libmv-capi.h	2011-08-05 06:59:36 UTC (rev 39052)
@@ -45,30 +45,30 @@
 
 /* RegionTracker */
 struct libmv_RegionTracker *libmv_regionTrackerNew(int max_iterations, int pyramid_level, double tolerance);
-int libmv_regionTrackerTrack(struct libmv_RegionTracker *tracker, const float *ima1, const float *ima2,
+int libmv_regionTrackerTrack(struct libmv_RegionTracker *libmv_tracker, const float *ima1, const float *ima2,
 			int width, int height, int half_window_size,
 			double  x1, double  y1, double *x2, double *y2);
-void libmv_regionTrackerDestroy(struct libmv_RegionTracker *tracker);
+void libmv_regionTrackerDestroy(struct libmv_RegionTracker *libmv_tracker);
 
 /* Tracks */
 struct libmv_Tracks *libmv_tracksNew(void);
-void libmv_tracksInsert(struct libmv_Tracks *tracks, int image, int track, double x, double y);
-void libmv_tracksDestroy(struct libmv_Tracks *tracks);
+void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y);
+void libmv_tracksDestroy(struct libmv_Tracks *libmv_tracks);
 
 /* Reconstruction solver */
 struct libmv_Reconstruction *libmv_solveReconstruction(struct libmv_Tracks *tracks, int keyframe1, int keyframe2,
 			double focal_length, double principal_x, double principal_y, double k1, double k2, double k3);
 int libmv_reporojectionPointForTrack(struct libmv_Reconstruction *libmv_reconstruction, int track, double pos[3]);
+double libmv_reporojectionErrorForTrack(struct libmv_Reconstruction *libmv_reconstruction, int track);
 int libmv_reporojectionCameraForImage(struct libmv_Reconstruction *libmv_reconstruction, int image, double mat[4][4]);

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list