mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-07 03:03:00 +02:00
Goodbye, skeltrack. You won't be missed.
This commit is contained in:
parent
5ef400b193
commit
f83c16e578
15 changed files with 0 additions and 3638 deletions
|
@ -1,44 +0,0 @@
|
|||
# Try to find the Skeltrack library to perform skeleton tracking via depth camera
|
||||
#
|
||||
# You must provide a SKELTRACK_ROOT_DIR which contains lib and include directories
|
||||
#
|
||||
# Once done this will define
|
||||
#
|
||||
# SKELTRACK_FOUND - system found Skeltrack
|
||||
# SKELTRACK_INCLUDE_DIRS - the Skeltrack include directory
|
||||
# SKELTRACK_LIBRARIES - Link this to use Skeltrack
|
||||
#
|
||||
# Created on 6/25/2013 by Andrzej Kapolka
|
||||
# Copyright (c) 2013 High Fidelity
|
||||
#
|
||||
|
||||
if (SKELTRACK_LIBRARIES AND SKELTRACK_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
set(SKELTRACK_FOUND TRUE)
|
||||
else (SKELTRACK_LIBRARIES AND SKELTRACK_INCLUDE_DIRS)
|
||||
find_path(SKELTRACK_INCLUDE_DIRS skeltrack.h ${SKELTRACK_ROOT_DIR}/include)
|
||||
|
||||
if (APPLE)
|
||||
find_library(SKELTRACK_LIBRARIES libskeltrack.a ${SKELTRACK_ROOT_DIR}/lib/MacOS/)
|
||||
elseif (UNIX)
|
||||
find_library(SKELTRACK_LIBRARIES libskeltrack.a ${SKELTRACK_ROOT_DIR}/lib/UNIX/)
|
||||
endif ()
|
||||
|
||||
if (SKELTRACK_INCLUDE_DIRS AND SKELTRACK_LIBRARIES)
|
||||
set(SKELTRACK_FOUND TRUE)
|
||||
endif (SKELTRACK_INCLUDE_DIRS AND SKELTRACK_LIBRARIES)
|
||||
|
||||
if (SKELTRACK_FOUND)
|
||||
if (NOT SKELTRACK_FIND_QUIETLY)
|
||||
message(STATUS "Found Skeltrack: ${SKELTRACK_LIBRARIES}")
|
||||
endif (NOT SKELTRACK_FIND_QUIETLY)
|
||||
else (SKELTRACK_FOUND)
|
||||
if (SKELTRACK_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could not find Skeltrack")
|
||||
endif (SKELTRACK_FIND_REQUIRED)
|
||||
endif (SKELTRACK_FOUND)
|
||||
|
||||
# show the SKELTRACK_INCLUDE_DIRS and SKELTRACK_LIBRARIES variables only in the advanced view
|
||||
mark_as_advanced(SKELTRACK_INCLUDE_DIRS SKELTRACK_LIBRARIES)
|
||||
|
||||
endif (SKELTRACK_LIBRARIES AND SKELTRACK_INCLUDE_DIRS)
|
1
interface/external/skeltrack/AUTHORS
vendored
1
interface/external/skeltrack/AUTHORS
vendored
|
@ -1 +0,0 @@
|
|||
Joaquim Rocha <jrocha@igalia.com> - Creator
|
14
interface/external/skeltrack/CMakeLists.txt
vendored
14
interface/external/skeltrack/CMakeLists.txt
vendored
|
@ -1,14 +0,0 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
include_directories(include)
|
||||
|
||||
# grab the implementation and header files from src dirs
|
||||
file(GLOB SKELTRACK_SRCS src/*.c include/*.h)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(GLIB2 glib-2.0)
|
||||
|
||||
string(REPLACE ";" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GLIB2_STATIC_CFLAGS} ${GLIB2_STATIC_LDFLAGS}")
|
||||
message("${CMAKE_C_FLAGS}")
|
||||
|
||||
add_library(skeltrack ${SKELTRACK_SRCS})
|
||||
|
165
interface/external/skeltrack/COPYING
vendored
165
interface/external/skeltrack/COPYING
vendored
|
@ -1,165 +0,0 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
|
@ -1,90 +0,0 @@
|
|||
/*
|
||||
* skeltrak-joint.h
|
||||
*
|
||||
* Skeltrack - A Free Software skeleton tracking library
|
||||
* Copyright (C) 2012 Igalia S.L.
|
||||
*
|
||||
* Authors:
|
||||
* Joaquim Rocha <jrocha@igalia.com>
|
||||
* Eduardo Lima Mitev <elima@igalia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* version 3, or (at your option) any later version as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License at http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef __SKELTRACK_JOINT_H__
|
||||
#define __SKELTRACK_JOINT_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SKELTRACK_TYPE_JOINT (skeltrack_joint_get_type ())
|
||||
#define SKELTRACK_JOINT_MAX_JOINTS 7
|
||||
|
||||
typedef struct _SkeltrackJoint SkeltrackJoint;
|
||||
typedef SkeltrackJoint **SkeltrackJointList;
|
||||
|
||||
/**
|
||||
* SkeltrackJointId:
|
||||
* @SKELTRACK_JOINT_ID_HEAD: The head
|
||||
* @SKELTRACK_JOINT_ID_LEFT_SHOULDER: The left shoulder
|
||||
* @SKELTRACK_JOINT_ID_RIGHT_SHOULDER: The right shoulder
|
||||
* @SKELTRACK_JOINT_ID_LEFT_ELBOW: The left elbow
|
||||
* @SKELTRACK_JOINT_ID_RIGHT_ELBOW: The right elbow
|
||||
* @SKELTRACK_JOINT_ID_LEFT_HAND: The left hand
|
||||
* @SKELTRACK_JOINT_ID_RIGHT_HAND: The right hand
|
||||
*
|
||||
* Available joint ids.
|
||||
**/
|
||||
typedef enum {
|
||||
SKELTRACK_JOINT_ID_HEAD,
|
||||
SKELTRACK_JOINT_ID_LEFT_SHOULDER,
|
||||
SKELTRACK_JOINT_ID_RIGHT_SHOULDER,
|
||||
SKELTRACK_JOINT_ID_LEFT_ELBOW,
|
||||
SKELTRACK_JOINT_ID_RIGHT_ELBOW,
|
||||
SKELTRACK_JOINT_ID_LEFT_HAND,
|
||||
SKELTRACK_JOINT_ID_RIGHT_HAND
|
||||
} SkeltrackJointId;
|
||||
|
||||
/**
|
||||
* SkeltrackJoint:
|
||||
* @id: The id of the joint
|
||||
* @x: The x coordinate of the joint in the space (in mm)
|
||||
* @y: The y coordinate of the joint in the space (in mm)
|
||||
* @z: The z coordinate of the joint in the space (in mm)
|
||||
* @screen_x: The x coordinate of the joint in the screen (in pixels)
|
||||
* @screen_y: The y coordinate of the joint in the screen (in pixels)
|
||||
**/
|
||||
struct _SkeltrackJoint
|
||||
{
|
||||
SkeltrackJointId id;
|
||||
|
||||
gint x;
|
||||
gint y;
|
||||
gint z;
|
||||
|
||||
gint screen_x;
|
||||
gint screen_y;
|
||||
};
|
||||
|
||||
GType skeltrack_joint_get_type (void);
|
||||
gpointer skeltrack_joint_copy (SkeltrackJoint *joint);
|
||||
void skeltrack_joint_free (SkeltrackJoint *joint);
|
||||
void skeltrack_joint_list_free (SkeltrackJointList list);
|
||||
SkeltrackJointList skeltrack_joint_list_new (void);
|
||||
SkeltrackJoint * skeltrack_joint_list_get_joint (SkeltrackJointList list,
|
||||
SkeltrackJointId id);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __SKELTRACK_JOINT_H__ */
|
|
@ -1,95 +0,0 @@
|
|||
/*
|
||||
* skeltrack.h
|
||||
*
|
||||
* Skeltrack - A Free Software skeleton tracking library
|
||||
* Copyright (C) 2012 Igalia S.L.
|
||||
*
|
||||
* Authors:
|
||||
* Joaquim Rocha <jrocha@igalia.com>
|
||||
* Eduardo Lima Mitev <elima@igalia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* version 3, or (at your option) any later version as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License at http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef __SKELTRACK_SKELETON_H__
|
||||
#define __SKELTRACK_SKELETON_H__
|
||||
|
||||
#include <skeltrack-joint.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SKELTRACK_TYPE_SKELETON (skeltrack_skeleton_get_type ())
|
||||
#define SKELTRACK_SKELETON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SKELTRACK_TYPE_SKELETON, SkeltrackSkeleton))
|
||||
#define SKELTRACK_SKELETON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SKELTRACK_TYPE_SKELETON, SkeltrackSkeletonClass))
|
||||
#define SKELTRACK_IS_SKELETON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SKELTRACK_TYPE_SKELETON))
|
||||
#define SKELTRACK_IS_SKELETON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SKELTRACK_TYPE_SKELETON))
|
||||
#define SKELTRACK_SKELETON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SKELTRACK_TYPE_SKELETON, SkeltrackSkeletonClass))
|
||||
|
||||
typedef struct _SkeltrackSkeleton SkeltrackSkeleton;
|
||||
typedef struct _SkeltrackSkeletonClass SkeltrackSkeletonClass;
|
||||
typedef struct _SkeltrackSkeletonPrivate SkeltrackSkeletonPrivate;
|
||||
|
||||
struct _SkeltrackSkeleton
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
/*< private >*/
|
||||
SkeltrackSkeletonPrivate *priv;
|
||||
};
|
||||
|
||||
/**
|
||||
* SkeltrackSkeletonClass:
|
||||
**/
|
||||
struct _SkeltrackSkeletonClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
GType skeltrack_skeleton_get_type (void) G_GNUC_CONST;
|
||||
|
||||
SkeltrackSkeleton * skeltrack_skeleton_new (void);
|
||||
|
||||
void skeltrack_skeleton_track_joints (SkeltrackSkeleton *self,
|
||||
guint16 *buffer,
|
||||
guint width,
|
||||
guint height,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
SkeltrackJointList skeltrack_skeleton_track_joints_finish (SkeltrackSkeleton *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
SkeltrackJointList skeltrack_skeleton_track_joints_sync (SkeltrackSkeleton *self,
|
||||
guint16 *buffer,
|
||||
guint width,
|
||||
guint height,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
void skeltrack_skeleton_get_focus_point (SkeltrackSkeleton *self,
|
||||
gint *x,
|
||||
gint *y,
|
||||
gint *z);
|
||||
|
||||
void skeltrack_skeleton_set_focus_point (SkeltrackSkeleton *self,
|
||||
gint x,
|
||||
gint y,
|
||||
gint z);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __SKELTRACK_SKELETON_H__ */
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* skeltrack-smooth.h
|
||||
*
|
||||
* Skeltrack - A Free Software skeleton tracking library
|
||||
* Copyright (C) 2012 Igalia S.L.
|
||||
*
|
||||
* Authors:
|
||||
* Joaquim Rocha <jrocha@igalia.com>
|
||||
* Eduardo Lima Mitev <elima@igalia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License at http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include "skeltrack-joint.h"
|
||||
|
||||
typedef struct {
|
||||
SkeltrackJointList smoothed_joints;
|
||||
SkeltrackJointList trend_joints;
|
||||
guint joints_persistency;
|
||||
gfloat smoothing_factor;
|
||||
guint joints_persistency_counter[SKELTRACK_JOINT_MAX_JOINTS];
|
||||
} SmoothData;
|
||||
|
||||
void reset_joints_persistency_counter (SmoothData *smooth_data);
|
||||
|
||||
void smooth_joints (SmoothData *data,
|
||||
SkeltrackJointList new_joints);
|
|
@ -1,127 +0,0 @@
|
|||
/*
|
||||
* skeltrack-util.h
|
||||
*
|
||||
* Skeltrack - A Free Software skeleton tracking library
|
||||
* Copyright (C) 2012 Igalia S.L.
|
||||
*
|
||||
* Authors:
|
||||
* Joaquim Rocha <jrocha@igalia.com>
|
||||
* Eduardo Lima Mitev <elima@igalia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License at http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include "skeltrack-joint.h"
|
||||
|
||||
typedef struct _Label Label;
|
||||
typedef struct _Node Node;
|
||||
|
||||
struct _Label {
|
||||
gint index;
|
||||
Label *parent;
|
||||
GList *nodes;
|
||||
Node *bridge_node;
|
||||
Node *to_node;
|
||||
gint lower_screen_y;
|
||||
gint higher_z;
|
||||
gint lower_z;
|
||||
gdouble normalized_num_nodes;
|
||||
};
|
||||
|
||||
struct _Node {
|
||||
gint i;
|
||||
gint j;
|
||||
gint x;
|
||||
gint y;
|
||||
gint z;
|
||||
GList *neighbors;
|
||||
GList *linked_nodes;
|
||||
Label *label;
|
||||
};
|
||||
|
||||
Node * get_closest_node_to_joint (GList *extremas,
|
||||
SkeltrackJoint *joint,
|
||||
gint *distance);
|
||||
|
||||
Node * get_closest_node (GList *node_list, Node *from);
|
||||
|
||||
Node * get_closest_torso_node (GList *node_list,
|
||||
Node *from,
|
||||
Node *head);
|
||||
|
||||
Label * get_main_component (GList *node_list,
|
||||
Node *from,
|
||||
gdouble min_normalized_nr_nodes);
|
||||
|
||||
Label * label_find (Label *label);
|
||||
|
||||
void label_union (Label *a, Label *b);
|
||||
|
||||
gint get_distance (Node *a, Node *b);
|
||||
|
||||
void free_label (Label *label);
|
||||
|
||||
void clean_labels (GList *labels);
|
||||
|
||||
void free_node (Node *node,
|
||||
gboolean unlink_node_first);
|
||||
|
||||
void clean_nodes (GList *nodes);
|
||||
|
||||
GList * remove_nodes_with_label (GList *nodes,
|
||||
Node **node_matrix,
|
||||
gint width,
|
||||
Label *label);
|
||||
|
||||
Label * get_lowest_index_label (Label **neighbor_labels);
|
||||
|
||||
Label * new_label (gint index);
|
||||
|
||||
void join_components_to_main (GList *nodes,
|
||||
Label *lowest_component_label,
|
||||
guint horizontal_max_distance,
|
||||
guint depth_max_distance,
|
||||
guint graph_distance_threshold);
|
||||
|
||||
void set_joint_from_node (SkeltrackJointList *joints,
|
||||
Node *node,
|
||||
SkeltrackJointId id,
|
||||
gint dimension_reduction);
|
||||
|
||||
gint * create_new_dist_matrix (gint matrix_size);
|
||||
|
||||
gboolean dijkstra_to (GList *nodes,
|
||||
Node *source,
|
||||
Node *target,
|
||||
gint width,
|
||||
gint height,
|
||||
gint *distances,
|
||||
Node **previous);
|
||||
|
||||
void convert_screen_coords_to_mm (guint width,
|
||||
guint height,
|
||||
guint dimension_reduction,
|
||||
guint i,
|
||||
guint j,
|
||||
gint z,
|
||||
gint *x,
|
||||
gint *y);
|
||||
|
||||
void convert_mm_to_screen_coords (guint width,
|
||||
guint height,
|
||||
guint dimension_reduction,
|
||||
gint x,
|
||||
gint y,
|
||||
gint z,
|
||||
guint *i,
|
||||
guint *j);
|
28
interface/external/skeltrack/include/skeltrack.h
vendored
28
interface/external/skeltrack/include/skeltrack.h
vendored
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* skeltrack.h
|
||||
*
|
||||
* skeltrack - A GObject wrapper of the libfreenect library
|
||||
* Copyright (C) 2011 Igalia S.L.
|
||||
*
|
||||
* Authors:
|
||||
* Joaquim Manuel Pereira Rocha <jrocha@igalia.com>
|
||||
* Eduardo Lima Mitev <elima@igalia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* version 3, or (at your option) any later version as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License at http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef __SKELTRACK_H__
|
||||
#define __SKELTRACK_H__
|
||||
|
||||
#include <skeltrack-skeleton.h>
|
||||
|
||||
#endif /* __SKELTRACK_H__ */
|
Binary file not shown.
BIN
interface/external/skeltrack/lib/UNIX/libskeltrack.a
vendored
BIN
interface/external/skeltrack/lib/UNIX/libskeltrack.a
vendored
Binary file not shown.
159
interface/external/skeltrack/src/skeltrack-joint.c
vendored
159
interface/external/skeltrack/src/skeltrack-joint.c
vendored
|
@ -1,159 +0,0 @@
|
|||
/*
|
||||
* skeltrack-joint.c
|
||||
*
|
||||
* Skeltrack - A Free Software skeleton tracking library
|
||||
* Copyright (C) 2012 Igalia S.L.
|
||||
*
|
||||
* Authors:
|
||||
* Joaquim Rocha <jrocha@igalia.com>
|
||||
* Eduardo Lima Mitev <elima@igalia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License at http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:skeltrack-joint
|
||||
* @short_description: Data structure that holds information about
|
||||
* a skeleton joint.
|
||||
*
|
||||
* A #SkeltrackJoint is built automatically by #SkeltrackSkeleton when
|
||||
* it finds a skeleton joint and can be used to get information about it.
|
||||
* Each #SkeltrackJoint holds an id, given by #SkeltrackJointId that indicates
|
||||
* which of the human skeleton joints it represents.
|
||||
*
|
||||
* Spacial information about a joint is given by the @x, @y and @z coordinates.
|
||||
* To represent the joint in a 2D, the variables @screen_x and
|
||||
* @screen_y will indicate the joint's position in the screen and are calculated
|
||||
* taking into account the #SkeltrackSkeleton:dimension-reduction (it will
|
||||
* be multiplied by this value).
|
||||
*
|
||||
* The tracked list of joints is represented by #SkeltrackJointList and given
|
||||
* by skeltrack_skeleton_track_joints_finish().
|
||||
* To get a #SkeltrackJoint from a #SkeltrackJointList object, use the
|
||||
* skeltrack_joint_list_get_joint() indicating the needed #SkeltrackJointId.
|
||||
*
|
||||
* A #SkeltrackJointList can be freed by using skeltrack_joint_list_free().
|
||||
* A #SkeltrackJoint can be copied by skeltrack_joint_copy() and freed by
|
||||
* skeltrack_joint_free().
|
||||
**/
|
||||
|
||||
#include <string.h>
|
||||
#include "skeltrack-joint.h"
|
||||
|
||||
/**
|
||||
* skeltrack_joint_get_type:
|
||||
*
|
||||
* Returns: The registered #GType for #SkeltrackJoint boxed type
|
||||
**/
|
||||
GType
|
||||
skeltrack_joint_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (G_UNLIKELY (type == 0))
|
||||
type = g_boxed_type_register_static ("SkeltrackJoint",
|
||||
(GBoxedCopyFunc) skeltrack_joint_copy,
|
||||
(GBoxedFreeFunc) skeltrack_joint_free);
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* skeltrack_joint_copy:
|
||||
* @joint: The #SkeltrackJoint to copy
|
||||
*
|
||||
* Makes an exact copy of a #SkeltrackJoint object.
|
||||
*
|
||||
* Returns: (transfer full): A newly created #SkeltrackJoint. Use
|
||||
* skeltrack_joint_free() to free it.
|
||||
**/
|
||||
gpointer
|
||||
skeltrack_joint_copy (SkeltrackJoint *joint)
|
||||
{
|
||||
SkeltrackJoint *new_joint;
|
||||
|
||||
if (joint == NULL)
|
||||
return NULL;
|
||||
|
||||
new_joint = g_slice_new0 (SkeltrackJoint);
|
||||
memcpy (new_joint, joint, sizeof (SkeltrackJoint));
|
||||
|
||||
return new_joint;
|
||||
}
|
||||
|
||||
/**
|
||||
* skeltrack_joint_free:
|
||||
* @joint: The #SkeltrackJoint to free
|
||||
*
|
||||
* Frees a #SkeltrackJoint object.
|
||||
**/
|
||||
void
|
||||
skeltrack_joint_free (SkeltrackJoint *joint)
|
||||
{
|
||||
g_slice_free (SkeltrackJoint, joint);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* skeltrack_joint_list_free:
|
||||
* @list: The #SkeltrackJointList to free
|
||||
*
|
||||
* Frees a #SkeltrackJointList object and each #SkeltrackJoint
|
||||
* in it.
|
||||
**/
|
||||
void
|
||||
skeltrack_joint_list_free (SkeltrackJointList list)
|
||||
{
|
||||
gint i;
|
||||
|
||||
if (list == NULL)
|
||||
return;
|
||||
|
||||
for (i = 0; i < SKELTRACK_JOINT_MAX_JOINTS; i++)
|
||||
{
|
||||
g_slice_free (SkeltrackJoint, list[i]);
|
||||
}
|
||||
g_slice_free1 (SKELTRACK_JOINT_MAX_JOINTS * sizeof (SkeltrackJoint *), list);
|
||||
}
|
||||
|
||||
/**
|
||||
* skeltrack_joint_list_get_joint:
|
||||
* @list: The #SkeltrackJointList
|
||||
* @id: The #SkeltrackJointId of the joint to get
|
||||
*
|
||||
* Gets a joint from a list of skeleton joints. The joint
|
||||
* returned needs to be freed by using skeltrack_joint_free() or,
|
||||
* alternatively, the whole list and its joints can be freed by using
|
||||
* skeltrack_joint_list_free().
|
||||
*
|
||||
* Returns: (transfer full): The #SkeltrackJoint that corresponds to
|
||||
* the given @id or %NULL if that joint wasn't found.
|
||||
**/
|
||||
SkeltrackJoint *
|
||||
skeltrack_joint_list_get_joint (SkeltrackJointList list, SkeltrackJointId id)
|
||||
{
|
||||
return list[id];
|
||||
}
|
||||
|
||||
/**
|
||||
* skeltrack_joint_list_new:
|
||||
*
|
||||
* Created a new list of #SkeltrackJointsList with its joints as #NULL.
|
||||
* When it is no longer needed, free it with skeltrack_joint_list_free().
|
||||
*
|
||||
* Returns: (transfer full): A newly allocated #SkeltrackJointList
|
||||
**/
|
||||
SkeltrackJointList
|
||||
skeltrack_joint_list_new (void)
|
||||
{
|
||||
return (SkeltrackJointList) g_slice_alloc0 (SKELTRACK_JOINT_MAX_JOINTS *
|
||||
sizeof (SkeltrackJoint *));
|
||||
}
|
2027
interface/external/skeltrack/src/skeltrack-skeleton.c
vendored
2027
interface/external/skeltrack/src/skeltrack-skeleton.c
vendored
File diff suppressed because it is too large
Load diff
226
interface/external/skeltrack/src/skeltrack-smooth.c
vendored
226
interface/external/skeltrack/src/skeltrack-smooth.c
vendored
|
@ -1,226 +0,0 @@
|
|||
/*
|
||||
* skeltrack-smooth.c
|
||||
*
|
||||
* Skeltrack - A Free Software skeleton tracking library
|
||||
* Copyright (C) 2012 Igalia S.L.
|
||||
*
|
||||
* Authors:
|
||||
* Joaquim Rocha <jrocha@igalia.com>
|
||||
* Eduardo Lima Mitev <elima@igalia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License at http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "skeltrack-smooth.h"
|
||||
|
||||
static gfloat
|
||||
holt_double_exp_formula_st (gfloat alpha,
|
||||
gfloat previous_trend,
|
||||
gfloat current_value,
|
||||
gfloat previous_smoothed_value)
|
||||
{
|
||||
return alpha * current_value +
|
||||
(1.0 - alpha) * (previous_smoothed_value + previous_trend);
|
||||
}
|
||||
|
||||
static gfloat
|
||||
holt_double_exp_formula_bt (gfloat beta,
|
||||
gfloat previous_trend,
|
||||
gfloat current_smoothed_value,
|
||||
gfloat previous_smoothed_value)
|
||||
{
|
||||
return beta * (current_smoothed_value - previous_smoothed_value) +
|
||||
(1.0 - beta) * previous_trend;
|
||||
}
|
||||
|
||||
static void
|
||||
holt_double_exp_joint (gfloat alpha,
|
||||
gfloat beta,
|
||||
SkeltrackJoint *smoothed_joint,
|
||||
SkeltrackJoint *current_joint,
|
||||
SkeltrackJoint *trend_joint)
|
||||
{
|
||||
gfloat new_x, new_y, new_z, new_screen_x, new_screen_y;
|
||||
new_x = holt_double_exp_formula_st (alpha,
|
||||
trend_joint->x,
|
||||
current_joint->x,
|
||||
smoothed_joint->x);
|
||||
new_y = holt_double_exp_formula_st (alpha,
|
||||
trend_joint->y,
|
||||
current_joint->y,
|
||||
smoothed_joint->y);
|
||||
new_z = holt_double_exp_formula_st (alpha,
|
||||
trend_joint->z,
|
||||
current_joint->z,
|
||||
smoothed_joint->z);
|
||||
new_screen_x = holt_double_exp_formula_st (alpha,
|
||||
trend_joint->screen_x,
|
||||
current_joint->screen_x,
|
||||
smoothed_joint->screen_x);
|
||||
new_screen_y = holt_double_exp_formula_st (alpha,
|
||||
trend_joint->screen_y,
|
||||
current_joint->screen_y,
|
||||
smoothed_joint->screen_y);
|
||||
trend_joint->x = holt_double_exp_formula_bt (beta,
|
||||
trend_joint->x,
|
||||
new_x,
|
||||
smoothed_joint->x);
|
||||
trend_joint->y = holt_double_exp_formula_bt (beta,
|
||||
trend_joint->y,
|
||||
new_y,
|
||||
smoothed_joint->y);
|
||||
trend_joint->z = holt_double_exp_formula_bt (beta,
|
||||
trend_joint->z,
|
||||
new_z,
|
||||
smoothed_joint->z);
|
||||
trend_joint->screen_x = holt_double_exp_formula_bt (beta,
|
||||
trend_joint->screen_x,
|
||||
new_screen_x,
|
||||
smoothed_joint->screen_x);
|
||||
trend_joint->screen_y = holt_double_exp_formula_bt (beta,
|
||||
trend_joint->screen_y,
|
||||
new_screen_y,
|
||||
smoothed_joint->screen_y);
|
||||
smoothed_joint->x = new_x;
|
||||
smoothed_joint->y = new_y;
|
||||
smoothed_joint->z = new_z;
|
||||
smoothed_joint->screen_x = new_screen_x;
|
||||
smoothed_joint->screen_y = new_screen_y;
|
||||
}
|
||||
|
||||
void
|
||||
reset_joints_persistency_counter (SmoothData *smooth_data)
|
||||
{
|
||||
guint i;
|
||||
for (i = 0; i < SKELTRACK_JOINT_MAX_JOINTS; i++)
|
||||
{
|
||||
smooth_data->joints_persistency_counter[i] =
|
||||
smooth_data->joints_persistency;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
decrease_joints_persistency (SmoothData *smooth_data)
|
||||
{
|
||||
guint i;
|
||||
for (i = 0; i < SKELTRACK_JOINT_MAX_JOINTS; i++)
|
||||
{
|
||||
SkeltrackJoint *smoothed_joint = NULL;
|
||||
SkeltrackJoint *trend_joint = NULL;
|
||||
|
||||
if (smooth_data->smoothed_joints)
|
||||
smoothed_joint = smooth_data->smoothed_joints[i];
|
||||
if (smooth_data->trend_joints)
|
||||
trend_joint = smooth_data->trend_joints[i];
|
||||
|
||||
if (smoothed_joint != NULL || trend_joint != NULL)
|
||||
{
|
||||
if (smooth_data->joints_persistency_counter[i] > 0)
|
||||
smooth_data->joints_persistency_counter[i]--;
|
||||
else
|
||||
{
|
||||
skeltrack_joint_free (smoothed_joint);
|
||||
skeltrack_joint_free (trend_joint);
|
||||
if (smoothed_joint)
|
||||
smooth_data->smoothed_joints[i] = NULL;
|
||||
if (trend_joint)
|
||||
smooth_data->trend_joints[i] = NULL;
|
||||
smooth_data->joints_persistency_counter[i] = smooth_data->joints_persistency;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
smooth_joints (SmoothData *data,
|
||||
SkeltrackJointList new_joints)
|
||||
{
|
||||
guint i;
|
||||
|
||||
if (new_joints == NULL)
|
||||
{
|
||||
decrease_joints_persistency (data);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data->smoothed_joints == NULL)
|
||||
{
|
||||
data->smoothed_joints = skeltrack_joint_list_new ();
|
||||
for (i = 0; i < SKELTRACK_JOINT_MAX_JOINTS; i++)
|
||||
{
|
||||
data->smoothed_joints[i] = skeltrack_joint_copy (new_joints[i]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (data->trend_joints == NULL)
|
||||
{
|
||||
data->trend_joints = skeltrack_joint_list_new ();
|
||||
}
|
||||
|
||||
for (i = 0; i < SKELTRACK_JOINT_MAX_JOINTS; i++)
|
||||
{
|
||||
SkeltrackJoint *joint, *smoothed_joint, *trend_joint;
|
||||
|
||||
smoothed_joint = data->smoothed_joints[i];
|
||||
trend_joint = data->trend_joints[i];
|
||||
joint = new_joints[i];
|
||||
if (joint == NULL)
|
||||
{
|
||||
if (smoothed_joint != NULL)
|
||||
{
|
||||
if (data->joints_persistency_counter[i] > 0)
|
||||
data->joints_persistency_counter[i]--;
|
||||
else
|
||||
{
|
||||
skeltrack_joint_free (smoothed_joint);
|
||||
skeltrack_joint_free (trend_joint);
|
||||
data->smoothed_joints[i] = NULL;
|
||||
data->trend_joints[i] = NULL;
|
||||
data->joints_persistency_counter[i] = data->joints_persistency;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
data->joints_persistency_counter[i] = data->joints_persistency;
|
||||
|
||||
if (smoothed_joint == NULL)
|
||||
{
|
||||
data->smoothed_joints[i] = skeltrack_joint_copy (joint);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (trend_joint == NULL)
|
||||
{
|
||||
/* First case (when there are only initial values) */
|
||||
trend_joint = g_slice_new0 (SkeltrackJoint);
|
||||
trend_joint->x = joint->x - smoothed_joint->x;
|
||||
trend_joint->y = joint->y - smoothed_joint->y;
|
||||
trend_joint->z = joint->z - smoothed_joint->z;
|
||||
trend_joint->screen_x = joint->screen_x - smoothed_joint->screen_x;
|
||||
trend_joint->screen_y = joint->screen_y - smoothed_joint->screen_y;
|
||||
data->trend_joints[i] = trend_joint;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* @TODO: Check if we should give the control of each factor
|
||||
independently (data-smoothing-factor and trend-smoothing-factor).
|
||||
*/
|
||||
holt_double_exp_joint (data->smoothing_factor,
|
||||
data->smoothing_factor,
|
||||
smoothed_joint,
|
||||
joint,
|
||||
trend_joint);
|
||||
}
|
||||
}
|
||||
}
|
626
interface/external/skeltrack/src/skeltrack-util.c
vendored
626
interface/external/skeltrack/src/skeltrack-util.c
vendored
|
@ -1,626 +0,0 @@
|
|||
/*
|
||||
* skeltrack-util.c
|
||||
*
|
||||
* Skeltrack - A Free Software skeleton tracking library
|
||||
* Copyright (C) 2012 Igalia S.L.
|
||||
*
|
||||
* Authors:
|
||||
* Joaquim Rocha <jrocha@igalia.com>
|
||||
* Eduardo Lima Mitev <elima@igalia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License at http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "skeltrack-util.h"
|
||||
|
||||
/* @TODO: Expose these to the user */
|
||||
static const gfloat SCALE_FACTOR = .0021;
|
||||
static const gint MIN_DISTANCE = -10.0;
|
||||
|
||||
static SkeltrackJoint *
|
||||
node_to_joint (Node *node, SkeltrackJointId id, gint dimension_reduction)
|
||||
{
|
||||
SkeltrackJoint *joint;
|
||||
|
||||
if (node == NULL)
|
||||
return NULL;
|
||||
|
||||
joint = g_slice_new0 (SkeltrackJoint);
|
||||
joint->id = id;
|
||||
joint->x = node->x;
|
||||
joint->y = node->y;
|
||||
joint->z = node->z;
|
||||
joint->screen_x = node->i * dimension_reduction;
|
||||
joint->screen_y = node->j * dimension_reduction;
|
||||
|
||||
return joint;
|
||||
}
|
||||
|
||||
static guint
|
||||
get_distance_from_joint (Node *node, SkeltrackJoint *joint)
|
||||
{
|
||||
guint dx, dy, dz;
|
||||
dx = ABS (node->x - joint->x);
|
||||
dy = ABS (node->y - joint->y);
|
||||
dz = ABS (node->z - joint->z);
|
||||
return sqrt (dx * dx + dy * dy + dz * dz);
|
||||
}
|
||||
|
||||
static void
|
||||
unlink_node (Node *node)
|
||||
{
|
||||
Node *neighbor;
|
||||
GList *current_neighbor;
|
||||
|
||||
for (current_neighbor = g_list_first (node->neighbors);
|
||||
current_neighbor != NULL;
|
||||
current_neighbor = g_list_next (current_neighbor))
|
||||
{
|
||||
neighbor = (Node *) current_neighbor->data;
|
||||
neighbor->neighbors = g_list_remove (neighbor->neighbors, node);
|
||||
}
|
||||
|
||||
for (current_neighbor = g_list_first (node->linked_nodes);
|
||||
current_neighbor != NULL;
|
||||
current_neighbor = g_list_next (current_neighbor))
|
||||
{
|
||||
neighbor = (Node *) current_neighbor->data;
|
||||
neighbor->linked_nodes = g_list_remove (neighbor->linked_nodes, node);
|
||||
}
|
||||
|
||||
g_list_free (node->neighbors);
|
||||
g_list_free (node->linked_nodes);
|
||||
node->neighbors = NULL;
|
||||
node->linked_nodes = NULL;
|
||||
}
|
||||
|
||||
static Node *
|
||||
get_closest_node_with_distances (GList *node_list,
|
||||
Node *from,
|
||||
guint x_dist,
|
||||
guint y_dist,
|
||||
guint z_dist,
|
||||
gint *closest_node_dist)
|
||||
{
|
||||
Node *closest = NULL;
|
||||
gint distance = -1;
|
||||
GList *current_node;
|
||||
|
||||
/* @TODO: Replace this and use closest pair of points
|
||||
algorithm and ensure O(n log n) instead of brute-force */
|
||||
|
||||
for (current_node = g_list_first (node_list);
|
||||
current_node != NULL;
|
||||
current_node = g_list_next (current_node))
|
||||
{
|
||||
guint dx, dy, dz;
|
||||
Node *node;
|
||||
gint current_distance;
|
||||
node = (Node *) current_node->data;
|
||||
|
||||
dx = ABS (from->x - node->x);
|
||||
dy = ABS (from->y - node->y);
|
||||
dz = ABS (from->z - node->z);
|
||||
|
||||
if (dx > x_dist || dy > y_dist || dz > z_dist)
|
||||
continue;
|
||||
|
||||
current_distance = sqrt (dx * dx + dy * dy + dz * dz);
|
||||
if (closest == NULL || distance > current_distance)
|
||||
{
|
||||
closest = node;
|
||||
distance = current_distance;
|
||||
}
|
||||
}
|
||||
|
||||
*closest_node_dist = distance;
|
||||
return closest;
|
||||
}
|
||||
|
||||
Node *
|
||||
get_closest_node_to_joint (GList *extremas,
|
||||
SkeltrackJoint *joint,
|
||||
gint *distance)
|
||||
{
|
||||
GList *current_node;
|
||||
gint dist = -1;
|
||||
Node *closest_node = NULL;
|
||||
|
||||
for (current_node = g_list_first (extremas);
|
||||
current_node != NULL;
|
||||
current_node = g_list_next (current_node))
|
||||
{
|
||||
guint current_dist;
|
||||
Node *node = (Node *) current_node->data;
|
||||
if (node == NULL)
|
||||
continue;
|
||||
|
||||
current_dist = get_distance_from_joint (node, joint);
|
||||
if (dist == -1 || current_dist < dist)
|
||||
{
|
||||
closest_node = node;
|
||||
dist = current_dist;
|
||||
}
|
||||
}
|
||||
*distance = dist;
|
||||
return closest_node;
|
||||
}
|
||||
|
||||
gint
|
||||
get_distance (Node *a, Node *b)
|
||||
{
|
||||
guint dx, dy, dz;
|
||||
dx = ABS (a->x - b->x);
|
||||
dy = ABS (a->y - b->y);
|
||||
dz = ABS (a->z - b->z);
|
||||
return sqrt (dx * dx + dy * dy + dz * dz);
|
||||
}
|
||||
|
||||
Node *
|
||||
get_closest_torso_node (GList *node_list, Node *from, Node *head)
|
||||
{
|
||||
Node *closest = NULL;
|
||||
gint distance = -1;
|
||||
GList *current_node;
|
||||
|
||||
/* @TODO: Replace this and use closest pair of points
|
||||
algorithm and ensure O(n log n) instead of brute-force */
|
||||
|
||||
for (current_node = g_list_first (node_list);
|
||||
current_node != NULL;
|
||||
current_node = g_list_next (current_node))
|
||||
{
|
||||
Node *node;
|
||||
gint current_distance;
|
||||
node = (Node *) current_node->data;
|
||||
if (node->z >= head->z &&
|
||||
node->y >= from->y)
|
||||
{
|
||||
current_distance = get_distance (node, from);
|
||||
if (closest == NULL || current_distance < distance)
|
||||
{
|
||||
closest = node;
|
||||
distance = current_distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
|
||||
Node *
|
||||
get_closest_node (GList *node_list, Node *from)
|
||||
{
|
||||
Node *closest = NULL;
|
||||
gint distance = -1;
|
||||
GList *current_node;
|
||||
|
||||
/* @TODO: Replace this and use closest pair of points
|
||||
algorithm and ensure O(n log n) instead of brute-force */
|
||||
|
||||
for (current_node = g_list_first (node_list);
|
||||
current_node != NULL;
|
||||
current_node = g_list_next (current_node))
|
||||
{
|
||||
Node *node;
|
||||
gint current_distance;
|
||||
node = (Node *) current_node->data;
|
||||
if (closest == NULL)
|
||||
{
|
||||
closest = node;
|
||||
distance = get_distance (node, from);
|
||||
continue;
|
||||
}
|
||||
current_distance = get_distance (node, from);
|
||||
if (current_distance < distance)
|
||||
{
|
||||
closest = node;
|
||||
distance = current_distance;
|
||||
}
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
|
||||
Label *
|
||||
get_main_component (GList *node_list, Node *from, gdouble min_normalized_nr_nodes)
|
||||
{
|
||||
Label *main_component = NULL;
|
||||
gint distance = -1;
|
||||
GList *current_node;
|
||||
|
||||
for (current_node = g_list_first (node_list);
|
||||
current_node != NULL;
|
||||
current_node = g_list_next (current_node))
|
||||
{
|
||||
Node *node;
|
||||
Label *label;
|
||||
gint current_distance;
|
||||
node = (Node *) current_node->data;
|
||||
label = node->label;
|
||||
|
||||
if (main_component == NULL &&
|
||||
label->normalized_num_nodes > min_normalized_nr_nodes)
|
||||
{
|
||||
main_component = label;
|
||||
distance = get_distance (node, from);
|
||||
continue;
|
||||
}
|
||||
|
||||
current_distance = get_distance (node, from);
|
||||
if (current_distance < distance &&
|
||||
label->normalized_num_nodes > min_normalized_nr_nodes)
|
||||
{
|
||||
main_component = label;
|
||||
distance = current_distance;
|
||||
}
|
||||
}
|
||||
|
||||
return main_component;
|
||||
}
|
||||
|
||||
Label *
|
||||
label_find (Label *label)
|
||||
{
|
||||
Label *parent;
|
||||
|
||||
g_return_val_if_fail (label != NULL, NULL);
|
||||
|
||||
parent = label->parent;
|
||||
if (parent == label)
|
||||
return parent;
|
||||
else
|
||||
return label_find (parent);
|
||||
}
|
||||
|
||||
void
|
||||
label_union (Label *a, Label *b)
|
||||
{
|
||||
Label *root_a, *root_b;
|
||||
root_a = label_find (a);
|
||||
root_b = label_find (b);
|
||||
if (root_a->index < root_b->index)
|
||||
{
|
||||
b->parent = root_a;
|
||||
}
|
||||
else
|
||||
{
|
||||
a->parent = root_b;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
free_label (Label *label)
|
||||
{
|
||||
g_list_free (label->nodes);
|
||||
label->nodes = NULL;
|
||||
g_slice_free (Label, label);
|
||||
}
|
||||
|
||||
void
|
||||
clean_labels (GList *labels)
|
||||
{
|
||||
GList *current = g_list_first (labels);
|
||||
while (current != NULL)
|
||||
{
|
||||
Label *label;
|
||||
label = (Label *) current->data;
|
||||
free_label (label);
|
||||
current = g_list_next (current);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
free_node (Node *node, gboolean unlink_node_first)
|
||||
{
|
||||
if (unlink_node_first)
|
||||
{
|
||||
unlink_node (node);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_list_free (node->neighbors);
|
||||
g_list_free (node->linked_nodes);
|
||||
node->neighbors = NULL;
|
||||
node->linked_nodes = NULL;
|
||||
}
|
||||
g_slice_free (Node, node);
|
||||
}
|
||||
|
||||
void
|
||||
clean_nodes (GList *nodes)
|
||||
{
|
||||
GList *current = g_list_first (nodes);
|
||||
while (current != NULL)
|
||||
{
|
||||
Node *node;
|
||||
node = (Node *) current->data;
|
||||
free_node (node, FALSE);
|
||||
current = g_list_next (current);
|
||||
}
|
||||
}
|
||||
|
||||
GList *
|
||||
remove_nodes_with_label (GList *nodes,
|
||||
Node **node_matrix,
|
||||
gint width,
|
||||
Label *label)
|
||||
{
|
||||
Node *node;
|
||||
GList *link_to_delete, *current_node;
|
||||
|
||||
current_node = g_list_first (nodes);
|
||||
while (current_node != NULL)
|
||||
{
|
||||
node = (Node *) current_node->data;
|
||||
if (node->label == label)
|
||||
{
|
||||
link_to_delete = current_node;
|
||||
current_node = g_list_next (current_node);
|
||||
nodes = g_list_delete_link (nodes, link_to_delete);
|
||||
node_matrix[width * node->j + node->i] = NULL;
|
||||
free_node (node, TRUE);
|
||||
continue;
|
||||
}
|
||||
current_node = g_list_next (current_node);
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
Label *
|
||||
get_lowest_index_label (Label **neighbor_labels)
|
||||
{
|
||||
guint index;
|
||||
Label *lowest_index_label = NULL;
|
||||
|
||||
lowest_index_label = neighbor_labels[0];
|
||||
for (index = 1; index < 4; index++)
|
||||
{
|
||||
if (neighbor_labels[index] == NULL)
|
||||
continue;
|
||||
|
||||
if (lowest_index_label == NULL ||
|
||||
lowest_index_label->index < neighbor_labels[index]->index)
|
||||
{
|
||||
lowest_index_label = neighbor_labels[index];
|
||||
}
|
||||
}
|
||||
|
||||
return lowest_index_label;
|
||||
}
|
||||
|
||||
Label *
|
||||
new_label (gint index)
|
||||
{
|
||||
Label *label = g_slice_new (Label);
|
||||
label->index = index;
|
||||
label->parent = label;
|
||||
label->nodes = NULL;
|
||||
label->bridge_node = NULL;
|
||||
label->to_node = NULL;
|
||||
label->lower_screen_y = -1;
|
||||
label->higher_z = -1;
|
||||
label->lower_z = -1;
|
||||
label->normalized_num_nodes = -1;
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
void
|
||||
join_components_to_main (GList *labels,
|
||||
Label *main_component_label,
|
||||
guint horizontal_max_distance,
|
||||
guint depth_max_distance,
|
||||
guint graph_distance_threshold)
|
||||
{
|
||||
GList *current_label;
|
||||
|
||||
for (current_label = g_list_first (labels);
|
||||
current_label != NULL;
|
||||
current_label = g_list_next (current_label))
|
||||
{
|
||||
gint closer_distance = -1;
|
||||
Label *label;
|
||||
GList *current_node, *nodes;
|
||||
|
||||
label = (Label *) current_label->data;
|
||||
if (label == main_component_label)
|
||||
continue;
|
||||
|
||||
/* Skip nodes behind main component */
|
||||
if (label->higher_z > main_component_label->higher_z +
|
||||
graph_distance_threshold)
|
||||
continue;
|
||||
|
||||
nodes = label->nodes;
|
||||
for (current_node = g_list_first (nodes);
|
||||
current_node != NULL;
|
||||
current_node = g_list_next (current_node))
|
||||
{
|
||||
Node *node;
|
||||
gint current_distance;
|
||||
node = (Node *) current_node->data;
|
||||
/* Skip nodes that belong to the same component or
|
||||
that a not in the edge of their component */
|
||||
if (g_list_length (node->neighbors) == 8)
|
||||
continue;
|
||||
|
||||
Node *closest_node =
|
||||
get_closest_node_with_distances (main_component_label->nodes,
|
||||
node,
|
||||
horizontal_max_distance,
|
||||
horizontal_max_distance,
|
||||
depth_max_distance,
|
||||
¤t_distance);
|
||||
if (closest_node &&
|
||||
(current_distance < closer_distance ||
|
||||
closer_distance == -1))
|
||||
{
|
||||
node->label->bridge_node = node;
|
||||
node->label->to_node = closest_node;
|
||||
closer_distance = current_distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
set_joint_from_node (SkeltrackJointList *joints,
|
||||
Node *node,
|
||||
SkeltrackJointId id,
|
||||
gint dimension_reduction)
|
||||
{
|
||||
(*joints)[id] = node_to_joint (node, id, dimension_reduction);
|
||||
}
|
||||
|
||||
gint *
|
||||
create_new_dist_matrix (gint matrix_size)
|
||||
{
|
||||
guint i;
|
||||
gint *distances;
|
||||
|
||||
distances = g_slice_alloc0 (matrix_size * sizeof (gint));
|
||||
for (i = 0; i < matrix_size; i++)
|
||||
{
|
||||
distances[i] = -1;
|
||||
}
|
||||
|
||||
return distances;
|
||||
}
|
||||
|
||||
gboolean
|
||||
dijkstra_to (GList *nodes, Node *source, Node *target,
|
||||
gint width, gint height,
|
||||
gint *distances, Node **previous)
|
||||
{
|
||||
gint nr;
|
||||
GList *unvisited_nodes, *current;
|
||||
|
||||
for (current = g_list_first (nodes);
|
||||
previous != NULL && current != NULL;
|
||||
current = g_list_next (current))
|
||||
{
|
||||
Node *node;
|
||||
node = (Node *) current->data;
|
||||
previous[node->j * width + node->i] = NULL;
|
||||
}
|
||||
distances[source->j * width + source->i] = 0;
|
||||
|
||||
unvisited_nodes = g_list_copy (nodes);
|
||||
nr = 0;
|
||||
while (unvisited_nodes != NULL)
|
||||
{
|
||||
Node *node;
|
||||
GList *current_neighbor, *shorter_dist_node, *cur_node;
|
||||
|
||||
shorter_dist_node = g_list_first (unvisited_nodes);
|
||||
cur_node = g_list_next (shorter_dist_node);
|
||||
while (cur_node != NULL)
|
||||
{
|
||||
Node *value, *shorter_dist;
|
||||
value = (Node *) cur_node->data;
|
||||
shorter_dist = (Node *) shorter_dist_node->data;
|
||||
if (distances[shorter_dist->j * width + shorter_dist->i] == -1 ||
|
||||
(distances[value->j * width + value->i] != -1 &&
|
||||
distances[value->j * width +
|
||||
value->i] < distances[shorter_dist->j * width +
|
||||
shorter_dist->i]))
|
||||
{
|
||||
shorter_dist_node = cur_node;
|
||||
}
|
||||
cur_node = g_list_next (cur_node);
|
||||
}
|
||||
|
||||
node = (Node *) shorter_dist_node->data;
|
||||
if (distances[node->j * width + node->i] == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
current_neighbor = g_list_first (node->neighbors);
|
||||
while (current_neighbor)
|
||||
{
|
||||
gint dist;
|
||||
Node *neighbor;
|
||||
|
||||
neighbor = (Node *) current_neighbor->data;
|
||||
dist = get_distance (node, neighbor) +
|
||||
distances[node->j * width + node->i];
|
||||
|
||||
if (distances[neighbor->j * width + neighbor->i] == -1 ||
|
||||
dist < distances[neighbor->j * width + neighbor->i])
|
||||
{
|
||||
distances[neighbor->j * width + neighbor->i] = dist;
|
||||
if (previous != NULL)
|
||||
{
|
||||
previous[neighbor->j * width + neighbor->i] = node;
|
||||
}
|
||||
nr++;
|
||||
}
|
||||
if (target != NULL && neighbor == target)
|
||||
{
|
||||
g_list_free (unvisited_nodes);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
current_neighbor = g_list_next (current_neighbor);
|
||||
}
|
||||
unvisited_nodes = g_list_delete_link (unvisited_nodes, shorter_dist_node);
|
||||
}
|
||||
g_list_free (unvisited_nodes);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
convert_screen_coords_to_mm (guint width,
|
||||
guint height,
|
||||
guint dimension_reduction,
|
||||
guint i,
|
||||
guint j,
|
||||
gint z,
|
||||
gint *x,
|
||||
gint *y)
|
||||
{
|
||||
gfloat width_height_relation =
|
||||
width > height ? (gfloat) width / height : (gfloat) height / width;
|
||||
/* Formula from http://openkinect.org/wiki/Imaging_Information */
|
||||
*x = round((i * dimension_reduction - width * dimension_reduction / 2.0) *
|
||||
(z + MIN_DISTANCE) * SCALE_FACTOR * width_height_relation);
|
||||
*y = round((j * dimension_reduction - height * dimension_reduction / 2.0) *
|
||||
(z + MIN_DISTANCE) * SCALE_FACTOR);
|
||||
}
|
||||
|
||||
void
|
||||
convert_mm_to_screen_coords (guint width,
|
||||
guint height,
|
||||
guint dimension_reduction,
|
||||
gint x,
|
||||
gint y,
|
||||
gint z,
|
||||
guint *i,
|
||||
guint *j)
|
||||
{
|
||||
gfloat width_height_relation =
|
||||
width > height ? (gfloat) width / height : (gfloat) height / width;
|
||||
|
||||
if (z + MIN_DISTANCE == 0)
|
||||
{
|
||||
*i = 0;
|
||||
*j = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
*i = round (width / 2.0 + x / ((gfloat) (z + MIN_DISTANCE) * SCALE_FACTOR *
|
||||
dimension_reduction * width_height_relation));
|
||||
*j = round (height / 2.0 + y / ((gfloat) (z + MIN_DISTANCE) * SCALE_FACTOR *
|
||||
dimension_reduction));
|
||||
}
|
Loading…
Reference in a new issue