Libmv: Add autotrack API to the C-API

Pretty much straightforward changes, nothing to be mentioned specially.
This commit is contained in:
Sergey Sharybin 2014-06-22 14:53:21 +06:00
parent b15a056230
commit 7013d55580
12 changed files with 770 additions and 6 deletions

View File

@ -66,19 +66,22 @@ if(WITH_LIBMV)
list(APPEND INC_SYS
../Eigen3
${PNG_INCLUDE_DIR}
${PNG_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
)
list(APPEND SRC
intern/autotrack.cc
intern/camera_intrinsics.cc
intern/detector.cc
intern/frame_accessor.cc
intern/homography.cc
intern/image.cc
intern/logging.cc
intern/reconstruction.cc
intern/track_region.cc
intern/tracks.cc
intern/tracksN.cc
libmv/autotrack/autotrack.cc
libmv/autotrack/predict_tracks.cc
libmv/autotrack/tracks.cc
@ -117,14 +120,17 @@ if(WITH_LIBMV)
libmv/tracking/trklt_region_tracker.cc
intern/autotrack.h
intern/camera_intrinsics.h
intern/detector.h
intern/frame_accessor.h
intern/homography.h
intern/image.h
intern/logging.h
intern/reconstruction.h
intern/track_region.h
intern/tracks.h
intern/tracksN.h
libmv/autotrack/autotrack.h
libmv/autotrack/callbacks.h
libmv/autotrack/frame_accessor.h
@ -245,7 +251,7 @@ if(WITH_LIBMV)
endif()
else()
list(APPEND SRC
libmv-capi_stub.cc
intern/stub.cc
)
endif()

View File

@ -159,30 +159,36 @@ if(WITH_LIBMV)
list(APPEND INC_SYS
../Eigen3
\${PNG_INCLUDE_DIR}
\${PNG_INCLUDE_DIRS}
\${ZLIB_INCLUDE_DIRS}
)
list(APPEND SRC
intern/autotrack.cc
intern/camera_intrinsics.cc
intern/detector.cc
intern/frame_accessor.cc
intern/homography.cc
intern/image.cc
intern/logging.cc
intern/reconstruction.cc
intern/track_region.cc
intern/tracks.cc
intern/tracksN.cc
${sources}
${third_sources}
intern/autotrack.h
intern/camera_intrinsics.h
intern/detector.h
intern/frame_accessor.h
intern/homography.h
intern/image.h
intern/logging.h
intern/reconstruction.h
intern/track_region.h
intern/tracks.h
intern/tracksN.h
${headers}
${third_headers}
@ -207,7 +213,7 @@ ${tests}
endif()
else()
list(APPEND SRC
libmv-capi_stub.cc
intern/stub.cc
)
endif()

108
extern/libmv/intern/autotrack.cc vendored Normal file
View File

@ -0,0 +1,108 @@
/*
* ***** 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.
*
* The Original Code is Copyright (C) 2014 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Blender Foundation,
* Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "intern/autotrack.h"
#include "intern/tracksN.h"
#include "intern/utildefines.h"
#include "libmv/autotrack/autotrack.h"
using mv::AutoTrack;
using mv::FrameAccessor;
using mv::Marker;
using libmv::TrackRegionOptions;
using libmv::TrackRegionResult;
libmv_AutoTrack* libmv_autoTrackNew(libmv_FrameAccessor *frame_accessor) {
return (libmv_AutoTrack*) LIBMV_OBJECT_NEW(AutoTrack,
(FrameAccessor*) frame_accessor);
}
void libmv_autoTrackDestroy(libmv_AutoTrack* libmv_autotrack) {
LIBMV_OBJECT_DELETE(libmv_autotrack, AutoTrack);
}
void libmv_autoTrackSetOptions(libmv_AutoTrack* libmv_autotrack,
const libmv_AutoTrackOptions* options) {
AutoTrack *autotrack = ((AutoTrack*) libmv_autotrack);
libmv_configureTrackRegionOptions(options->track_region,
&autotrack->options.track_region);
autotrack->options.search_region.min(0) = options->search_region.min[0];
autotrack->options.search_region.min(1) = options->search_region.min[1];
autotrack->options.search_region.max(0) = options->search_region.max[0];
autotrack->options.search_region.max(1) = options->search_region.max[1];
}
int libmv_autoTrackMarker(libmv_AutoTrack* libmv_autotrack,
const libmv_TrackRegionOptions* libmv_options,
libmv_Marker *libmv_tracked_marker,
libmv_TrackRegionResult* libmv_result) {
Marker tracked_marker;
TrackRegionOptions options;
TrackRegionResult result;
libmv_apiMarkerToMarker(*libmv_tracked_marker, &tracked_marker);
libmv_configureTrackRegionOptions(*libmv_options,
&options);
bool tracking_result
= ((AutoTrack*) libmv_autotrack)->TrackMarker(&tracked_marker,
&result,
&options);
libmv_markerToApiMarker(tracked_marker, libmv_tracked_marker);
libmv_regionTrackergetResult(result, libmv_result);
// TODO(keir): Update the termination string with failure details.
if (result.termination == TrackRegionResult::CONVERGENCE ||
result.termination == TrackRegionResult::NO_CONVERGENCE) {
tracking_result = true;
}
return tracking_result;
}
void libmv_autoTrackAddMarker(libmv_AutoTrack* libmv_autotrack,
const libmv_Marker* libmv_marker) {
Marker marker;
libmv_apiMarkerToMarker(*libmv_marker, &marker);
((AutoTrack*) libmv_autotrack)->AddMarker(marker);
}
int libmv_autoTrackGetMarker(libmv_AutoTrack* libmv_autotrack,
int clip,
int frame,
int track,
libmv_Marker *libmv_marker) {
Marker marker;
int ok = ((AutoTrack*) libmv_autotrack)->GetMarker(clip,
frame,
track,
&marker);
if (ok) {
libmv_markerToApiMarker(marker, libmv_marker);
}
return ok;
}

71
extern/libmv/intern/autotrack.h vendored Normal file
View File

@ -0,0 +1,71 @@
/*
* ***** 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.
*
* The Original Code is Copyright (C) 2014 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Blender Foundation,
* Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef LIBMV_C_API_AUTOTRACK_H_
#define LIBMV_C_API_AUTOTRACK_H_
#include "intern/track_region.h"
#include "intern/region.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct libmv_FrameAccessor libmv_FrameAccessor;
typedef struct libmv_AutoTrack libmv_AutoTrack;
typedef struct libmv_Marker libmv_Marker;
typedef struct libmv_AutoTrackOptions {
libmv_TrackRegionOptions track_region;
libmv_Region search_region;
} libmv_AutoTrackOptions;
libmv_AutoTrack* libmv_autoTrackNew(libmv_FrameAccessor *frame_accessor);
void libmv_autoTrackDestroy(libmv_AutoTrack* libmv_autotrack);
void libmv_autoTrackSetOptions(libmv_AutoTrack* libmv_autotrack,
const libmv_AutoTrackOptions* options);
int libmv_autoTrackMarker(libmv_AutoTrack* libmv_autotrack,
const libmv_TrackRegionOptions* libmv_options,
libmv_Marker *libmv_tracker_marker,
libmv_TrackRegionResult* libmv_result);
void libmv_autoTrackAddMarker(libmv_AutoTrack* libmv_autotrack,
const libmv_Marker* libmv_marker);
int libmv_autoTrackGetMarker(libmv_AutoTrack* libmv_autotrack,
int clip,
int frame,
int track,
libmv_Marker *libmv_marker);
#ifdef __cplusplus
}
#endif
#endif // LIBMV_C_API_TRACKS_H_

164
extern/libmv/intern/frame_accessor.cc vendored Normal file
View File

@ -0,0 +1,164 @@
/*
* ***** 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.
*
* The Original Code is Copyright (C) 2014 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Blender Foundation,
* Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "intern/frame_accessor.h"
#include "intern/image.h"
#include "intern/utildefines.h"
#include "libmv/autotrack/frame_accessor.h"
#include "libmv/autotrack/region.h"
#include "libmv/image/image.h"
namespace {
using libmv::FloatImage;
using mv::FrameAccessor;
using mv::Region;
struct LibmvFrameAccessor : public FrameAccessor {
LibmvFrameAccessor(libmv_FrameAccessorUserData* user_data,
libmv_GetImageCallback get_image_callback,
libmv_ReleaseImageCallback release_image_callback)
: user_data_(user_data),
get_image_callback_(get_image_callback),
release_image_callback_(release_image_callback) { }
libmv_InputMode get_libmv_input_mode(InputMode input_mode) {
switch (input_mode) {
#define CHECK_INPUT_MODE(mode) \
case mode: \
return LIBMV_IMAGE_MODE_ ## mode;
CHECK_INPUT_MODE(MONO)
CHECK_INPUT_MODE(RGBA)
#undef CHECK_INPUT_MODE
}
assert(!"unknown input mode passed from Libmv.");
// TODO(sergey): Proper error handling here in the future.
return LIBMV_IMAGE_MODE_MONO;
}
void get_libmv_region(const Region& region,
libmv_Region* libmv_region) {
libmv_region->min[0] = region.min(0);
libmv_region->min[1] = region.min(1);
libmv_region->max[0] = region.max(0);
libmv_region->max[1] = region.max(1);
}
Key GetImage(int clip,
int frame,
InputMode input_mode,
int downscale,
const Region* region,
const Transform* transform,
FloatImage* destination) {
float *float_buffer;
int width, height, channels;
libmv_Region libmv_region;
if (region) {
get_libmv_region(*region, &libmv_region);
}
Key cache_key = get_image_callback_(user_data_,
clip,
frame,
get_libmv_input_mode(input_mode),
downscale,
region != NULL ? &libmv_region : NULL,
(libmv_FrameTransform*) transform,
&float_buffer,
&width,
&height,
&channels);
// TODO(sergey): Dumb code for until we can set data directly.
FloatImage temp_image(float_buffer,
height,
width,
channels);
destination->CopyFrom(temp_image);
return cache_key;
}
void ReleaseImage(Key cache_key) {
release_image_callback_(cache_key);
}
bool GetClipDimensions(int clip, int *width, int *height) {
return false;
}
int NumClips() {
return 1;
}
int NumFrames(int clip) {
return 0;
}
libmv_FrameAccessorUserData* user_data_;
libmv_GetImageCallback get_image_callback_;
libmv_ReleaseImageCallback release_image_callback_;
};
} // namespace
libmv_FrameAccessor* libmv_FrameAccessorNew(
libmv_FrameAccessorUserData* user_data,
libmv_GetImageCallback get_image_callback,
libmv_ReleaseImageCallback release_image_callback) {
return (libmv_FrameAccessor*) LIBMV_OBJECT_NEW(LibmvFrameAccessor,
user_data,
get_image_callback,
release_image_callback);
}
void libmv_FrameAccessorDestroy(libmv_FrameAccessor* frame_accessor) {
LIBMV_OBJECT_DELETE(frame_accessor, LibmvFrameAccessor);
}
int64_t libmv_frameAccessorgetTransformKey(const libmv_FrameTransform *transform) {
return ((FrameAccessor::Transform*) transform)->key();
}
void libmv_frameAccessorgetTransformRun(const libmv_FrameTransform *transform,
const libmv_FloatImage *input_image,
libmv_FloatImage *output_image) {
const FloatImage input(input_image->buffer,
input_image->width,
input_image->height,
input_image->channels);
FloatImage output;
((FrameAccessor::Transform*) transform)->run(input,
&output);
int num_pixels = output.Width() *output.Height() * output.Depth();
output_image->buffer = new float[num_pixels];
memcpy(output_image->buffer, output.Data(), num_pixels * sizeof(float));
output_image->width = output.Width();
output_image->height = output.Height();
output_image->channels = output.Depth();
}

79
extern/libmv/intern/frame_accessor.h vendored Normal file
View File

@ -0,0 +1,79 @@
/*
* ***** 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.
*
* The Original Code is Copyright (C) 2014 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Blender Foundation,
* Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef LIBMV_C_API_FRAME_ACCESSOR_H_
#define LIBMV_C_API_FRAME_ACCESSOR_H_
#include <stdint.h>
#include "intern/region.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct libmv_FloatImage libmv_FloatImage;
typedef struct libmv_FrameAccessor libmv_FrameAccessor;
typedef struct libmv_FrameTransform libmv_FrameTransform;
typedef struct libmv_FrameAccessorUserData libmv_FrameAccessorUserData;
typedef void *libmv_CacheKey;
typedef enum {
LIBMV_IMAGE_MODE_MONO,
LIBMV_IMAGE_MODE_RGBA,
} libmv_InputMode;
typedef libmv_CacheKey (*libmv_GetImageCallback) (
libmv_FrameAccessorUserData* user_data,
int clip,
int frame,
libmv_InputMode input_mode,
int downscale,
const libmv_Region* region,
const libmv_FrameTransform* transform,
float** destination,
int* width,
int* height,
int* channels);
typedef void (*libmv_ReleaseImageCallback) (libmv_CacheKey cache_key);
libmv_FrameAccessor* libmv_FrameAccessorNew(
libmv_FrameAccessorUserData* user_data,
libmv_GetImageCallback get_image_callback,
libmv_ReleaseImageCallback release_image_callback);
void libmv_FrameAccessorDestroy(libmv_FrameAccessor* frame_accessor);
int64_t libmv_frameAccessorgetTransformKey(const libmv_FrameTransform *transform);
void libmv_frameAccessorgetTransformRun(const libmv_FrameTransform *transform,
const libmv_FloatImage *input_image,
libmv_FloatImage *output_image);
#ifdef __cplusplus
}
#endif
#endif // LIBMV_C_API_FRAME_ACCESSOR_H_

View File

@ -34,7 +34,7 @@
using libmv::FloatImage;
using libmv::SamplePlanarPatch;
void libmv_floatImaheDestroy(libmv_FloatImage *image) {
void libmv_floatImageDestroy(libmv_FloatImage *image) {
delete [] image->buffer;
}

View File

@ -64,7 +64,7 @@ typedef struct libmv_FloatImage {
int channels;
} libmv_FloatImage;
void libmv_floatImaheDestroy(libmv_FloatImage *image);
void libmv_floatImageDestroy(libmv_FloatImage *image);
void libmv_samplePlanarPatchFloat(const float* image,
int width,

View File

@ -97,6 +97,10 @@ void libmv_samplePlanarPatchByte(const unsigned char * /*image*/,
/* TODO(sergey): implement */
}
void libmv_floatImageDestroy(libmv_FloatImage* /*image*/)
{
}
/* ************ Tracks ************ */
libmv_Tracks *libmv_tracksNew(void) {
@ -328,3 +332,68 @@ void libmv_homography2DFromCorrespondencesEuc(/* const */ double (*x1)[2],
H[1][1] = 1.0f;
H[2][2] = 1.0f;
}
/* ************ autotrack ************ */
libmv_AutoTrack* libmv_autoTrackNew(libmv_FrameAccessor* /*frame_accessor*/)
{
return NULL;
}
void libmv_autoTrackDestroy(libmv_AutoTrack* /*libmv_autotrack*/)
{
}
void libmv_autoTrackSetOptions(libmv_AutoTrack* /*libmv_autotrack*/,
const libmv_AutoTrackOptions* /*options*/)
{
}
int libmv_autoTrackMarker(libmv_AutoTrack* /*libmv_autotrack*/,
const libmv_TrackRegionOptions* /*libmv_options*/,
libmv_Marker */*libmv_tracker_marker*/,
libmv_TrackRegionResult* /*libmv_result*/)
{
return 0;
}
void libmv_autoTrackAddMarker(libmv_AutoTrack* /*libmv_autotrack*/,
const libmv_Marker* /*libmv_marker*/)
{
}
int libmv_autoTrackGetMarker(libmv_AutoTrack* /*libmv_autotrack*/,
int /*clip*/,
int /*frame*/,
int /*track*/,
libmv_Marker* /*libmv_marker*/)
{
return 0;
}
/* ************ frame accessor ************ */
libmv_FrameAccessor* libmv_FrameAccessorNew(
libmv_FrameAccessorUserData* /*user_data**/,
libmv_GetImageCallback /*get_image_callback*/,
libmv_ReleaseImageCallback /*release_image_callback*/)
{
return NULL;
}
void libmv_FrameAccessorDestroy(libmv_FrameAccessor* /*frame_accessor*/)
{
}
int64_t libmv_frameAccessorgetTransformKey(
const libmv_FrameTransform */*transform*/)
{
return 0;
}
void libmv_frameAccessorgetTransformRun(const libmv_FrameTransform* /*transform*/,
const libmv_FloatImage* /*input_image*/,
libmv_FloatImage* /*output_image*/)
{
}

136
extern/libmv/intern/tracksN.cc vendored Normal file
View File

@ -0,0 +1,136 @@
/*
* ***** 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.
*
* The Original Code is Copyright (C) 2011 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Blender Foundation,
* Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "intern/tracksN.h"
#include "intern/utildefines.h"
#include "libmv/autotrack/marker.h"
#include "libmv/autotrack/tracks.h"
using mv::Marker;
using mv::Tracks;
void libmv_apiMarkerToMarker(const libmv_Marker& libmv_marker,
Marker *marker) {
marker->clip = libmv_marker.clip;
marker->frame = libmv_marker.frame;
marker->track = libmv_marker.track;
marker->center(0) = libmv_marker.center[0];
marker->center(1) = libmv_marker.center[1];
for (int i = 0; i < 4; i++) {
marker->patch.coordinates(i, 0) = libmv_marker.patch[i][0];
marker->patch.coordinates(i, 1) = libmv_marker.patch[i][1];
}
marker->search_region.min(0) = libmv_marker.search_region_min[0];
marker->search_region.min(1) = libmv_marker.search_region_min[1];
marker->search_region.max(0) = libmv_marker.search_region_max[0];
marker->search_region.max(1) = libmv_marker.search_region_max[1];
marker->weight = libmv_marker.weight;
marker->source = (Marker::Source) libmv_marker.source;
marker->status = (Marker::Status) libmv_marker.status;
marker->reference_clip = libmv_marker.reference_clip;
marker->reference_frame = libmv_marker.reference_frame;
marker->model_type = (Marker::ModelType) libmv_marker.model_type;
marker->model_id = libmv_marker.model_id;
}
void libmv_markerToApiMarker(const Marker& marker,
libmv_Marker *libmv_marker) {
libmv_marker->clip = marker.clip;
libmv_marker->frame = marker.frame;
libmv_marker->track = marker.track;
libmv_marker->center[0] = marker.center(0);
libmv_marker->center[1] = marker.center(1);
for (int i = 0; i < 4; i++) {
libmv_marker->patch[i][0] = marker.patch.coordinates(i, 0);
libmv_marker->patch[i][1] = marker.patch.coordinates(i, 1);
}
libmv_marker->search_region_min[0] = marker.search_region.min(0);
libmv_marker->search_region_min[1] = marker.search_region.min(1);
libmv_marker->search_region_max[0] = marker.search_region.max(0);
libmv_marker->search_region_max[1] = marker.search_region.max(1);
libmv_marker->weight = marker.weight;
libmv_marker->source = (libmv_MarkerSource) marker.source;
libmv_marker->status = (libmv_MarkerStatus) marker.status;
libmv_marker->reference_clip = marker.reference_clip;
libmv_marker->reference_frame = marker.reference_frame;
libmv_marker->model_type = (libmv_MarkerModelType) marker.model_type;
libmv_marker->model_id = marker.model_id;
}
libmv_TracksN* libmv_tracksNewN(void) {
Tracks* tracks = LIBMV_OBJECT_NEW(Tracks);
return (libmv_TracksN*) tracks;
}
void libmv_tracksDestroyN(libmv_TracksN* libmv_tracks) {
LIBMV_OBJECT_DELETE(libmv_tracks, Tracks);
}
void libmv_tracksAddMarkerN(libmv_TracksN* libmv_tracks,
const libmv_Marker* libmv_marker) {
Marker marker;
libmv_apiMarkerToMarker(*libmv_marker, &marker);
((Tracks*) libmv_tracks)->AddMarker(marker);
}
void libmv_tracksGetMarkerN(libmv_TracksN* libmv_tracks,
int clip,
int frame,
int track,
libmv_Marker* libmv_marker) {
Marker marker;
((Tracks*) libmv_tracks)->GetMarker(clip, frame, track, &marker);
libmv_markerToApiMarker(marker, libmv_marker);
}
void libmv_tracksRemoveMarkerN(libmv_TracksN* libmv_tracks,
int clip,
int frame,
int track) {
((Tracks *) libmv_tracks)->RemoveMarker(clip, frame, track);
}
void libmv_tracksRemoveMarkersForTrack(libmv_TracksN* libmv_tracks,
int track) {
((Tracks *) libmv_tracks)->RemoveMarkersForTrack(track);
}
int libmv_tracksMaxClipN(libmv_TracksN* libmv_tracks) {
return ((Tracks*) libmv_tracks)->MaxClip();
}
int libmv_tracksMaxFrameN(libmv_TracksN* libmv_tracks, int clip) {
return ((Tracks*) libmv_tracks)->MaxFrame(clip);
}
int libmv_tracksMaxTrackN(libmv_TracksN* libmv_tracks) {
return ((Tracks*) libmv_tracks)->MaxTrack();
}
int libmv_tracksNumMarkersN(libmv_TracksN* libmv_tracks) {
return ((Tracks*) libmv_tracks)->NumMarkers();
}

122
extern/libmv/intern/tracksN.h vendored Normal file
View File

@ -0,0 +1,122 @@
/*
* ***** 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.
*
* The Original Code is Copyright (C) 2011 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Blender Foundation,
* Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
// TODO(serrgey): For the time being we're converting simple pipeline
// to an autotrack pipeline we call it tracks.
// Once we've done with porting we remove N.
#ifndef LIBMV_C_API_TRACKSN_H_
#define LIBMV_C_API_TRACKSN_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef struct libmv_TracksN libmv_TracksN;
// Keep order in this enums exactly the same as in mv::Marker.
// Otherwise API wouldn't convert the values properly.
typedef enum libmv_MarkerSource {
LIBMV_MARKER_SOURCE_MANUAL,
LIBMV_MARKER_SOURCE_DETECTED,
LIBMV_MARKER_SOURCE_TRACKED,
LIBMV_MARKER_SOURCE_MATCHED,
LIBMV_MARKER_SOURCE_PREDICTED,
} libmv_MarkerSource;
typedef enum libmv_MarkerStatus {
LIBMV_MARKER_STATUS_UNKNOWN,
LIBMV_MARKER_STATUS_INLIER,
LIBMV_MARKER_STATUS_OUTLIER,
} libmv_MarkerStatus;
typedef enum libmv_MarkerModelType {
LIBMV_MARKER_MODEL_TYPE_POINT,
LIBMV_MARKER_MODEL_TYPE_PLANE,
LIBMV_MARKER_MODEL_TYPE_LINE,
LIBMV_MARKER_MODEL_TYPE_CUBE,
} libmv_MarkerModelType;
typedef struct libmv_Marker {
int clip;
int frame;
int track;
float center[2];
float patch[4][2];
float search_region_min[2];
float search_region_max[2];
float weight;
libmv_MarkerSource source;
libmv_MarkerStatus status;
int reference_clip;
int reference_frame;
libmv_MarkerModelType model_type;
int model_id;
} libmv_Marker;
#ifdef __cplusplus
namespace mv {
class Marker;
}
void libmv_apiMarkerToMarker(const libmv_Marker& libmv_marker,
mv::Marker *marker);
void libmv_markerToApiMarker(const mv::Marker& marker,
libmv_Marker *libmv_marker);
#endif
libmv_TracksN* libmv_tracksNewN(void);
void libmv_tracksDestroyN(libmv_TracksN* libmv_tracks);
void libmv_tracksAddMarkerN(libmv_TracksN* libmv_tracks,
const libmv_Marker* libmv_marker);
void libmv_tracksGetMarkerN(libmv_TracksN* libmv_tracks,
int clip,
int frame,
int track,
libmv_Marker* libmv_marker);
void libmv_tracksRemoveMarkerN(libmv_TracksN* libmv_tracks,
int clip,
int frame,
int track);
void libmv_tracksRemoveMarkersForTrack(libmv_TracksN* libmv_tracks,
int track);
int libmv_tracksMaxClipN(libmv_TracksN* libmv_tracks);
int libmv_tracksMaxFrameN(libmv_TracksN* libmv_tracks, int clip);
int libmv_tracksMaxTrackN(libmv_TracksN* libmv_tracks);
int libmv_tracksNumMarkersN(libmv_TracksN* libmv_tracks);
#ifdef __cplusplus
}
#endif
#endif // LIBMV_C_API_TRACKS_H_

View File

@ -27,13 +27,16 @@
#ifndef LIBMV_C_API_H
#define LIBMV_C_API_H
#include "intern/autotrack.h"
#include "intern/camera_intrinsics.h"
#include "intern/detector.h"
#include "intern/frame_accessor.h"
#include "intern/homography.h"
#include "intern/image.h"
#include "intern/logging.h"
#include "intern/reconstruction.h"
#include "intern/track_region.h"
#include "intern/tracks.h"
#include "intern/tracksN.h"
#endif // LIBMV_C_API_H