[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58765] trunk/blender: Code cleanup: libmv C API
Joseph Mansfield
sftrabbit at gmail.com
Wed Jul 31 15:48:12 CEST 2013
Revision: 58765
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58765
Author: sftrabbit
Date: 2013-07-31 13:48:12 +0000 (Wed, 31 Jul 2013)
Log Message:
-----------
Code cleanup: libmv C API
Clean up inconsistencies in the libmv C API:
- All type identifiers are libmv_TypeName
- All function identifiers libmv_functionName
- Prefer libmv_nounVerb function names (e.g. libmv_featuresDestroy)
- Match Blender code formatting rather than Google
- Spelling corrections
Code review: https://codereview.appspot.com/11494044/
Modified Paths:
--------------
trunk/blender/extern/libmv/libmv-capi.cc
trunk/blender/extern/libmv/libmv-capi.h
trunk/blender/extern/libmv/libmv-capi_stub.cc
trunk/blender/source/blender/blenkernel/intern/tracking.c
Modified: trunk/blender/extern/libmv/libmv-capi.cc
===================================================================
--- trunk/blender/extern/libmv/libmv-capi.cc 2013-07-31 12:26:03 UTC (rev 58764)
+++ trunk/blender/extern/libmv/libmv-capi.cc 2013-07-31 13:48:12 UTC (rev 58765)
@@ -62,7 +62,7 @@
# define snprintf _snprintf
#endif
-typedef struct libmv_Reconstruction {
+struct libmv_Reconstruction {
libmv::EuclideanReconstruction reconstruction;
/* used for per-track average error calculation after reconstruction */
@@ -70,12 +70,12 @@
libmv::CameraIntrinsics intrinsics;
double error;
-} libmv_Reconstruction;
+};
-typedef struct libmv_Features {
+struct libmv_Features {
int count, margin;
libmv::Feature *features;
-} libmv_Features;
+};
/* ************ Logging ************ */
@@ -197,30 +197,30 @@
int x, y;
png_bytep *row_pointers;
- row_pointers= (png_bytep*)malloc(sizeof(png_bytep)*image.Height());
+ row_pointers = (png_bytep *) malloc(sizeof(png_bytep) * image.Height());
for (y = 0; y < image.Height(); y++) {
- row_pointers[y]= (png_bytep)malloc(sizeof(png_byte)*4*image.Width());
+ row_pointers[y] = (png_bytep) malloc(sizeof(png_byte) * 4 * image.Width());
for (x = 0; x < image.Width(); x++) {
if (x0 == x && image.Height() - y0 - 1 == y) {
- row_pointers[y][x*4+0]= 255;
- row_pointers[y][x*4+1]= 0;
- row_pointers[y][x*4+2]= 0;
- row_pointers[y][x*4+3]= 255;
+ row_pointers[y][x * 4 + 0] = 255;
+ row_pointers[y][x * 4 + 1] = 0;
+ row_pointers[y][x * 4 + 2] = 0;
+ row_pointers[y][x * 4 + 3] = 255;
}
else {
float pixel = image(image.Height() - y - 1, x, 0);
- row_pointers[y][x*4+0]= pixel*255;
- row_pointers[y][x*4+1]= pixel*255;
- row_pointers[y][x*4+2]= pixel*255;
- row_pointers[y][x*4+3]= 255;
+ row_pointers[y][x * 4 + 0] = pixel * 255;
+ row_pointers[y][x * 4 + 1] = pixel * 255;
+ row_pointers[y][x * 4 + 2] = pixel * 255;
+ row_pointers[y][x * 4 + 3] = 255;
}
}
}
{
- static int a= 0;
+ static int a = 0;
char buf[128];
snprintf(buf, sizeof(buf), "%s_%02d.png", prefix, ++a);
savePNGImage(row_pointers, image.Width(), image.Height(), 8, PNG_COLOR_TYPE_RGBA, buf);
@@ -237,17 +237,17 @@
int x, y;
png_bytep *row_pointers;
- row_pointers= (png_bytep*)malloc(sizeof(png_bytep)*height);
+ row_pointers = (png_bytep *) malloc(sizeof(png_bytep) * height);
for (y = 0; y < height; y++) {
- row_pointers[y]= (png_bytep)malloc(sizeof(png_byte)*4*width);
+ row_pointers[y] = (png_bytep) malloc(sizeof(png_byte) * 4 * width);
for (x = 0; x < width; x++) {
- char pixel = data[width*y+x];
- row_pointers[y][x*4+0]= pixel;
- row_pointers[y][x*4+1]= pixel;
- row_pointers[y][x*4+2]= pixel;
- row_pointers[y][x*4+3]= 255;
+ char pixel = data[width * y + x];
+ row_pointers[y][x * 4 + 0] = pixel;
+ row_pointers[y][x * 4 + 1] = pixel;
+ row_pointers[y][x * 4 + 2] = pixel;
+ row_pointers[y][x * 4 + 3] = 255;
}
}
@@ -267,12 +267,12 @@
/* ************ Planar tracker ************ */
-/* TrackRegion (new planar tracker) */
-int libmv_trackRegion(const struct libmv_trackRegionOptions *options,
+/* TrackRegion */
+int libmv_trackRegion(const libmv_TrackRegionOptions *options,
const float *image1, int image1_width, int image1_height,
const float *image2, int image2_width, int image2_height,
const double *x1, const double *y1,
- struct libmv_trackRegionResult *result,
+ libmv_TrackRegionResult *result,
double *x2, double *y2)
{
double xx1[5], yy1[5];
@@ -292,7 +292,7 @@
switch (options->motion_model) {
#define LIBMV_CONVERT(the_model) \
- case libmv::TrackRegionOptions::the_model: \
+ case libmv::TrackRegionOptions::the_model: \
track_region_options.mode = libmv::TrackRegionOptions::the_model; \
break;
LIBMV_CONVERT(TRANSLATION)
@@ -384,29 +384,28 @@
/* ************ Tracks ************ */
-libmv_Tracks *libmv_tracksNew(void)
+struct libmv_Tracks *libmv_tracksNew(void)
{
libmv::Tracks *libmv_tracks = new libmv::Tracks();
- return (libmv_Tracks *)libmv_tracks;
+ return (struct libmv_Tracks *)libmv_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)
{
- ((libmv::Tracks*)libmv_tracks)->Insert(image, track, x, y);
+ delete (libmv::Tracks*) libmv_tracks;
}
-void libmv_tracksDestroy(libmv_Tracks *libmv_tracks)
+void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y)
{
- delete (libmv::Tracks*)libmv_tracks;
+ ((libmv::Tracks*) libmv_tracks)->Insert(image, track, x, y);
}
-/* ************ Reconstruction solver ************ */
+/* ************ Reconstruction ************ */
class ReconstructUpdateCallback : public libmv::ProgressUpdateCallback {
public:
- ReconstructUpdateCallback(reconstruct_progress_update_cb progress_update_callback,
- void *callback_customdata)
+ ReconstructUpdateCallback(reconstruct_progress_update_cb progress_update_callback, void *callback_customdata)
{
progress_update_callback_ = progress_update_callback;
callback_customdata_ = callback_customdata;
@@ -414,7 +413,7 @@
void invoke(double progress, const char *message)
{
- if(progress_update_callback_) {
+ if (progress_update_callback_) {
progress_update_callback_(callback_customdata_, progress, message);
}
}
@@ -456,7 +455,7 @@
intrinsics);
}
-static void cameraIntrinsicsFromOptions(const libmv_cameraIntrinsicsOptions *camera_intrinsics_options,
+static void cameraIntrinsicsFromOptions(const libmv_CameraIntrinsicsOptions *camera_intrinsics_options,
libmv::CameraIntrinsics *camera_intrinsics)
{
camera_intrinsics->SetFocalLength(camera_intrinsics_options->focal_length,
@@ -486,7 +485,7 @@
}
static void finishReconstruction(const libmv::Tracks &tracks, const libmv::CameraIntrinsics &camera_intrinsics,
- libmv_Reconstruction *libmv_reconstruction,
+ struct libmv_Reconstruction *libmv_reconstruction,
reconstruct_progress_update_cb progress_update_callback,
void *callback_customdata)
{
@@ -571,13 +570,13 @@
return true;
}
-libmv_Reconstruction *libmv_solveReconstruction(const libmv_Tracks *libmv_tracks,
- const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
- libmv_reconstructionOptions *libmv_reconstruction_options,
- reconstruct_progress_update_cb progress_update_callback,
- void *callback_customdata)
+struct libmv_Reconstruction *libmv_solveReconstruction(const struct libmv_Tracks *libmv_tracks,
+ const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+ libmv_ReconstructionOptions *libmv_reconstruction_options,
+ reconstruct_progress_update_cb progress_update_callback,
+ void *callback_customdata)
{
- libmv_Reconstruction *libmv_reconstruction = new libmv_Reconstruction();
+ struct libmv_Reconstruction *libmv_reconstruction = new libmv_Reconstruction();
libmv::Tracks &tracks = *((libmv::Tracks *) libmv_tracks);
libmv::EuclideanReconstruction &reconstruction = libmv_reconstruction->reconstruction;
@@ -650,16 +649,16 @@
finishReconstruction(tracks, camera_intrinsics, libmv_reconstruction,
progress_update_callback, callback_customdata);
- return (libmv_Reconstruction *)libmv_reconstruction;
+ return (struct libmv_Reconstruction *)libmv_reconstruction;
}
-struct libmv_Reconstruction *libmv_solveModal(const libmv_Tracks *libmv_tracks,
- const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
- const libmv_reconstructionOptions *libmv_reconstruction_options,
- reconstruct_progress_update_cb progress_update_callback,
- void *callback_customdata)
+struct libmv_Reconstruction *libmv_solveModal(const struct libmv_Tracks *libmv_tracks,
+ const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
+ const libmv_ReconstructionOptions *libmv_reconstruction_options,
+ reconstruct_progress_update_cb progress_update_callback,
+ void *callback_customdata)
{
- libmv_Reconstruction *libmv_reconstruction = new libmv_Reconstruction();
+ struct libmv_Reconstruction *libmv_reconstruction = new libmv_Reconstruction();
libmv::Tracks &tracks = *((libmv::Tracks *) libmv_tracks);
libmv::EuclideanReconstruction &reconstruction = libmv_reconstruction->reconstruction;
@@ -697,15 +696,20 @@
finishReconstruction(tracks, camera_intrinsics, libmv_reconstruction,
progress_update_callback, callback_customdata);
- return (libmv_Reconstruction *)libmv_reconstruction;
+ return (struct libmv_Reconstruction *)libmv_reconstruction;
}
-int libmv_reporojectionPointForTrack(const libmv_Reconstruction *libmv_reconstruction, int track, double pos[3])
+void libmv_reconstructionDestroy(struct libmv_Reconstruction *libmv_reconstruction)
{
+ delete libmv_reconstruction;
+}
+
+int libmv_reprojectionPointForTrack(const struct libmv_Reconstruction *libmv_reconstruction, int track, double pos[3])
+{
const libmv::EuclideanReconstruction *reconstruction = &libmv_reconstruction->reconstruction;
const libmv::EuclideanPoint *point = reconstruction->PointForTrack(track);
- if(point) {
+ if (point) {
pos[0] = point->X[0];
pos[1] = point->X[2];
pos[2] = point->X[1];
@@ -732,7 +736,7 @@
return reprojected_marker;
}
-double libmv_reporojectionErrorForTrack(const libmv_Reconstruction *libmv_reconstruction, int track)
+double libmv_reprojectionErrorForTrack(const struct libmv_Reconstruction *libmv_reconstruction, int track)
{
const libmv::EuclideanReconstruction *reconstruction = &libmv_reconstruction->reconstruction;
const libmv::CameraIntrinsics *intrinsics = &libmv_reconstruction->intrinsics;
@@ -755,13 +759,13 @@
double ex = reprojected_marker.x - markers[i].x;
double ey = reprojected_marker.y - markers[i].y;
- total_error += sqrt(ex*ex + ey*ey);
+ total_error += sqrt(ex * ex + ey * ey);
}
return total_error / num_reprojected;
}
-double libmv_reporojectionErrorForImage(const libmv_Reconstruction *libmv_reconstruction, int image)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list