[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58372] branches/soc-2013-motion_track/ extern/libmv: Modify Tracks and libmv C API for multiview reconstruction
Joseph Mansfield
sftrabbit at gmail.com
Fri Jul 19 02:09:04 CEST 2013
Revision: 58372
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58372
Author: sftrabbit
Date: 2013-07-19 00:09:03 +0000 (Fri, 19 Jul 2013)
Log Message:
-----------
Modify Tracks and libmv C API for multiview reconstruction
Add a view identifier to the Markers that are contained in a Tracks set and the appropriate interface for inserting and fetching from the set according to view. Also modify the libmv C API to allow multiview insertion into Tracks from outside libmv.
Modified Paths:
--------------
branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/tracks.cc
branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/tracks.h
branches/soc-2013-motion_track/extern/libmv/libmv-capi.cc
branches/soc-2013-motion_track/extern/libmv/libmv-capi.h
Modified: branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/tracks.cc
===================================================================
--- branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/tracks.cc 2013-07-18 17:12:00 UTC (rev 58371)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/tracks.cc 2013-07-19 00:09:03 UTC (rev 58372)
@@ -34,25 +34,40 @@
Tracks::Tracks(const vector<Marker> &markers) : markers_(markers) {}
-void Tracks::Insert(int image, int track, double x, double y) {
+void Tracks::Insert(int view, int image, int track, double x, double y) {
// TODO(keir): Wow, this is quadratic for repeated insertions. Fix this by
// adding a smarter data structure like a set<>.
for (int i = 0; i < markers_.size(); ++i) {
- if (markers_[i].image == image &&
+ if (markers_[i].view == view &&
+ markers_[i].image == image &&
markers_[i].track == track) {
markers_[i].x = x;
markers_[i].y = y;
return;
}
}
- Marker marker = { image, track, x, y };
+ Marker marker = { view, image, track, x, y };
markers_.push_back(marker);
}
+void Tracks::Insert(int image, int track, double x, double y) {
+ this->Insert(0, image, track, x, y);
+}
+
vector<Marker> Tracks::AllMarkers() const {
return markers_;
}
+vector<Marker> Tracks::MarkersInView(int view) const {
+ vector<Marker> markers;
+ for (int i = 0; i < markers_.size(); ++i) {
+ if (view == markers_[i].view) {
+ markers.push_back(markers_[i]);
+ }
+ }
+ return markers;
+}
+
vector<Marker> Tracks::MarkersInImage(int image) const {
vector<Marker> markers;
for (int i = 0; i < markers_.size(); ++i) {
@@ -122,10 +137,20 @@
return markers_[i];
}
}
- Marker null = { -1, -1, -1, -1 };
+ Marker null = { -1, -1, -1, -1, -1 };
return null;
}
+void Tracks::RemoveMarkersForView(int view) {
+ int size = 0;
+ for (int i = 0; i < markers_.size(); ++i) {
+ if (markers_[i].view != view) {
+ markers_[size++] = markers_[i];
+ }
+ }
+ markers_.resize(size);
+}
+
void Tracks::RemoveMarkersForTrack(int track) {
int size = 0;
for (int i = 0; i < markers_.size(); ++i) {
@@ -136,16 +161,31 @@
markers_.resize(size);
}
-void Tracks::RemoveMarker(int image, int track) {
+void Tracks::RemoveMarker(int view, int image, int track) {
int size = 0;
for (int i = 0; i < markers_.size(); ++i) {
- if (markers_[i].image != image || markers_[i].track != track) {
+ if (markers_[i].view != view ||
+ markers_[i].image != image ||
+ markers_[i].track != track) {
markers_[size++] = markers_[i];
}
}
markers_.resize(size);
}
+void Tracks::RemoveMarker(int image, int track) {
+ this->RemoveMarker(0, image, track);
+}
+
+int Tracks::MaxView() const {
+ // TODO(MatthiasF): maintain a max_view_ member (updated on Insert)
+ int max_view = 0;
+ for (int i = 0; i < markers_.size(); ++i) {
+ max_view = std::max(markers_[i].view, max_view);
+ }
+ return max_view;
+}
+
int Tracks::MaxImage() const {
// TODO(MatthiasF): maintain a max_image_ member (updated on Insert)
int max_image = 0;
Modified: branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/tracks.h
===================================================================
--- branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/tracks.h 2013-07-18 17:12:00 UTC (rev 58371)
+++ branches/soc-2013-motion_track/extern/libmv/libmv/simple_pipeline/tracks.h 2013-07-19 00:09:03 UTC (rev 58372)
@@ -30,14 +30,17 @@
A Marker is the 2D location of a tracked point in an image.
\a x, \a y is the position of the marker in pixels from the top left corner
- in the image identified by \a image. All markers for to the same target
- form a track identified by a common \a track number.
+ in the image identified by \a image. All markers for the same target
+ form a track identified by a common \a track number. Markers in a
+ particular track but with different \a view numbers correspond to the
+ same target in an alternate view.
\note Markers are typically aggregated with the help of the \l Tracks class.
\sa Tracks
*/
struct Marker {
+ int view;
int image;
int track;
double x, y;
@@ -66,25 +69,36 @@
/*!
Inserts a marker into the set. If there is already a marker for the given
- \a image and \a track, the existing marker is replaced. If there is no
- marker for the given \a image and \a track, a new one is added.
+ \a view, \a image and \a track, the existing marker is replaced. If there
+ is no marker for the given \a view, \a image and \a track, a new one is
+ added.
- \a image and \a track are the keys used to retrieve the markers with the
- other methods in this class.
+ \a view, \a image and \a track are the keys used to retrieve the markers
+ with the other methods in this class.
\note To get an identifier for a new track, use \l MaxTrack() + 1.
*/
+ void Insert(int view, int image, int track, double x, double y);
+
+ /*!
+ Inserts a marker for view 0 into the set. If there is already a marker
+ for view 0 and the given \a image and \a track, the existing marker is
+ replaced. This is a useful shorthand for single view reconstruction.
+ */
void Insert(int image, int track, double x, double y);
/// Returns all the markers.
vector<Marker> AllMarkers() const;
- /// Returns all the markers belonging to a track.
- vector<Marker> MarkersForTrack(int track) const;
+ /// Returns all the markers visible in \a view.
+ vector<Marker> MarkersInView(int view) const;
/// Returns all the markers visible in \a image.
vector<Marker> MarkersInImage(int image) const;
+ /// Returns all the markers belonging to a track.
+ vector<Marker> MarkersForTrack(int track) const;
+
/// Returns all the markers visible in \a image1 and \a image2.
vector<Marker> MarkersInBothImages(int image1, int image2) const;
@@ -99,12 +113,21 @@
/// Returns the marker in \a image belonging to \a track.
Marker MarkerInImageForTrack(int image, int track) const;
+ /// Removes all the markers belonging to \a view.
+ void RemoveMarkersForView(int view);
+
/// Removes all the markers belonging to \a track.
void RemoveMarkersForTrack(int track);
- /// Removes the marker in \a image belonging to \a track.
+ /// Removes the marker in \a image of \a view belonging to \a track.
+ void RemoveMarker(int view, int image, int track);
+
+ /// Removes the marker in \a image of view 0 belonging to \a track.
void RemoveMarker(int image, int track);
+ /// Returns the maximum view identifier used.
+ int MaxView() const;
+
/// Returns the maximum image identifier used.
int MaxImage() const;
Modified: branches/soc-2013-motion_track/extern/libmv/libmv-capi.cc
===================================================================
--- branches/soc-2013-motion_track/extern/libmv/libmv-capi.cc 2013-07-18 17:12:00 UTC (rev 58371)
+++ branches/soc-2013-motion_track/extern/libmv/libmv-capi.cc 2013-07-19 00:09:03 UTC (rev 58372)
@@ -396,6 +396,11 @@
((libmv::Tracks*)libmv_tracks)->Insert(image, track, x, y);
}
+void libmv_tracksInsertMultiview(struct libmv_Tracks *libmv_tracks, int view, int image, int track, double x, double y)
+{
+ ((libmv::Tracks*)libmv_tracks)->Insert(view, image, track, x, y);
+}
+
void libmv_tracksDestroy(libmv_Tracks *libmv_tracks)
{
delete (libmv::Tracks*)libmv_tracks;
@@ -726,24 +731,31 @@
}
libmv_Reconstruction *libmv_solve(const libmv_Tracks *libmv_tracks,
- const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+ const libmv_cameraIntrinsicsOptions libmv_camera_intrinsics_options[],
libmv_reconstructionOptions *libmv_reconstruction_options,
reconstruct_progress_update_cb progress_update_callback,
void *callback_customdata)
{
- if (libmv_reconstruction_options->motion_flag & LIBMV_TRACKING_MOTION_MODAL) {
- return libmv_solveModal(libmv_tracks,
- libmv_camera_intrinsics_options,
- libmv_reconstruction_options,
- progress_update_callback,
- callback_customdata);
+ libmv::Tracks &tracks = *((libmv::Tracks *) libmv_tracks);
+ if (tracks.MaxView() == 0) {
+ if (libmv_reconstruction_options->motion_flag & LIBMV_TRACKING_MOTION_MODAL) {
+ return libmv_solveModal(libmv_tracks,
+ libmv_camera_intrinsics_options,
+ libmv_reconstruction_options,
+ progress_update_callback,
+ callback_customdata);
+ }
+ else {
+ return libmv_solveReconstruction(libmv_tracks,
+ libmv_camera_intrinsics_options,
+ libmv_reconstruction_options,
+ progress_update_callback,
+ callback_customdata);
+ }
}
else {
- return libmv_solveReconstruction(libmv_tracks,
- libmv_camera_intrinsics_options,
- libmv_reconstruction_options,
- progress_update_callback,
- callback_customdata);
+ //TODO(sftrabbit): Perform multiview reconstruction
+ return NULL;
}
}
Modified: branches/soc-2013-motion_track/extern/libmv/libmv-capi.h
===================================================================
--- branches/soc-2013-motion_track/extern/libmv/libmv-capi.h 2013-07-18 17:12:00 UTC (rev 58371)
+++ branches/soc-2013-motion_track/extern/libmv/libmv-capi.h 2013-07-19 00:09:03 UTC (rev 58372)
@@ -74,6 +74,7 @@
/* Tracks */
struct libmv_Tracks *libmv_tracksNew(void);
void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y);
+void libmv_tracksInsertMultiview(struct libmv_Tracks *libmv_tracks, int view, int image, int track, double x, double y);
void libmv_tracksDestroy(struct libmv_Tracks *libmv_tracks);
/* Reconstruction solver */
@@ -112,7 +113,7 @@
typedef void (*reconstruct_progress_update_cb) (void *customdata, double progress, const char *message);
struct libmv_Reconstruction *libmv_solve(const struct libmv_Tracks *libmv_tracks,
- const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list