2011-06-10 17:17:25 +00:00
|
|
|
/*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
2011-06-22 14:54:53 +00:00
|
|
|
* The Original Code is Copyright (C) 2011 Blender Foundation.
|
2011-06-10 17:17:25 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation,
|
|
|
|
* Sergey Sharybin
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LIBMV_C_API_H
|
|
|
|
#define LIBMV_C_API_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2011-07-07 17:58:33 +00:00
|
|
|
struct libmv_RegionTracker;
|
|
|
|
struct libmv_Tracks;
|
|
|
|
struct libmv_Reconstruction;
|
2011-08-17 17:12:10 +00:00
|
|
|
struct libmv_Features;
|
2011-09-26 19:00:12 +00:00
|
|
|
struct libmv_CameraIntrinsics;
|
2011-06-10 17:17:25 +00:00
|
|
|
|
2011-07-07 17:58:33 +00:00
|
|
|
/* Logging */
|
|
|
|
void libmv_initLogging(const char *argv0);
|
|
|
|
void libmv_startDebugLogging(void);
|
|
|
|
void libmv_setLoggingVerbosity(int verbosity);
|
|
|
|
|
|
|
|
/* RegionTracker */
|
Improve the KLT tracking behaviour and UI
- Remove the overly-conservative use of libmv's re-track tracker. The re-track
tracker would take a normal tracker such as TRKLT or KLT or pyramid KLT, and
track from frame 1 to 2, then back from the position found in 2 back to 1.
Then, when the reverse-track doesn't match the original track with high
precision, the track is considered "failed". This is a good approach for
fully automatic reconstruction, but is too conservative for supervised
tracking.
The retrack-tracker will return when fully automatic tracking is added.
- Always solve for (dx, dy) in the TRKLT loop even if the linear system is
ill-conditioned. The client (Blender in this case) can still use the solved
position, even though it is less reliable.
- Expose the pyramid level setting to the tracking UI when in KLT tracking
mode. While it was tempting to hide this detail from the user, in reality it
does more harm than good, since the way tracking fails depends on the pyramid
level. For now, exposing the pyramid details is a good compromise.
- Move the settings for the tracking algorithm, including search window,
tracking algorithm, pyramid levels, etc, into the track object instead of a
global movie clip object.
2011-10-30 12:42:56 +00:00
|
|
|
struct libmv_RegionTracker *libmv_regionTrackerNew(int max_iterations, int pyramid_level);
|
2011-08-03 18:28:40 +00:00
|
|
|
int libmv_regionTrackerTrack(struct libmv_RegionTracker *libmv_tracker, const float *ima1, const float *ima2,
|
2011-06-14 16:22:06 +00:00
|
|
|
int width, int height, int half_window_size,
|
2011-06-10 17:17:25 +00:00
|
|
|
double x1, double y1, double *x2, double *y2);
|
2011-08-03 18:28:40 +00:00
|
|
|
void libmv_regionTrackerDestroy(struct libmv_RegionTracker *libmv_tracker);
|
2011-07-07 17:58:33 +00:00
|
|
|
|
2011-08-17 07:16:11 +00:00
|
|
|
/* SAD Tracker */
|
2011-08-17 11:17:18 +00:00
|
|
|
void libmv_SADSamplePattern(unsigned char *image, int stride,
|
2011-08-18 21:20:12 +00:00
|
|
|
float warp[3][2], unsigned char *pattern);
|
2011-08-19 13:41:11 +00:00
|
|
|
float libmv_SADTrackerTrack(unsigned char *pattern, unsigned char *warped, unsigned char *image,
|
|
|
|
int stride, int width, int height, float warp[3][2]);
|
2011-08-17 07:16:11 +00:00
|
|
|
|
2011-07-07 17:58:33 +00:00
|
|
|
/* Tracks */
|
|
|
|
struct libmv_Tracks *libmv_tracksNew(void);
|
2011-08-03 18:28:40 +00:00
|
|
|
void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y);
|
|
|
|
void libmv_tracksDestroy(struct libmv_Tracks *libmv_tracks);
|
2011-07-07 17:58:33 +00:00
|
|
|
|
|
|
|
/* 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);
|
2011-07-30 17:14:07 +00:00
|
|
|
int libmv_reporojectionPointForTrack(struct libmv_Reconstruction *libmv_reconstruction, int track, double pos[3]);
|
2011-08-04 15:40:28 +00:00
|
|
|
double libmv_reporojectionErrorForTrack(struct libmv_Reconstruction *libmv_reconstruction, int track);
|
2011-10-19 12:46:30 +00:00
|
|
|
double libmv_reporojectionErrorForImage(struct libmv_Reconstruction *libmv_reconstruction, int image);
|
2011-07-30 17:14:07 +00:00
|
|
|
int libmv_reporojectionCameraForImage(struct libmv_Reconstruction *libmv_reconstruction, int image, double mat[4][4]);
|
2011-08-03 18:28:40 +00:00
|
|
|
double libmv_reprojectionError(struct libmv_Reconstruction *libmv_reconstruction);
|
2011-07-30 17:14:07 +00:00
|
|
|
void libmv_destroyReconstruction(struct libmv_Reconstruction *libmv_reconstruction);
|
2011-06-10 17:17:25 +00:00
|
|
|
|
2011-07-15 20:44:19 +00:00
|
|
|
/* feature detector */
|
2011-10-13 17:54:05 +00:00
|
|
|
struct libmv_Features *libmv_detectFeaturesFAST(unsigned char *data, int width, int height, int stride,
|
|
|
|
int margin, int min_trackness, int min_distance);
|
|
|
|
struct libmv_Features *libmv_detectFeaturesMORAVEC(unsigned char *data, int width, int height, int stride,
|
2011-08-17 17:12:10 +00:00
|
|
|
int margin, int count, int min_distance);
|
|
|
|
int libmv_countFeatures(struct libmv_Features *libmv_features);
|
|
|
|
void libmv_getFeature(struct libmv_Features *libmv_features, int number, double *x, double *y, double *score, double *size);
|
|
|
|
void libmv_destroyFeatures(struct libmv_Features *libmv_features);
|
2011-07-15 20:44:19 +00:00
|
|
|
|
2011-09-26 19:00:12 +00:00
|
|
|
/* camera intrinsics */
|
|
|
|
struct libmv_CameraIntrinsics *libmv_CameraIntrinsicsNew(double focal_length, double principal_x, double principal_y,
|
2011-09-28 13:31:32 +00:00
|
|
|
double k1, double k2, double k3, int width, int height);
|
2011-09-26 19:00:12 +00:00
|
|
|
|
2011-10-07 19:21:29 +00:00
|
|
|
struct libmv_CameraIntrinsics *libmv_CameraIntrinsicsCopy(struct libmv_CameraIntrinsics *libmvIntrinsics);
|
|
|
|
|
2011-10-09 20:28:29 +00:00
|
|
|
struct libmv_CameraIntrinsics *libmv_CameraIntrinsicsCopy(struct libmv_CameraIntrinsics *libmvIntrinsics);
|
|
|
|
|
2011-09-26 19:00:12 +00:00
|
|
|
void libmv_CameraIntrinsicsDestroy(struct libmv_CameraIntrinsics *libmvIntrinsics);
|
|
|
|
|
|
|
|
void libmv_CameraIntrinsicsUpdate(struct libmv_CameraIntrinsics *libmvIntrinsics, double focal_length,
|
2011-09-28 13:31:32 +00:00
|
|
|
double principal_x, double principal_y, double k1, double k2, double k3, int width, int height);
|
2011-09-26 19:00:12 +00:00
|
|
|
|
|
|
|
void libmv_CameraIntrinsicsUndistortByte(struct libmv_CameraIntrinsics *libmvIntrinsics,
|
2011-10-09 20:28:29 +00:00
|
|
|
unsigned char *src, unsigned char *dst, int width, int height, float overscan, int channels);
|
2011-09-26 19:00:12 +00:00
|
|
|
|
|
|
|
void libmv_CameraIntrinsicsUndistortFloat(struct libmv_CameraIntrinsics *libmvIntrinsics,
|
2011-10-09 20:28:29 +00:00
|
|
|
float *src, float *dst, int width, int height, float overscan, int channels);
|
2011-09-26 19:00:12 +00:00
|
|
|
|
|
|
|
void libmv_CameraIntrinsicsDistortByte(struct libmv_CameraIntrinsics *libmvIntrinsics,
|
2011-10-09 20:28:29 +00:00
|
|
|
unsigned char *src, unsigned char *dst, int width, int height, float overscan, int channels);
|
2011-09-26 19:00:12 +00:00
|
|
|
|
|
|
|
void libmv_CameraIntrinsicsDistortFloat(struct libmv_CameraIntrinsics *libmvIntrinsics,
|
2011-10-09 20:28:29 +00:00
|
|
|
float *src, float *dst, int width, int height, float overscan, int channels);
|
2011-09-26 19:00:12 +00:00
|
|
|
|
2011-08-12 21:56:08 +00:00
|
|
|
/* dsitortion */
|
|
|
|
void libmv_undistortByte(double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
|
|
|
|
unsigned char *src, unsigned char *dst, int width, int height, int channels);
|
|
|
|
void libmv_undistortFloat(double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
|
|
|
|
float *src, float *dst, int width, int height, int channels);
|
|
|
|
|
|
|
|
void libmv_distortByte(double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
|
|
|
|
unsigned char *src, unsigned char *dst, int width, int height, int channels);
|
|
|
|
void libmv_distortFloat(double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
|
|
|
|
float *src, float *dst, int width, int height, int channels);
|
|
|
|
|
2011-07-11 09:04:00 +00:00
|
|
|
/* utils */
|
|
|
|
void libmv_applyCameraIntrinsics(double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
|
|
|
|
double x, double y, double *x1, double *y1);
|
2011-07-20 20:31:25 +00:00
|
|
|
void libmv_InvertIntrinsics(double focal_length, double principal_x, double principal_y, double k1, double k2, double k3,
|
|
|
|
double x, double y, double *x1, double *y1);
|
2011-07-11 09:04:00 +00:00
|
|
|
|
2011-06-10 17:17:25 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // LIBMV_C_API_H
|