2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2011 Blender Foundation.
19 * All rights reserved.
21 * Contributor(s): Blender Foundation,
24 * ***** END GPL LICENSE BLOCK *****
34 struct libmv_RegionTracker;
36 struct libmv_Reconstruction;
37 struct libmv_Features;
38 struct libmv_CameraIntrinsics;
41 void libmv_initLogging(const char *argv0);
42 void libmv_startDebugLogging(void);
43 void libmv_setLoggingVerbosity(int verbosity);
46 struct libmv_RegionTracker *libmv_pyramidRegionTrackerNew(int max_iterations, int pyramid_level, int half_window_size, double minimum_correlation);
47 struct libmv_RegionTracker *libmv_hybridRegionTrackerNew(int max_iterations, int half_window_size, double minimum_correlation);
48 struct libmv_RegionTracker *libmv_bruteRegionTrackerNew(int half_window_size, double minimum_correlation);
49 int libmv_regionTrackerTrack(struct libmv_RegionTracker *libmv_tracker, const float *ima1, const float *ima2,
50 int width, int height, double x1, double y1, double *x2, double *y2);
51 void libmv_regionTrackerDestroy(struct libmv_RegionTracker *libmv_tracker);
53 /* TrackRegion (new planar tracker) */
54 struct libmv_trackRegionOptions {
58 int use_normalization;
59 double minimum_correlation;
64 struct libmv_trackRegionResult {
66 const char *termination_reason;
70 int libmv_trackRegion(const struct libmv_trackRegionOptions *options,
71 const float *image1, int image1_width, int image1_height,
72 const float *image2, int image2_width, int image2_height,
73 const double *x1, const double *y1,
74 struct libmv_trackRegionResult *result,
75 double *x2, double *y2);
77 void libmv_samplePlanarPatch(const float *image, int width, int height,
78 int channels, const double *xs, const double *ys,
79 int num_samples_x, int num_samples_y,
80 const float *mask, float *patch,
81 double *warped_position_x, double *warped_position_y);
84 struct libmv_Tracks *libmv_tracksNew(void);
85 void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y);
86 void libmv_tracksDestroy(struct libmv_Tracks *libmv_tracks);
88 /* Reconstruction solver */
89 #define LIBMV_REFINE_FOCAL_LENGTH (1<<0)
90 #define LIBMV_REFINE_PRINCIPAL_POINT (1<<1)
91 #define LIBMV_REFINE_RADIAL_DISTORTION_K1 (1<<2)
92 #define LIBMV_REFINE_RADIAL_DISTORTION_K2 (1<<4)
94 typedef void (*reconstruct_progress_update_cb) (void *customdata, double progress, const char *message);
96 int libmv_refineParametersAreValid(int parameters);
98 struct libmv_Reconstruction *libmv_solveReconstruction(struct libmv_Tracks *tracks, int keyframe1, int keyframe2,
99 int refine_intrinsics, double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
100 reconstruct_progress_update_cb progress_update_callback, void *callback_customdata);
101 struct libmv_Reconstruction *libmv_solveModal(struct libmv_Tracks *tracks, double focal_length,
102 double principal_x, double principal_y, double k1, double k2, double k3,
103 reconstruct_progress_update_cb progress_update_callback, void *callback_customdata);
104 int libmv_reporojectionPointForTrack(struct libmv_Reconstruction *libmv_reconstruction, int track, double pos[3]);
105 double libmv_reporojectionErrorForTrack(struct libmv_Reconstruction *libmv_reconstruction, int track);
106 double libmv_reporojectionErrorForImage(struct libmv_Reconstruction *libmv_reconstruction, int image);
107 int libmv_reporojectionCameraForImage(struct libmv_Reconstruction *libmv_reconstruction, int image, double mat[4][4]);
108 double libmv_reprojectionError(struct libmv_Reconstruction *libmv_reconstruction);
109 void libmv_destroyReconstruction(struct libmv_Reconstruction *libmv_reconstruction);
111 /* feature detector */
112 struct libmv_Features *libmv_detectFeaturesFAST(unsigned char *data, int width, int height, int stride,
113 int margin, int min_trackness, int min_distance);
114 struct libmv_Features *libmv_detectFeaturesMORAVEC(unsigned char *data, int width, int height, int stride,
115 int margin, int count, int min_distance);
116 int libmv_countFeatures(struct libmv_Features *libmv_features);
117 void libmv_getFeature(struct libmv_Features *libmv_features, int number, double *x, double *y, double *score, double *size);
118 void libmv_destroyFeatures(struct libmv_Features *libmv_features);
120 /* camera intrinsics */
121 struct libmv_CameraIntrinsics *libmv_ReconstructionExtractIntrinsics(struct libmv_Reconstruction *libmv_Reconstruction);
123 struct libmv_CameraIntrinsics *libmv_CameraIntrinsicsNew(double focal_length, double principal_x, double principal_y,
124 double k1, double k2, double k3, int width, int height);
126 struct libmv_CameraIntrinsics *libmv_CameraIntrinsicsCopy(struct libmv_CameraIntrinsics *libmvIntrinsics);
128 void libmv_CameraIntrinsicsDestroy(struct libmv_CameraIntrinsics *libmvIntrinsics);
130 void libmv_CameraIntrinsicsUpdate(struct libmv_CameraIntrinsics *libmvIntrinsics, double focal_length,
131 double principal_x, double principal_y, double k1, double k2, double k3, int width, int height);
133 void libmv_CameraIntrinsicsExtract(struct libmv_CameraIntrinsics *libmvIntrinsics, double *focal_length,
134 double *principal_x, double *principal_y, double *k1, double *k2, double *k3, int *width, int *height);
136 void libmv_CameraIntrinsicsUndistortByte(struct libmv_CameraIntrinsics *libmvIntrinsics,
137 unsigned char *src, unsigned char *dst, int width, int height, float overscan, int channels);
139 void libmv_CameraIntrinsicsUndistortFloat(struct libmv_CameraIntrinsics *libmvIntrinsics,
140 float *src, float *dst, int width, int height, float overscan, int channels);
142 void libmv_CameraIntrinsicsDistortByte(struct libmv_CameraIntrinsics *libmvIntrinsics,
143 unsigned char *src, unsigned char *dst, int width, int height, float overscan, int channels);
145 void libmv_CameraIntrinsicsDistortFloat(struct libmv_CameraIntrinsics *libmvIntrinsics,
146 float *src, float *dst, int width, int height, float overscan, int channels);
149 void libmv_undistortByte(double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
150 unsigned char *src, unsigned char *dst, int width, int height, int channels);
151 void libmv_undistortFloat(double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
152 float *src, float *dst, int width, int height, int channels);
154 void libmv_distortByte(double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
155 unsigned char *src, unsigned char *dst, int width, int height, int channels);
156 void libmv_distortFloat(double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
157 float *src, float *dst, int width, int height, int channels);
160 void libmv_applyCameraIntrinsics(double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
161 double x, double y, double *x1, double *y1);
162 void libmv_InvertIntrinsics(double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
163 double x, double y, double *x1, double *y1);
166 void libmv_rigidRegistration(float (*reference_points)[3], float (*points)[3], int total_points,
167 int use_scale, int use_translation, double M[4][4]);
173 #endif // LIBMV_C_API_H