Merge branch 'master' of github.com:worklist/hifi
10
.gitignore
vendored
|
@ -1,3 +1,13 @@
|
||||||
|
# CMake
|
||||||
|
CMakeCache.txt
|
||||||
|
CMakeFiles/
|
||||||
|
CMakeScripts/
|
||||||
|
cmake_install.cmake
|
||||||
|
build/
|
||||||
|
|
||||||
|
# Xcode
|
||||||
|
*.xcodeproj
|
||||||
|
*.xcworkspace
|
||||||
.DS_Store
|
.DS_Store
|
||||||
xcuserdata
|
xcuserdata
|
||||||
*.pbxuser
|
*.pbxuser
|
||||||
|
|
11
CMakeLists.txt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
|
||||||
|
|
||||||
|
project(hifi)
|
||||||
|
|
||||||
|
set(GLM_ROOT_DIR ${CMAKE_SOURCE_DIR}/thirdparty)
|
||||||
|
set(PORTAUDIO_ROOT_DIR ${CMAKE_SOURCE_DIR}/thirdparty/Portaudio)
|
||||||
|
set(LODEPNG_ROOT_DIR ${CMAKE_SOURCE_DIR}/thirdparty/LodePNG)
|
||||||
|
|
||||||
|
add_subdirectory(interface)
|
||||||
|
add_subdirectory(mixer)
|
|
@ -1 +0,0 @@
|
||||||
Versions/A/CVBlob
|
|
|
@ -1 +0,0 @@
|
||||||
Versions/A/Headers/
|
|
|
@ -1,99 +0,0 @@
|
||||||
#ifndef BLOBCONTOUR_H_INCLUDED
|
|
||||||
#define BLOBCONTOUR_H_INCLUDED
|
|
||||||
|
|
||||||
|
|
||||||
#include "list"
|
|
||||||
#include <opencv/cv.h>
|
|
||||||
//#include "cxtypes.h" //AO
|
|
||||||
#include <opencv/cxcore.h> //
|
|
||||||
|
|
||||||
//! Type of chain codes
|
|
||||||
typedef unsigned char t_chainCode;
|
|
||||||
//! Type of list of chain codes
|
|
||||||
typedef CvSeq* t_chainCodeList;
|
|
||||||
//! Type of list of points
|
|
||||||
typedef CvSeq* t_PointList;
|
|
||||||
|
|
||||||
|
|
||||||
//! Max order of calculated moments
|
|
||||||
#define MAX_MOMENTS_ORDER 3
|
|
||||||
|
|
||||||
|
|
||||||
//! Blob contour class (in crack code)
|
|
||||||
class CBlobContour
|
|
||||||
{
|
|
||||||
friend class CBlob;
|
|
||||||
friend class CBlobProperties; //AO
|
|
||||||
|
|
||||||
public:
|
|
||||||
//! Constructors
|
|
||||||
CBlobContour();
|
|
||||||
CBlobContour(CvPoint startPoint, CvMemStorage *storage );
|
|
||||||
//! Copy constructor
|
|
||||||
CBlobContour( CBlobContour *source );
|
|
||||||
|
|
||||||
~CBlobContour();
|
|
||||||
//! Assigment operator
|
|
||||||
CBlobContour& operator=( const CBlobContour &source );
|
|
||||||
|
|
||||||
//! Add chain code to contour
|
|
||||||
void AddChainCode(t_chainCode code);
|
|
||||||
|
|
||||||
//! Return freeman chain coded contour
|
|
||||||
t_chainCodeList GetChainCode()
|
|
||||||
{
|
|
||||||
return m_contour;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsEmpty()
|
|
||||||
{
|
|
||||||
return m_contour == NULL || m_contour->total == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Return all contour points
|
|
||||||
t_chainCodeList GetContourPoints();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
CvPoint GetStartPoint() const
|
|
||||||
{
|
|
||||||
return m_startPoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Clears chain code contour
|
|
||||||
void ResetChainCode();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! Computes area from contour
|
|
||||||
double GetArea();
|
|
||||||
//! Computes perimeter from contour
|
|
||||||
double GetPerimeter();
|
|
||||||
//! Get contour moment (p,q up to MAX_CALCULATED_MOMENTS)
|
|
||||||
double GetMoment(int p, int q);
|
|
||||||
|
|
||||||
//! Crack code list
|
|
||||||
t_chainCodeList m_contour;
|
|
||||||
|
|
||||||
private:
|
|
||||||
//! Starting point of the contour
|
|
||||||
CvPoint m_startPoint;
|
|
||||||
//! All points from the contour
|
|
||||||
t_PointList m_contourPoints;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! Computed area from contour
|
|
||||||
double m_area;
|
|
||||||
//! Computed perimeter from contour
|
|
||||||
double m_perimeter;
|
|
||||||
//! Computed moments from contour
|
|
||||||
CvMoments m_moments;
|
|
||||||
|
|
||||||
//! Pointer to storage
|
|
||||||
CvMemStorage *m_parentStorage;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //!BLOBCONTOUR_H_INCLUDED
|
|
||||||
|
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
/************************************************************************
|
|
||||||
BlobLibraryConfiguration.h
|
|
||||||
|
|
||||||
FUNCIONALITAT: Configuració del comportament global de la llibreria
|
|
||||||
AUTOR: Inspecta S.L.
|
|
||||||
MODIFICACIONS (Modificació, Autor, Data):
|
|
||||||
|
|
||||||
FUNCTIONALITY: Global configuration of the library
|
|
||||||
AUTHOR: Inspecta S.L.
|
|
||||||
MODIFICATIONS (Modification, Author, Date):
|
|
||||||
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
//! Indica si es volen fer servir les MatrixCV o no
|
|
||||||
//! Use/Not use the MatrixCV class
|
|
||||||
//#define MATRIXCV_ACTIU
|
|
||||||
|
|
||||||
//! Uses/not use the blob object factory
|
|
||||||
//#define BLOB_OBJECT_FACTORY
|
|
||||||
|
|
||||||
//! Show/not show blob access errors
|
|
||||||
//#define _SHOW_ERRORS //AO: Only works for WIN.
|
|
|
@ -1,754 +0,0 @@
|
||||||
#ifndef BLOB_OPERATORS_H_INCLUDED
|
|
||||||
#define BLOB_OPERATORS_H_INCLUDED
|
|
||||||
|
|
||||||
#include "blob.h"
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
Definició de les classes per a fer operacions sobre els blobs
|
|
||||||
|
|
||||||
Helper classes to perform operations on blobs
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
//! Factor de conversió de graus a radians
|
|
||||||
#define DEGREE2RAD (CV_PI / 180.0)
|
|
||||||
|
|
||||||
|
|
||||||
//! Classe d'on derivarem totes les operacions sobre els blobs
|
|
||||||
//! Interface to derive all blob operations
|
|
||||||
class COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~COperadorBlob(){};
|
|
||||||
|
|
||||||
//! Aply operator to blob
|
|
||||||
virtual double operator()(CBlob &blob) = 0;
|
|
||||||
//! Get operator name
|
|
||||||
virtual const char *GetNom() = 0;
|
|
||||||
|
|
||||||
operator COperadorBlob*()
|
|
||||||
{
|
|
||||||
return (COperadorBlob*)this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef COperadorBlob funcio_calculBlob;
|
|
||||||
|
|
||||||
#ifdef BLOB_OBJECT_FACTORY
|
|
||||||
/**
|
|
||||||
Funció per comparar dos identificadors dins de la fàbrica de COperadorBlobs
|
|
||||||
*/
|
|
||||||
struct functorComparacioIdOperador
|
|
||||||
{
|
|
||||||
bool operator()(const char* s1, const char* s2) const
|
|
||||||
{
|
|
||||||
return strcmp(s1, s2) < 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Definition of Object factory type for COperadorBlob objects
|
|
||||||
typedef ObjectFactory<COperadorBlob, const char *, functorComparacioIdOperador > t_OperadorBlobFactory;
|
|
||||||
|
|
||||||
//! Funció global per a registrar tots els operadors definits a blob.h
|
|
||||||
void RegistraTotsOperadors( t_OperadorBlobFactory &fabricaOperadorsBlob );
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//! Classe per calcular l'etiqueta d'un blob
|
|
||||||
//! Class to get ID of a blob
|
|
||||||
class CBlobGetID : public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
return blob.GetID();
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetID";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//! Classe per calcular l'àrea d'un blob
|
|
||||||
//! Class to get the area of a blob
|
|
||||||
class CBlobGetArea : public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
return blob.Area();
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetArea";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular el perimetre d'un blob
|
|
||||||
//! Class to get the perimeter of a blob
|
|
||||||
class CBlobGetPerimeter: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
return blob.Perimeter();
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetPerimeter";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe que diu si un blob és extern o no
|
|
||||||
//! Class to get the extern flag of a blob
|
|
||||||
class CBlobGetExterior: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CBlobGetExterior()
|
|
||||||
{
|
|
||||||
m_mask = NULL;
|
|
||||||
m_xBorder = false;
|
|
||||||
m_yBorder = false;
|
|
||||||
}
|
|
||||||
CBlobGetExterior(IplImage *mask, bool xBorder = true, bool yBorder = true)
|
|
||||||
{
|
|
||||||
m_mask = mask;
|
|
||||||
m_xBorder = xBorder;
|
|
||||||
m_yBorder = yBorder;
|
|
||||||
}
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
return blob.Exterior(m_mask, m_xBorder, m_yBorder);
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetExterior";
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
IplImage *m_mask;
|
|
||||||
bool m_xBorder, m_yBorder;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular la mitjana de nivells de gris d'un blob
|
|
||||||
//! Class to get the mean grey level of a blob
|
|
||||||
class CBlobGetMean: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CBlobGetMean()
|
|
||||||
{
|
|
||||||
m_image = NULL;
|
|
||||||
}
|
|
||||||
CBlobGetMean( IplImage *image )
|
|
||||||
{
|
|
||||||
m_image = image;
|
|
||||||
};
|
|
||||||
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
return blob.Mean(m_image);
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetMean";
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
|
|
||||||
IplImage *m_image;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular la desviació estàndard dels nivells de gris d'un blob
|
|
||||||
//! Class to get the standard deviation of the grey level values of a blob
|
|
||||||
class CBlobGetStdDev: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CBlobGetStdDev()
|
|
||||||
{
|
|
||||||
m_image = NULL;
|
|
||||||
}
|
|
||||||
CBlobGetStdDev( IplImage *image )
|
|
||||||
{
|
|
||||||
m_image = image;
|
|
||||||
};
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
return blob.StdDev(m_image);
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetStdDev";
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
|
|
||||||
IplImage *m_image;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular la compacitat d'un blob
|
|
||||||
//! Class to calculate the compactness of a blob
|
|
||||||
class CBlobGetCompactness: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob);
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetCompactness";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular la longitud d'un blob
|
|
||||||
//! Class to calculate the length of a blob
|
|
||||||
class CBlobGetLength: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob);
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetLength";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular l'amplada d'un blob
|
|
||||||
//! Class to calculate the breadth of a blob
|
|
||||||
class CBlobGetBreadth: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob);
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetBreadth";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular la diferència en X del blob
|
|
||||||
class CBlobGetDiffX: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
return blob.GetBoundingBox().width;
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetDiffX";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular la diferència en X del blob
|
|
||||||
class CBlobGetDiffY: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
return blob.GetBoundingBox().height;
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetDiffY";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular el moment PQ del blob
|
|
||||||
//! Class to calculate the P,Q moment of a blob
|
|
||||||
class CBlobGetMoment: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//! Constructor estàndard
|
|
||||||
//! Standard constructor (gets the 00 moment)
|
|
||||||
CBlobGetMoment()
|
|
||||||
{
|
|
||||||
m_p = m_q = 0;
|
|
||||||
}
|
|
||||||
//! Constructor: indiquem el moment p,q a calcular
|
|
||||||
//! Constructor: gets the PQ moment
|
|
||||||
CBlobGetMoment( int p, int q )
|
|
||||||
{
|
|
||||||
m_p = p;
|
|
||||||
m_q = q;
|
|
||||||
};
|
|
||||||
double operator()(CBlob &blob);
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetMoment";
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
//! moment que volem calcular
|
|
||||||
int m_p, m_q;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular el perimetre del poligon convex d'un blob
|
|
||||||
//! Class to calculate the convex hull perimeter of a blob
|
|
||||||
class CBlobGetHullPerimeter: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob);
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetHullPerimeter";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular l'àrea del poligon convex d'un blob
|
|
||||||
//! Class to calculate the convex hull area of a blob
|
|
||||||
class CBlobGetHullArea: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob);
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetHullArea";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular la x minima en la y minima
|
|
||||||
//! Class to calculate the minimum x on the minimum y
|
|
||||||
class CBlobGetMinXatMinY: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob);
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetMinXatMinY";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular la y minima en la x maxima
|
|
||||||
//! Class to calculate the minimum y on the maximum x
|
|
||||||
class CBlobGetMinYatMaxX: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob);
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetMinYatMaxX";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular la x maxima en la y maxima
|
|
||||||
//! Class to calculate the maximum x on the maximum y
|
|
||||||
class CBlobGetMaxXatMaxY: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob);
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetMaxXatMaxY";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular la y maxima en la x minima
|
|
||||||
//! Class to calculate the maximum y on the minimum y
|
|
||||||
class CBlobGetMaxYatMinX: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob);
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetMaxYatMinX";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per a calcular la x mínima
|
|
||||||
//! Class to get the minimum x
|
|
||||||
class CBlobGetMinX: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
return blob.MinX();
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetMinX";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per a calcular la x màxima
|
|
||||||
//! Class to get the maximum x
|
|
||||||
class CBlobGetMaxX: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
return blob.MaxX();
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetMaxX";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per a calcular la y mínima
|
|
||||||
//! Class to get the minimum y
|
|
||||||
class CBlobGetMinY: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
return blob.MinY();
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetMinY";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per a calcular la y màxima
|
|
||||||
//! Class to get the maximum y
|
|
||||||
class CBlobGetMaxY: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
return blob.MaxY();
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetMaxY";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//! Classe per calcular l'elongacio d'un blob
|
|
||||||
//! Class to calculate the elongation of the blob
|
|
||||||
class CBlobGetElongation: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob);
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetElongation";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular la rugositat d'un blob
|
|
||||||
//! Class to calculate the roughness of the blob
|
|
||||||
class CBlobGetRoughness: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob);
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetRoughness";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular la distància entre el centre del blob i un punt donat
|
|
||||||
//! Class to calculate the euclidean distance between the center of a blob and a given point
|
|
||||||
class CBlobGetDistanceFromPoint: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//! Standard constructor (distance to point 0,0)
|
|
||||||
CBlobGetDistanceFromPoint()
|
|
||||||
{
|
|
||||||
m_x = m_y = 0.0;
|
|
||||||
}
|
|
||||||
//! Constructor (distance to point x,y)
|
|
||||||
CBlobGetDistanceFromPoint( const double x, const double y )
|
|
||||||
{
|
|
||||||
m_x = x;
|
|
||||||
m_y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
double operator()(CBlob &blob);
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetDistanceFromPoint";
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
// coordenades del punt on volem calcular la distància
|
|
||||||
double m_x, m_y;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular el nombre de pixels externs d'un blob
|
|
||||||
//! Class to get the number of extern pixels of a blob
|
|
||||||
class CBlobGetExternPerimeter: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CBlobGetExternPerimeter()
|
|
||||||
{
|
|
||||||
m_mask = NULL;
|
|
||||||
m_xBorder = false;
|
|
||||||
m_yBorder = false;
|
|
||||||
}
|
|
||||||
CBlobGetExternPerimeter( IplImage *mask, bool xBorder = true, bool yBorder = true )
|
|
||||||
{
|
|
||||||
m_mask = mask;
|
|
||||||
m_xBorder = xBorder;
|
|
||||||
m_yBorder = yBorder;
|
|
||||||
}
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
return blob.ExternPerimeter(m_mask, m_xBorder, m_yBorder);
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetExternPerimeter";
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
IplImage *m_mask;
|
|
||||||
bool m_xBorder, m_yBorder;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular el ratio entre el perimetre i nombre pixels externs
|
|
||||||
//! valors propers a 0 indiquen que la majoria del blob és intern
|
|
||||||
//! valors propers a 1 indiquen que la majoria del blob és extern
|
|
||||||
//! Class to calculate the ratio between the perimeter and the number of extern pixels
|
|
||||||
class CBlobGetExternPerimeterRatio: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CBlobGetExternPerimeterRatio()
|
|
||||||
{
|
|
||||||
m_mask = NULL;
|
|
||||||
m_xBorder = false;
|
|
||||||
m_yBorder = false;
|
|
||||||
}
|
|
||||||
CBlobGetExternPerimeterRatio( IplImage *mask, bool xBorder = true, bool yBorder = true )
|
|
||||||
{
|
|
||||||
m_mask = mask;
|
|
||||||
m_xBorder = xBorder;
|
|
||||||
m_yBorder = yBorder;
|
|
||||||
}
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
if( blob.Perimeter() != 0 )
|
|
||||||
return blob.ExternPerimeter(m_mask, m_xBorder, m_yBorder) / blob.Perimeter();
|
|
||||||
else
|
|
||||||
return blob.ExternPerimeter(m_mask, m_xBorder, m_yBorder);
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetExternPerimeterRatio";
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
IplImage *m_mask;
|
|
||||||
bool m_xBorder, m_yBorder;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular el ratio entre el perimetre convex i nombre pixels externs
|
|
||||||
//! valors propers a 0 indiquen que la majoria del blob és intern
|
|
||||||
//! valors propers a 1 indiquen que la majoria del blob és extern
|
|
||||||
//! Class to calculate the ratio between the perimeter and the number of extern pixels
|
|
||||||
class CBlobGetExternHullPerimeterRatio: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CBlobGetExternHullPerimeterRatio()
|
|
||||||
{
|
|
||||||
m_mask = NULL;
|
|
||||||
m_xBorder = false;
|
|
||||||
m_yBorder = false;
|
|
||||||
}
|
|
||||||
CBlobGetExternHullPerimeterRatio( IplImage *mask, bool xBorder = true, bool yBorder = true )
|
|
||||||
{
|
|
||||||
m_mask = mask;
|
|
||||||
m_xBorder = xBorder;
|
|
||||||
m_yBorder = yBorder;
|
|
||||||
}
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
CBlobGetHullPerimeter getHullPerimeter;
|
|
||||||
double hullPerimeter;
|
|
||||||
|
|
||||||
if( (hullPerimeter = getHullPerimeter( blob ) ) != 0 )
|
|
||||||
return blob.ExternPerimeter(m_mask, m_xBorder, m_yBorder) / hullPerimeter;
|
|
||||||
else
|
|
||||||
return blob.ExternPerimeter(m_mask, m_xBorder, m_yBorder);
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetExternHullPerimeterRatio";
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
IplImage *m_mask;
|
|
||||||
bool m_xBorder, m_yBorder;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular el centre en el eix X d'un blob
|
|
||||||
//! Class to calculate the center in the X direction
|
|
||||||
class CBlobGetXCenter: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
return blob.MinX() + (( blob.MaxX() - blob.MinX() ) / 2.0);
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetXCenter";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular el centre en el eix Y d'un blob
|
|
||||||
//! Class to calculate the center in the Y direction
|
|
||||||
class CBlobGetYCenter: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
return blob.MinY() + (( blob.MaxY() - blob.MinY() ) / 2.0);
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetYCenter";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular la longitud de l'eix major d'un blob
|
|
||||||
//! Class to calculate the length of the major axis of the ellipse that fits the blob edges
|
|
||||||
class CBlobGetMajorAxisLength: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
CvBox2D elipse = blob.GetEllipse();
|
|
||||||
|
|
||||||
return elipse.size.width;
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetMajorAxisLength";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular el ratio entre l'area de la elipse i la de la taca
|
|
||||||
//! Class
|
|
||||||
class CBlobGetAreaElipseRatio: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
if( blob.Area()==0.0 ) return 0.0;
|
|
||||||
|
|
||||||
CvBox2D elipse = blob.GetEllipse();
|
|
||||||
double ratioAreaElipseAreaTaca = ( (elipse.size.width/2.0)
|
|
||||||
*
|
|
||||||
(elipse.size.height/2.0)
|
|
||||||
*CV_PI
|
|
||||||
)
|
|
||||||
/
|
|
||||||
blob.Area();
|
|
||||||
|
|
||||||
return ratioAreaElipseAreaTaca;
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetAreaElipseRatio";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular la longitud de l'eix menor d'un blob
|
|
||||||
//! Class to calculate the length of the minor axis of the ellipse that fits the blob edges
|
|
||||||
class CBlobGetMinorAxisLength: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
CvBox2D elipse = blob.GetEllipse();
|
|
||||||
|
|
||||||
return elipse.size.height;
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetMinorAxisLength";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular l'orientació de l'ellipse del blob en radians
|
|
||||||
//! Class to calculate the orientation of the ellipse that fits the blob edges in radians
|
|
||||||
class CBlobGetOrientation: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
CvBox2D elipse = blob.GetEllipse();
|
|
||||||
/*
|
|
||||||
if( elipse.angle > 180.0 )
|
|
||||||
return (( elipse.angle - 180.0 )* DEGREE2RAD);
|
|
||||||
else
|
|
||||||
return ( elipse.angle * DEGREE2RAD);
|
|
||||||
*/
|
|
||||||
return elipse.angle;
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetOrientation";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Classe per calcular el cosinus de l'orientació de l'ellipse del blob
|
|
||||||
//! Class to calculate the cosinus of the orientation of the ellipse that fits the blob edges
|
|
||||||
class CBlobGetOrientationCos: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
CBlobGetOrientation getOrientation;
|
|
||||||
return fabs( cos( getOrientation(blob)*DEGREE2RAD ));
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetOrientationCos";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//! Classe per calcular el ratio entre l'eix major i menor de la el·lipse
|
|
||||||
//! Class to calculate the ratio between both axes of the ellipse
|
|
||||||
class CBlobGetAxisRatio: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
double operator()(CBlob &blob)
|
|
||||||
{
|
|
||||||
double major,minor;
|
|
||||||
CBlobGetMajorAxisLength getMajor;
|
|
||||||
CBlobGetMinorAxisLength getMinor;
|
|
||||||
|
|
||||||
major = getMajor(blob);
|
|
||||||
minor = getMinor(blob);
|
|
||||||
|
|
||||||
if( major != 0 )
|
|
||||||
return minor / major;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetAxisRatio";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//! Classe per calcular si un punt cau dins del blob
|
|
||||||
//! Class to calculate whether a point is inside a blob
|
|
||||||
class CBlobGetXYInside: public COperadorBlob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//! Constructor estàndard
|
|
||||||
//! Standard constructor
|
|
||||||
CBlobGetXYInside()
|
|
||||||
{
|
|
||||||
m_p.x = 0;
|
|
||||||
m_p.y = 0;
|
|
||||||
}
|
|
||||||
//! Constructor: indiquem el punt
|
|
||||||
//! Constructor: sets the point
|
|
||||||
CBlobGetXYInside( CvPoint2D32f p )
|
|
||||||
{
|
|
||||||
m_p = p;
|
|
||||||
};
|
|
||||||
double operator()(CBlob &blob);
|
|
||||||
const char *GetNom()
|
|
||||||
{
|
|
||||||
return "CBlobGetXYInside";
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
//! punt que considerem
|
|
||||||
//! point to be considered
|
|
||||||
CvPoint2D32f m_p;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //!BLOB_OPERATORS_H_INCLUDED
|
|
|
@ -1,70 +0,0 @@
|
||||||
|
|
||||||
//! Disable warnings referred to 255 character truncation for the std:map
|
|
||||||
#pragma warning( disable : 4786 )
|
|
||||||
|
|
||||||
#ifndef BLOB_PROPERTIES_H_INCLUDED
|
|
||||||
#define BLOB_PROPERTIES_H_INCLUDED
|
|
||||||
|
|
||||||
#include <opencv/cxcore.h>
|
|
||||||
#include "BlobLibraryConfiguration.h"
|
|
||||||
#include "BlobContour.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef BLOB_OBJECT_FACTORY
|
|
||||||
//! Object factory pattern implementation
|
|
||||||
#include "..\inspecta\DesignPatterns\ObjectFactory.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//! Type of labelled images
|
|
||||||
typedef unsigned int t_labelType;
|
|
||||||
|
|
||||||
//! Max order of calculated moments
|
|
||||||
#define MAX_MOMENTS_ORDER 3
|
|
||||||
|
|
||||||
|
|
||||||
//! Blob class
|
|
||||||
class CBlobProperties
|
|
||||||
{
|
|
||||||
typedef std::list<CBlobContour> t_contourList;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
CBlobProperties();
|
|
||||||
virtual ~CBlobProperties();
|
|
||||||
|
|
||||||
//! Get blob area
|
|
||||||
double GetArea();
|
|
||||||
|
|
||||||
//! Get blob perimeter
|
|
||||||
double GetPerimeter();
|
|
||||||
|
|
||||||
//! Get contour moment (p,q up to MAX_CALCULATED_MOMENTS)
|
|
||||||
double GetMoment(int p, int q);
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// Blob contours
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//! Contour storage memory
|
|
||||||
CvMemStorage *m_storage;
|
|
||||||
//! External contour of the blob (crack codes)
|
|
||||||
CBlobContour m_externalContour;
|
|
||||||
//! Internal contours (crack codes)
|
|
||||||
t_contourList m_internalContours;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//! Computed area from blob
|
|
||||||
double m_area;
|
|
||||||
//! Computed perimeter from blob
|
|
||||||
double m_perimeter;
|
|
||||||
// Computed moment from the blob
|
|
||||||
double m_moment[MAX_MOMENTS_ORDER*MAX_MOMENTS_ORDER];
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //!BLOB_PROPERTIES_H_INCLUDED
|
|
||||||
|
|
|
@ -1,171 +0,0 @@
|
||||||
/************************************************************************
|
|
||||||
BlobResult.h
|
|
||||||
|
|
||||||
FUNCIONALITAT: Definició de la classe CBlobResult
|
|
||||||
AUTOR: Inspecta S.L.
|
|
||||||
MODIFICACIONS (Modificació, Autor, Data):
|
|
||||||
|
|
||||||
FUNCTIONALITY: Definition of the CBlobResult class
|
|
||||||
AUTHOR: Inspecta S.L.
|
|
||||||
MODIFICATIONS (Modification, Author, Date):
|
|
||||||
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
#if !defined(_CLASSE_BLOBRESULT_INCLUDED)
|
|
||||||
#define _CLASSE_BLOBRESULT_INCLUDED
|
|
||||||
|
|
||||||
#if _MSC_VER > 1000
|
|
||||||
#pragma once
|
|
||||||
#endif // _MSC_VER > 1000
|
|
||||||
|
|
||||||
#include "BlobLibraryConfiguration.h"
|
|
||||||
#include <math.h>
|
|
||||||
#include <opencv/cxcore.h>
|
|
||||||
|
|
||||||
#ifdef MATRIXCV_ACTIU
|
|
||||||
#include "matrixCV.h"
|
|
||||||
#else
|
|
||||||
// llibreria STL
|
|
||||||
#include "vector"
|
|
||||||
//! Vector de doubles
|
|
||||||
typedef std::vector<double> double_stl_vector;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <vector> // vectors de la STL
|
|
||||||
#include <functional>
|
|
||||||
#include "blob.h"
|
|
||||||
#include "BlobOperators.h"
|
|
||||||
#include "ComponentLabeling.h"
|
|
||||||
/**************************************************************************
|
|
||||||
Filtres / Filters
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
//! accions que es poden fer amb els filtres
|
|
||||||
//! Actions performed by a filter (include or exclude blobs)
|
|
||||||
#define B_INCLUDE 1L
|
|
||||||
#define B_EXCLUDE 2L
|
|
||||||
|
|
||||||
//! condicions sobre els filtres
|
|
||||||
//! Conditions to apply the filters
|
|
||||||
#define B_EQUAL 3L
|
|
||||||
#define B_NOT_EQUAL 4L
|
|
||||||
#define B_GREATER 5L
|
|
||||||
#define B_LESS 6L
|
|
||||||
#define B_GREATER_OR_EQUAL 7L
|
|
||||||
#define B_LESS_OR_EQUAL 8L
|
|
||||||
#define B_INSIDE 9L
|
|
||||||
#define B_OUTSIDE 10L
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
Excepcions / Exceptions
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
//! Excepcions llençades per les funcions:
|
|
||||||
#define EXCEPTION_BLOB_OUT_OF_BOUNDS 1000
|
|
||||||
#define EXCEPCIO_CALCUL_BLOBS 1001
|
|
||||||
|
|
||||||
/**
|
|
||||||
Classe que conté un conjunt de blobs i permet extreure'n propietats
|
|
||||||
o filtrar-los segons determinats criteris.
|
|
||||||
Class to calculate the blobs of an image and calculate some properties
|
|
||||||
on them. Also, the class provides functions to filter the blobs using
|
|
||||||
some criteria.
|
|
||||||
*/
|
|
||||||
class CBlobResult
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
//! constructor estandard, crea un conjunt buit de blobs
|
|
||||||
//! Standard constructor, it creates an empty set of blobs
|
|
||||||
CBlobResult();
|
|
||||||
//! constructor a partir d'una imatge
|
|
||||||
//! Image constructor, it creates an object with the blobs of the image
|
|
||||||
CBlobResult(IplImage *source, IplImage *mask, uchar backgroundColor);
|
|
||||||
//! constructor de còpia
|
|
||||||
//! Copy constructor
|
|
||||||
CBlobResult( const CBlobResult &source );
|
|
||||||
//! Destructor
|
|
||||||
virtual ~CBlobResult();
|
|
||||||
|
|
||||||
//! operador = per a fer assignacions entre CBlobResult
|
|
||||||
//! Assigment operator
|
|
||||||
CBlobResult& operator=(const CBlobResult& source);
|
|
||||||
//! operador + per concatenar dos CBlobResult
|
|
||||||
//! Addition operator to concatenate two sets of blobs
|
|
||||||
CBlobResult operator+( const CBlobResult& source ) const;
|
|
||||||
|
|
||||||
//! Afegeix un blob al conjunt
|
|
||||||
//! Adds a blob to the set of blobs
|
|
||||||
void AddBlob( CBlob *blob );
|
|
||||||
|
|
||||||
#ifdef MATRIXCV_ACTIU
|
|
||||||
//! Calcula un valor sobre tots els blobs de la classe retornant una MatrixCV
|
|
||||||
//! Computes some property on all the blobs of the class
|
|
||||||
double_vector GetResult( funcio_calculBlob *evaluador ) const;
|
|
||||||
#endif
|
|
||||||
//! Calcula un valor sobre tots els blobs de la classe retornant un std::vector<double>
|
|
||||||
//! Computes some property on all the blobs of the class
|
|
||||||
double_stl_vector GetSTLResult( funcio_calculBlob *evaluador ) const;
|
|
||||||
|
|
||||||
//! Calcula un valor sobre un blob de la classe
|
|
||||||
//! Computes some property on one blob of the class
|
|
||||||
double GetNumber( int indexblob, funcio_calculBlob *evaluador ) const;
|
|
||||||
|
|
||||||
//! Retorna aquells blobs que compleixen les condicions del filtre en el destination
|
|
||||||
//! Filters the blobs of the class using some property
|
|
||||||
void Filter(CBlobResult &dst,
|
|
||||||
int filterAction, funcio_calculBlob *evaluador,
|
|
||||||
int condition, double lowLimit, double highLimit = 0 );
|
|
||||||
void Filter(CBlobResult &dst,
|
|
||||||
int filterAction, funcio_calculBlob *evaluador,
|
|
||||||
int condition, double lowLimit, double highLimit = 0 ) const;
|
|
||||||
|
|
||||||
//! Retorna l'enèssim blob segons un determinat criteri
|
|
||||||
//! Sorts the blobs of the class acording to some criteria and returns the n-th blob
|
|
||||||
void GetNthBlob( funcio_calculBlob *criteri, int nBlob, CBlob &dst ) const;
|
|
||||||
|
|
||||||
//! Retorna el blob enèssim
|
|
||||||
//! Gets the n-th blob of the class ( without sorting )
|
|
||||||
CBlob GetBlob(int indexblob) const;
|
|
||||||
CBlob *GetBlob(int indexblob);
|
|
||||||
|
|
||||||
//! Elimina tots els blobs de l'objecte
|
|
||||||
//! Clears all the blobs of the class
|
|
||||||
void ClearBlobs();
|
|
||||||
|
|
||||||
//! Escriu els blobs a un fitxer
|
|
||||||
//! Prints some features of all the blobs in a file
|
|
||||||
void PrintBlobs( char *nom_fitxer ) const;
|
|
||||||
|
|
||||||
|
|
||||||
//Metodes GET/SET
|
|
||||||
|
|
||||||
//! Retorna el total de blobs
|
|
||||||
//! Gets the total number of blobs
|
|
||||||
int GetNumBlobs() const
|
|
||||||
{
|
|
||||||
return(m_blobs.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//! Funció per gestionar els errors
|
|
||||||
//! Function to manage the errors
|
|
||||||
void RaiseError(const int errorCode) const;
|
|
||||||
|
|
||||||
//! Does the Filter method job
|
|
||||||
void DoFilter(CBlobResult &dst,
|
|
||||||
int filterAction, funcio_calculBlob *evaluador,
|
|
||||||
int condition, double lowLimit, double highLimit = 0) const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
//! Vector amb els blobs
|
|
||||||
//! Vector with all the blobs
|
|
||||||
Blob_vector m_blobs;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // !defined(_CLASSE_BLOBRESULT_INCLUDED)
|
|
|
@ -1,30 +0,0 @@
|
||||||
#if !defined(_COMPONENT_LABELING_H_INCLUDED)
|
|
||||||
#define _CLASSE_BLOBRESULT_INCLUDED
|
|
||||||
|
|
||||||
#include "vector"
|
|
||||||
#include "BlobContour.h"
|
|
||||||
#include "blob.h"
|
|
||||||
|
|
||||||
|
|
||||||
//! definició de que es un vector de blobs
|
|
||||||
typedef std::vector<CBlob*> Blob_vector;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ComponentLabeling( IplImage* inputImage,
|
|
||||||
IplImage* maskImage,
|
|
||||||
unsigned char backgroundColor,
|
|
||||||
Blob_vector &blobs );
|
|
||||||
|
|
||||||
|
|
||||||
void contourTracing( IplImage *image, IplImage *mask, CvPoint contourStart, t_labelType *labels,
|
|
||||||
bool *visitedPoints, t_labelType label,
|
|
||||||
bool internalContour, unsigned char backgroundColor,
|
|
||||||
CBlobContour *currentBlobContour );
|
|
||||||
|
|
||||||
CvPoint tracer( IplImage *image, IplImage *mask, CvPoint P, bool *visitedPoints,
|
|
||||||
short initialMovement,
|
|
||||||
unsigned char backgroundColor, short &movement );
|
|
||||||
|
|
||||||
|
|
||||||
#endif //!_CLASSE_BLOBRESULT_INCLUDED
|
|
|
@ -1,172 +0,0 @@
|
||||||
/************************************************************************
|
|
||||||
Blob.h
|
|
||||||
|
|
||||||
FUNCIONALITAT: Definició de la classe CBlob
|
|
||||||
AUTOR: Inspecta S.L.
|
|
||||||
MODIFICACIONS (Modificació, Autor, Data):
|
|
||||||
|
|
||||||
FUNCTIONALITY: Definition of the CBlob class and some helper classes to perform
|
|
||||||
some calculations on it
|
|
||||||
AUTHOR: Inspecta S.L.
|
|
||||||
MODIFICATIONS (Modification, Author, Date):
|
|
||||||
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
//! Disable warnings referred to 255 character truncation for the std:map
|
|
||||||
#pragma warning( disable : 4786 )
|
|
||||||
|
|
||||||
#ifndef CBLOB_INSPECTA_INCLUDED
|
|
||||||
#define CBLOB_INSPECTA_INCLUDED
|
|
||||||
|
|
||||||
#include <opencv/cxcore.h>
|
|
||||||
#include "BlobLibraryConfiguration.h"
|
|
||||||
#include "BlobContour.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef BLOB_OBJECT_FACTORY
|
|
||||||
//! Object factory pattern implementation
|
|
||||||
#include "..\inspecta\DesignPatterns\ObjectFactory.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//! Type of labelled images
|
|
||||||
typedef unsigned int t_labelType;
|
|
||||||
|
|
||||||
|
|
||||||
//! Blob class
|
|
||||||
class CBlob
|
|
||||||
{
|
|
||||||
typedef std::list<CBlobContour> t_contourList;
|
|
||||||
|
|
||||||
public:
|
|
||||||
CBlob();
|
|
||||||
CBlob( t_labelType id, CvPoint startPoint, CvSize originalImageSize );
|
|
||||||
~CBlob();
|
|
||||||
|
|
||||||
//! Copy constructor
|
|
||||||
CBlob( const CBlob &src );
|
|
||||||
CBlob( const CBlob *src );
|
|
||||||
|
|
||||||
//! Operador d'assignació
|
|
||||||
//! Assigment operator
|
|
||||||
CBlob& operator=(const CBlob &src );
|
|
||||||
|
|
||||||
//! Adds a new internal contour to the blob
|
|
||||||
void AddInternalContour( const CBlobContour &newContour );
|
|
||||||
|
|
||||||
//! Retrieves contour in Freeman's chain code
|
|
||||||
CBlobContour *GetExternalContour()
|
|
||||||
{
|
|
||||||
return &m_externalContour;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Retrieves blob storage
|
|
||||||
CvMemStorage *GetStorage()
|
|
||||||
{
|
|
||||||
return m_storage;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Get label ID
|
|
||||||
t_labelType GetID()
|
|
||||||
{
|
|
||||||
return m_id;
|
|
||||||
}
|
|
||||||
//! > 0 for extern blobs, 0 if not
|
|
||||||
int Exterior( IplImage *mask, bool xBorder = true, bool yBorder = true );
|
|
||||||
//! Compute blob's area
|
|
||||||
double Area();
|
|
||||||
//! Compute blob's perimeter
|
|
||||||
double Perimeter();
|
|
||||||
//! Compute blob's moment (p,q up to MAX_CALCULATED_MOMENTS)
|
|
||||||
double Moment(int p, int q);
|
|
||||||
|
|
||||||
//! Compute extern perimeter
|
|
||||||
double ExternPerimeter( IplImage *mask, bool xBorder = true, bool yBorder = true );
|
|
||||||
|
|
||||||
//! Get mean grey color
|
|
||||||
double Mean( IplImage *image );
|
|
||||||
|
|
||||||
//! Get standard deviation grey color
|
|
||||||
double StdDev( IplImage *image );
|
|
||||||
|
|
||||||
//! Indica si el blob està buit ( no té cap info associada )
|
|
||||||
//! Shows if the blob has associated information
|
|
||||||
bool IsEmpty();
|
|
||||||
|
|
||||||
//! Retorna el poligon convex del blob
|
|
||||||
//! Calculates the convex hull of the blob
|
|
||||||
t_PointList GetConvexHull();
|
|
||||||
|
|
||||||
//! Pinta l'interior d'un blob d'un color determinat
|
|
||||||
//! Paints the blob in an image
|
|
||||||
void FillBlob( IplImage *imatge, CvScalar color, int offsetX = 0, int offsetY = 0 );
|
|
||||||
|
|
||||||
//! Join a blob to current one (add's contour
|
|
||||||
void JoinBlob( CBlob *blob );
|
|
||||||
|
|
||||||
//! Get bounding box
|
|
||||||
CvRect GetBoundingBox();
|
|
||||||
//! Get bounding ellipse
|
|
||||||
CvBox2D GetEllipse();
|
|
||||||
|
|
||||||
//! Minimun X
|
|
||||||
double MinX()
|
|
||||||
{
|
|
||||||
return GetBoundingBox().x;
|
|
||||||
}
|
|
||||||
//! Minimun Y
|
|
||||||
double MinY()
|
|
||||||
{
|
|
||||||
return GetBoundingBox().y;
|
|
||||||
}
|
|
||||||
//! Maximun X
|
|
||||||
double MaxX()
|
|
||||||
{
|
|
||||||
return GetBoundingBox().x + GetBoundingBox().width;
|
|
||||||
}
|
|
||||||
//! Maximun Y
|
|
||||||
double MaxY()
|
|
||||||
{
|
|
||||||
return GetBoundingBox().y + GetBoundingBox().height;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
|
|
||||||
//! Deallocates all contours
|
|
||||||
void ClearContours();
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// Blob contours
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//! Contour storage memory
|
|
||||||
CvMemStorage *m_storage;
|
|
||||||
//! External contour of the blob (crack codes)
|
|
||||||
CBlobContour m_externalContour;
|
|
||||||
//! Internal contours (crack codes)
|
|
||||||
t_contourList m_internalContours;
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// Blob features
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//! Label number
|
|
||||||
t_labelType m_id;
|
|
||||||
//! Area
|
|
||||||
double m_area;
|
|
||||||
//! Perimeter
|
|
||||||
double m_perimeter;
|
|
||||||
//! Extern perimeter from blob
|
|
||||||
double m_externPerimeter;
|
|
||||||
//! Mean gray color
|
|
||||||
double m_meanGray;
|
|
||||||
//! Standard deviation from gray color blob distribution
|
|
||||||
double m_stdDevGray;
|
|
||||||
//! Bounding box
|
|
||||||
CvRect m_boundingBox;
|
|
||||||
//! Bounding ellipse
|
|
||||||
CvBox2D m_ellipse;
|
|
||||||
//! Sizes from image where blob is extracted
|
|
||||||
CvSize m_originalImageSize;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //CBLOB_INSPECTA_INCLUDED
|
|
|
@ -1 +0,0 @@
|
||||||
A/
|
|
|
@ -1,43 +0,0 @@
|
||||||
set(NAME glm)
|
|
||||||
|
|
||||||
file(GLOB ROOT_SOURCE *.cpp)
|
|
||||||
file(GLOB ROOT_INLINE *.inl)
|
|
||||||
file(GLOB ROOT_HEADER *.hpp)
|
|
||||||
|
|
||||||
file(GLOB_RECURSE CORE_SOURCE ./core/*.cpp)
|
|
||||||
file(GLOB_RECURSE CORE_INLINE ./core/*.inl)
|
|
||||||
file(GLOB_RECURSE CORE_HEADER ./core/*.hpp)
|
|
||||||
|
|
||||||
file(GLOB_RECURSE GTC_SOURCE ./gtc/*.cpp)
|
|
||||||
file(GLOB_RECURSE GTC_INLINE ./gtc/*.inl)
|
|
||||||
file(GLOB_RECURSE GTC_HEADER ./gtc/*.hpp)
|
|
||||||
|
|
||||||
file(GLOB_RECURSE GTX_SOURCE ./gtx/*.cpp)
|
|
||||||
file(GLOB_RECURSE GTX_INLINE ./gtx/*.inl)
|
|
||||||
file(GLOB_RECURSE GTX_HEADER ./gtx/*.hpp)
|
|
||||||
|
|
||||||
file(GLOB_RECURSE VIRTREV_SOURCE ./virtrev/*.cpp)
|
|
||||||
file(GLOB_RECURSE VIRTREV_INLINE ./virtrev/*.inl)
|
|
||||||
file(GLOB_RECURSE VIRTREV_HEADER ./virtrev/*.hpp)
|
|
||||||
|
|
||||||
source_group("Core Files" FILES ${CORE_SOURCE})
|
|
||||||
source_group("Core Files" FILES ${CORE_INLINE})
|
|
||||||
source_group("Core Files" FILES ${CORE_HEADER})
|
|
||||||
source_group("GTC Files" FILES ${GTC_SOURCE})
|
|
||||||
source_group("GTC Files" FILES ${GTC_INLINE})
|
|
||||||
source_group("GTC Files" FILES ${GTC_HEADER})
|
|
||||||
source_group("GTX Files" FILES ${GTX_SOURCE})
|
|
||||||
source_group("GTX Files" FILES ${GTX_INLINE})
|
|
||||||
source_group("GTX Files" FILES ${GTX_HEADER})
|
|
||||||
source_group("VIRTREV Files" FILES ${VIRTREV_SOURCE})
|
|
||||||
source_group("VIRTREV Files" FILES ${VIRTREV_INLINE})
|
|
||||||
source_group("VIRTREV Files" FILES ${VIRTREV_HEADER})
|
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
|
|
||||||
|
|
||||||
add_executable(${NAME}
|
|
||||||
${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
|
|
||||||
${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
|
|
||||||
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
|
|
||||||
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
|
|
||||||
${VIRTREV_SOURCE} ${VIRTREV_INLINE} ${VIRTREV_HEADER})
|
|
282
Makefile
|
@ -1,282 +0,0 @@
|
||||||
#############################################################################
|
|
||||||
#
|
|
||||||
# Generic Makefile for C/C++ Program
|
|
||||||
#
|
|
||||||
# License: GPL (General Public License)
|
|
||||||
# Author: whyglinux <whyglinux AT gmail DOT com>
|
|
||||||
# Date: 2006/03/04 (version 0.1)
|
|
||||||
# 2007/03/24 (version 0.2)
|
|
||||||
# 2007/04/09 (version 0.3)
|
|
||||||
# 2007/06/26 (version 0.4)
|
|
||||||
# 2008/04/05 (version 0.5)
|
|
||||||
#
|
|
||||||
# Description:
|
|
||||||
# ------------
|
|
||||||
# This is an easily customizable makefile template. The purpose is to
|
|
||||||
# provide an instant building environment for C/C++ programs.
|
|
||||||
#
|
|
||||||
# It searches all the C/C++ source files in the specified directories,
|
|
||||||
# makes dependencies, compiles and links to form an executable.
|
|
||||||
#
|
|
||||||
# Besides its default ability to build C/C++ programs which use only
|
|
||||||
# standard C/C++ libraries, you can customize the Makefile to build
|
|
||||||
# those using other libraries. Once done, without any changes you can
|
|
||||||
# then build programs using the same or less libraries, even if source
|
|
||||||
# files are renamed, added or removed. Therefore, it is particularly
|
|
||||||
# convenient to use it to build codes for experimental or study use.
|
|
||||||
#
|
|
||||||
# GNU make is expected to use the Makefile. Other versions of makes
|
|
||||||
# may or may not work.
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
# ------
|
|
||||||
# 1. Copy the Makefile to your program directory.
|
|
||||||
# 2. Customize in the "Customizable Section" only if necessary:
|
|
||||||
# * to use non-standard C/C++ libraries, set pre-processor or compiler
|
|
||||||
# options to <MY_CFLAGS> and linker ones to <MY_LIBS>
|
|
||||||
# (See Makefile.gtk+-2.0 for an example)
|
|
||||||
# * to search sources in more directories, set to <SRCDIRS>
|
|
||||||
# * to specify your favorite program name, set to <PROGRAM>
|
|
||||||
# 3. Type make to start building your program.
|
|
||||||
#
|
|
||||||
# Make Target:
|
|
||||||
# ------------
|
|
||||||
# The Makefile provides the following targets to make:
|
|
||||||
# $ make compile and link
|
|
||||||
# $ make NODEP=yes compile and link without generating dependencies
|
|
||||||
# $ make objs compile only (no linking)
|
|
||||||
# $ make tags create tags for Emacs editor
|
|
||||||
# $ make ctags create ctags for VI editor
|
|
||||||
# $ make clean clean objects and the executable file
|
|
||||||
# $ make distclean clean objects, the executable and dependencies
|
|
||||||
# $ make help get the usage of the makefile
|
|
||||||
#
|
|
||||||
#===========================================================================
|
|
||||||
|
|
||||||
## Customizable Section: adapt those variables to suit your program.
|
|
||||||
##==========================================================================
|
|
||||||
|
|
||||||
# The pre-processor and compiler options.
|
|
||||||
MY_CFLAGS = -I/usr/X11R6/include/
|
|
||||||
|
|
||||||
# The linker options.
|
|
||||||
MY_LIBS =
|
|
||||||
|
|
||||||
# The pre-processor options used by the cpp (man cpp for more).
|
|
||||||
CPPFLAGS = -Wall
|
|
||||||
|
|
||||||
# The options used in linking as well as in any direct use of ld.
|
|
||||||
#LDFLAGS = -L/usr/X11R6/lib -lX11 -lXi -lXmu -lglut -lGL -lGLU -lportaudio
|
|
||||||
LDFLAGS = -L/usr/X11R6/lib -lglut -lGL -lGLU -lportaudio
|
|
||||||
|
|
||||||
# The directories in which source files reside.
|
|
||||||
# If not specified, only the current directory will be serached.
|
|
||||||
SRCDIRS =
|
|
||||||
|
|
||||||
# The executable file name.
|
|
||||||
# If not specified, current directory name or `a.out' will be used.
|
|
||||||
PROGRAM = demo
|
|
||||||
|
|
||||||
## Implicit Section: change the following only when necessary.
|
|
||||||
##==========================================================================
|
|
||||||
|
|
||||||
# The source file types (headers excluded).
|
|
||||||
# .c indicates C source files, and others C++ ones.
|
|
||||||
SRCEXTS = .c .C .cc .cpp .CPP .c++ .cxx .cp
|
|
||||||
|
|
||||||
# The header file types.
|
|
||||||
HDREXTS = .h .H .hh .hpp .HPP .h++ .hxx .hp
|
|
||||||
|
|
||||||
# The pre-processor and compiler options.
|
|
||||||
# Users can override those variables from the command line.
|
|
||||||
CFLAGS = -g -O2
|
|
||||||
CXXFLAGS= -g -O2
|
|
||||||
|
|
||||||
# The C program compiler.
|
|
||||||
#CC = gcc
|
|
||||||
|
|
||||||
# The C++ program compiler.
|
|
||||||
#CXX = g++
|
|
||||||
|
|
||||||
# Un-comment the following line to compile C programs as C++ ones.
|
|
||||||
#CC = $(CXX)
|
|
||||||
|
|
||||||
# The command used to delete file.
|
|
||||||
#RM = rm -f
|
|
||||||
|
|
||||||
ETAGS = etags
|
|
||||||
ETAGSFLAGS =
|
|
||||||
|
|
||||||
CTAGS = ctags
|
|
||||||
CTAGSFLAGS =
|
|
||||||
|
|
||||||
## Stable Section: usually no need to be changed. But you can add more.
|
|
||||||
##==========================================================================
|
|
||||||
SHELL = /bin/sh
|
|
||||||
EMPTY =
|
|
||||||
SPACE = $(EMPTY) $(EMPTY)
|
|
||||||
ifeq ($(PROGRAM),)
|
|
||||||
CUR_PATH_NAMES = $(subst /,$(SPACE),$(subst $(SPACE),_,$(CURDIR)))
|
|
||||||
PROGRAM = $(word $(words $(CUR_PATH_NAMES)),$(CUR_PATH_NAMES))
|
|
||||||
ifeq ($(PROGRAM),)
|
|
||||||
PROGRAM = a.out
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(SRCDIRS),)
|
|
||||||
SRCDIRS = .
|
|
||||||
endif
|
|
||||||
SOURCES = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
|
|
||||||
HEADERS = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(HDREXTS))))
|
|
||||||
SRC_CXX = $(filter-out %.c,$(SOURCES))
|
|
||||||
OBJS = $(addsuffix .o, $(basename $(SOURCES)))
|
|
||||||
DEPS = $(OBJS:.o=.d)
|
|
||||||
|
|
||||||
## Define some useful variables.
|
|
||||||
DEP_OPT = $(shell if `$(CC) --version | grep "GCC" >/dev/null`; then \
|
|
||||||
echo "-MM -MP"; else echo "-M"; fi )
|
|
||||||
DEPEND = $(CC) $(DEP_OPT) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS)
|
|
||||||
DEPEND.d = $(subst -g ,,$(DEPEND))
|
|
||||||
COMPILE.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) -c
|
|
||||||
COMPILE.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c
|
|
||||||
#LINK.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
|
|
||||||
#LINK.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
|
|
||||||
LINK.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS)
|
|
||||||
LINK.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS)
|
|
||||||
|
|
||||||
.PHONY: all objs tags ctags clean distclean help show
|
|
||||||
|
|
||||||
# Delete the default suffixes
|
|
||||||
.SUFFIXES:
|
|
||||||
|
|
||||||
all: $(PROGRAM)
|
|
||||||
|
|
||||||
# Rules for creating dependency files (.d).
|
|
||||||
#------------------------------------------
|
|
||||||
|
|
||||||
%.d:%.c
|
|
||||||
@echo -n $(dir $<) > $@
|
|
||||||
@$(DEPEND.d) $< >> $@
|
|
||||||
|
|
||||||
%.d:%.C
|
|
||||||
@echo -n $(dir $<) > $@
|
|
||||||
@$(DEPEND.d) $< >> $@
|
|
||||||
|
|
||||||
%.d:%.cc
|
|
||||||
@echo -n $(dir $<) > $@
|
|
||||||
@$(DEPEND.d) $< >> $@
|
|
||||||
|
|
||||||
%.d:%.cpp
|
|
||||||
@echo -n $(dir $<) > $@
|
|
||||||
@$(DEPEND.d) $< >> $@
|
|
||||||
|
|
||||||
%.d:%.CPP
|
|
||||||
@echo -n $(dir $<) > $@
|
|
||||||
@$(DEPEND.d) $< >> $@
|
|
||||||
|
|
||||||
%.d:%.c++
|
|
||||||
@echo -n $(dir $<) > $@
|
|
||||||
@$(DEPEND.d) $< >> $@
|
|
||||||
|
|
||||||
%.d:%.cp
|
|
||||||
@echo -n $(dir $<) > $@
|
|
||||||
@$(DEPEND.d) $< >> $@
|
|
||||||
|
|
||||||
%.d:%.cxx
|
|
||||||
@echo -n $(dir $<) > $@
|
|
||||||
@$(DEPEND.d) $< >> $@
|
|
||||||
|
|
||||||
# Rules for generating object files (.o).
|
|
||||||
#----------------------------------------
|
|
||||||
objs:$(OBJS)
|
|
||||||
|
|
||||||
%.o:%.c
|
|
||||||
$(COMPILE.c) $< -o $@
|
|
||||||
|
|
||||||
%.o:%.C
|
|
||||||
$(COMPILE.cxx) $< -o $@
|
|
||||||
|
|
||||||
%.o:%.cc
|
|
||||||
$(COMPILE.cxx) $< -o $@
|
|
||||||
|
|
||||||
%.o:%.cpp
|
|
||||||
$(COMPILE.cxx) $< -o $@
|
|
||||||
|
|
||||||
%.o:%.CPP
|
|
||||||
$(COMPILE.cxx) $< -o $@
|
|
||||||
|
|
||||||
%.o:%.c++
|
|
||||||
$(COMPILE.cxx) $< -o $@
|
|
||||||
|
|
||||||
%.o:%.cp
|
|
||||||
$(COMPILE.cxx) $< -o $@
|
|
||||||
|
|
||||||
%.o:%.cxx
|
|
||||||
$(COMPILE.cxx) $< -o $@
|
|
||||||
|
|
||||||
# Rules for generating the tags.
|
|
||||||
#-------------------------------------
|
|
||||||
tags: $(HEADERS) $(SOURCES)
|
|
||||||
$(ETAGS) $(ETAGSFLAGS) $(HEADERS) $(SOURCES)
|
|
||||||
|
|
||||||
ctags: $(HEADERS) $(SOURCES)
|
|
||||||
$(CTAGS) $(CTAGSFLAGS) $(HEADERS) $(SOURCES)
|
|
||||||
|
|
||||||
# Rules for generating the executable.
|
|
||||||
#-------------------------------------
|
|
||||||
$(PROGRAM):$(OBJS)
|
|
||||||
ifeq ($(SRC_CXX),) # C program
|
|
||||||
$(LINK.c) $(OBJS) $(MY_LIBS) -o $@ $(LDFLAGS)
|
|
||||||
@echo Type ./$@ to execute the program.
|
|
||||||
else # C++ program
|
|
||||||
$(LINK.cxx) $(OBJS) $(MY_LIBS) -o $@ $(LDFLAGS)
|
|
||||||
@echo Type ./$@ to execute the program.
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifndef NODEP
|
|
||||||
ifneq ($(DEPS),)
|
|
||||||
sinclude $(DEPS)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(RM) $(OBJS) $(PROGRAM) $(PROGRAM).exe
|
|
||||||
|
|
||||||
distclean: clean
|
|
||||||
$(RM) $(DEPS) TAGS
|
|
||||||
|
|
||||||
# Show help.
|
|
||||||
help:
|
|
||||||
@echo 'Generic Makefile for C/C++ Programs (gcmakefile) version 0.5'
|
|
||||||
@echo 'Copyright (C) 2007, 2008 whyglinux <whyglinux@hotmail.com>'
|
|
||||||
@echo
|
|
||||||
@echo 'Usage: make [TARGET]'
|
|
||||||
@echo 'TARGETS:'
|
|
||||||
@echo ' all (=make) compile and link.'
|
|
||||||
@echo ' NODEP=yes make without generating dependencies.'
|
|
||||||
@echo ' objs compile only (no linking).'
|
|
||||||
@echo ' tags create tags for Emacs editor.'
|
|
||||||
@echo ' ctags create ctags for VI editor.'
|
|
||||||
@echo ' clean clean objects and the executable file.'
|
|
||||||
@echo ' distclean clean objects, the executable and dependencies.'
|
|
||||||
@echo ' show show variables (for debug use only).'
|
|
||||||
@echo ' help print this message.'
|
|
||||||
@echo
|
|
||||||
@echo 'Report bugs to <whyglinux AT gmail DOT com>.'
|
|
||||||
|
|
||||||
# Show variables (for debug use only.)
|
|
||||||
show:
|
|
||||||
@echo 'PROGRAM :' $(PROGRAM)
|
|
||||||
@echo 'SRCDIRS :' $(SRCDIRS)
|
|
||||||
@echo 'HEADERS :' $(HEADERS)
|
|
||||||
@echo 'SOURCES :' $(SOURCES)
|
|
||||||
@echo 'SRC_CXX :' $(SRC_CXX)
|
|
||||||
@echo 'OBJS :' $(OBJS)
|
|
||||||
@echo 'DEPS :' $(DEPS)
|
|
||||||
@echo 'DEPEND :' $(DEPEND)
|
|
||||||
@echo 'COMPILE.c :' $(COMPILE.c)
|
|
||||||
@echo 'COMPILE.cxx :' $(COMPILE.cxx)
|
|
||||||
@echo 'link.c :' $(LINK.c)
|
|
||||||
@echo 'link.cxx :' $(LINK.cxx)
|
|
||||||
|
|
||||||
## End of the Makefile ## Suggestions are welcome ## All rights reserved ##
|
|
||||||
#############################################################################
|
|
7
README
|
@ -1,7 +0,0 @@
|
||||||
Boxing balance surface project
|
|
||||||
|
|
||||||
Low latency high FPS display of exact balance point of a standing person,
|
|
||||||
detected by pressure sensors at corners of a 4' by 4' platform.
|
|
||||||
Sensors read and processed by Maple ret6 board, sent to MacBook via serial USB.
|
|
||||||
|
|
||||||
|
|
63
cmake/modules/FindGLM.cmake
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
# FindGLM - attempts to locate the glm matrix/vector library.
|
||||||
|
#
|
||||||
|
# This module defines the following variables (on success):
|
||||||
|
# GLM_INCLUDE_DIRS - where to find glm/glm.hpp
|
||||||
|
# GLM_FOUND - if the library was successfully located
|
||||||
|
#
|
||||||
|
# It is trying a few standard installation locations, but can be customized
|
||||||
|
# with the following variables:
|
||||||
|
# GLM_ROOT_DIR - root directory of a glm installation
|
||||||
|
# Headers are expected to be found in either:
|
||||||
|
# <GLM_ROOT_DIR>/glm/glm.hpp OR
|
||||||
|
# <GLM_ROOT_DIR>/include/glm/glm.hpp
|
||||||
|
# This variable can either be a cmake or environment
|
||||||
|
# variable. Note however that changing the value
|
||||||
|
# of the environment varible will NOT result in
|
||||||
|
# re-running the header search and therefore NOT
|
||||||
|
# adjust the variables set by this module.
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Copyright 2012 Carsten Neumann
|
||||||
|
#
|
||||||
|
# Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
# see accompanying file Copyright.txt for details.
|
||||||
|
#
|
||||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# See the License for more information.
|
||||||
|
#=============================================================================
|
||||||
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
|
# License text for the above reference.)
|
||||||
|
|
||||||
|
# default search dirs
|
||||||
|
SET(_glm_HEADER_SEARCH_DIRS
|
||||||
|
"/usr/include"
|
||||||
|
"/usr/local/include")
|
||||||
|
|
||||||
|
# check environment variable
|
||||||
|
SET(_glm_ENV_ROOT_DIR "$ENV{GLM_ROOT_DIR}")
|
||||||
|
|
||||||
|
IF(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR)
|
||||||
|
SET(GLM_ROOT_DIR "${_glm_ENV_ROOT_DIR}")
|
||||||
|
ENDIF(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR)
|
||||||
|
|
||||||
|
# put user specified location at beginning of search
|
||||||
|
IF(GLM_ROOT_DIR)
|
||||||
|
SET(_glm_HEADER_SEARCH_DIRS "${GLM_ROOT_DIR}"
|
||||||
|
"${GLM_ROOT_DIR}/include"
|
||||||
|
${_glm_HEADER_SEARCH_DIRS})
|
||||||
|
ENDIF(GLM_ROOT_DIR)
|
||||||
|
|
||||||
|
# locate header
|
||||||
|
FIND_PATH(GLM_INCLUDE_DIR "glm/glm.hpp"
|
||||||
|
PATHS ${_glm_HEADER_SEARCH_DIRS})
|
||||||
|
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLM DEFAULT_MSG
|
||||||
|
GLM_INCLUDE_DIR)
|
||||||
|
|
||||||
|
IF(GLM_FOUND)
|
||||||
|
SET(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}")
|
||||||
|
|
||||||
|
MESSAGE(STATUS "GLM_INCLUDE_DIR = ${GLM_INCLUDE_DIR}")
|
||||||
|
ENDIF(GLM_FOUND)
|
44
cmake/modules/FindLodePNG.cmake
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
# - Try to find the LodePNG library
|
||||||
|
#
|
||||||
|
# You must provide a LODEPNG_ROOT_DIR which contains the header and cpp file
|
||||||
|
#
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# LODEPNG_FOUND - system has LODEPNG_FOUND
|
||||||
|
# LODEPNG_INCLUDE_DIRS - the LodePNG include directory
|
||||||
|
# LODEPNG_LIBRARY - Link these to use LodePNG
|
||||||
|
#
|
||||||
|
# Copyright (c) 2013 Stephen Birarda <birarda@coffeeandpower.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
if (LODEPNG_LIBRARY AND LODEPNG_INCLUDE_DIRS)
|
||||||
|
# in cache already
|
||||||
|
set(LODEPNG_FOUND TRUE)
|
||||||
|
else (LODEPNG_LIBRARY AND LODEPNG_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
set(LODEPNG_INCLUDE_DIRS
|
||||||
|
${LODEPNG_ROOT_DIR}/lodepng.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set(LODEPNG_LIBRARY
|
||||||
|
${LODEPNG_ROOT_DIR}/lodepng.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
if (LODEPNG_INCLUDE_DIRS AND LODEPNG_LIBRARY)
|
||||||
|
set(LODEPNG_FOUND TRUE)
|
||||||
|
endif (LODEPNG_INCLUDE_DIRS AND LODEPNG_LIBRARY)
|
||||||
|
|
||||||
|
if (LODEPNG_FOUND)
|
||||||
|
if (NOT LodePNG_FIND_QUIETLY)
|
||||||
|
message(STATUS "Found LodePNG: ${LODEPNG_LIBRARY}")
|
||||||
|
endif (NOT LodePNG_FIND_QUIETLY)
|
||||||
|
else (LODEPNG_FOUND)
|
||||||
|
if (LodePNG_FIND_REQUIRED)
|
||||||
|
message(FATAL_ERROR "Could not find LodePNG")
|
||||||
|
endif (LodePNG_FIND_REQUIRED)
|
||||||
|
endif (LODEPNG_FOUND)
|
||||||
|
|
||||||
|
# show the LODEPNG_INCLUDE_DIRS and LODEPNG_LIBRARY variables only in the advanced view
|
||||||
|
mark_as_advanced(LODEPNG_INCLUDE_DIRS LODEPNG_LIBRARY)
|
||||||
|
|
||||||
|
endif (LODEPNG_LIBRARY AND LODEPNG_INCLUDE_DIRS)
|
46
cmake/modules/FindPortaudio.cmake
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
# - Try to find the Portaudio library
|
||||||
|
#
|
||||||
|
# You must provide a PORTAUDIO_ROOT_DIR which contains the header and library
|
||||||
|
#
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# PORTAUDIO_FOUND - system has Portaudio
|
||||||
|
# PORTAUDIO_INCLUDE_DIRS - the Portaudio include directory
|
||||||
|
# PORTAUDIO_LIBRARY - Link these to use Portaudio
|
||||||
|
#
|
||||||
|
# Copyright (c) 2013 Stephen Birarda <birarda@coffeeandpower.com>
|
||||||
|
#
|
||||||
|
# Heavily based on Andreas Schneider's original FindPortaudio.cmake
|
||||||
|
# which can be found at http://gnuradio.org/redmine/projects/gnuradio/repository/
|
||||||
|
|
||||||
|
|
||||||
|
if (PORTAUDIO_LIBRARY AND PORTAUDIO_INCLUDE_DIRS)
|
||||||
|
# in cache already
|
||||||
|
set(PORTAUDIO_FOUND TRUE)
|
||||||
|
else (PORTAUDIO_LIBRARY AND PORTAUDIO_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
set(PORTAUDIO_INCLUDE_DIRS
|
||||||
|
${PORTAUDIO_ROOT_DIR}/portaudio.h
|
||||||
|
)
|
||||||
|
set(PORTAUDIO_LIBRARY
|
||||||
|
${PORTAUDIO_ROOT_DIR}/libportaudio.a
|
||||||
|
)
|
||||||
|
|
||||||
|
if (PORTAUDIO_INCLUDE_DIRS AND PORTAUDIO_LIBRARY)
|
||||||
|
set(PORTAUDIO_FOUND TRUE)
|
||||||
|
endif (PORTAUDIO_INCLUDE_DIRS AND PORTAUDIO_LIBRARY)
|
||||||
|
|
||||||
|
if (PORTAUDIO_FOUND)
|
||||||
|
if (NOT Portaudio_FIND_QUIETLY)
|
||||||
|
message(STATUS "Found Portaudio: ${PORTAUDIO_LIBRARY}")
|
||||||
|
endif (NOT Portaudio_FIND_QUIETLY)
|
||||||
|
else (PORTAUDIO_FOUND)
|
||||||
|
if (Portaudio_FIND_REQUIRED)
|
||||||
|
message(FATAL_ERROR "Could not find Portaudio")
|
||||||
|
endif (Portaudio_FIND_REQUIRED)
|
||||||
|
endif (PORTAUDIO_FOUND)
|
||||||
|
|
||||||
|
# show the PORTAUDIO_INCLUDE_DIRS and PORTAUDIO_LIBRARY variables only in the advanced view
|
||||||
|
mark_as_advanced(PORTAUDIO_INCLUDE_DIRS PORTAUDIO_LIBRARY)
|
||||||
|
|
||||||
|
endif (PORTAUDIO_LIBRARY AND PORTAUDIO_INCLUDE_DIRS)
|
|
@ -1,148 +0,0 @@
|
||||||
// !$*UTF8*$!
|
|
||||||
{
|
|
||||||
08FB7793FE84155DC02AAC07 /* Project object */ = {
|
|
||||||
activeBuildConfigurationName = Release;
|
|
||||||
activeExecutable = D40BDF8D13403FC300B0BE1F /* automata7 */;
|
|
||||||
activeTarget = 8DD76F620486A84900D96B5E /* automata7 */;
|
|
||||||
addToTargets = (
|
|
||||||
8DD76F620486A84900D96B5E /* automata7 */,
|
|
||||||
);
|
|
||||||
codeSenseManager = D40BDF9913403FC900B0BE1F /* Code sense */;
|
|
||||||
executables = (
|
|
||||||
D40BDF8D13403FC300B0BE1F /* automata7 */,
|
|
||||||
);
|
|
||||||
perUserDictionary = {
|
|
||||||
PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = {
|
|
||||||
PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
|
|
||||||
PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID;
|
|
||||||
PBXFileTableDataSourceColumnWidthsKey = (
|
|
||||||
20,
|
|
||||||
833,
|
|
||||||
20,
|
|
||||||
48,
|
|
||||||
43,
|
|
||||||
43,
|
|
||||||
20,
|
|
||||||
);
|
|
||||||
PBXFileTableDataSourceColumnsKey = (
|
|
||||||
PBXFileDataSource_FiletypeID,
|
|
||||||
PBXFileDataSource_Filename_ColumnID,
|
|
||||||
PBXFileDataSource_Built_ColumnID,
|
|
||||||
PBXFileDataSource_ObjectSize_ColumnID,
|
|
||||||
PBXFileDataSource_Errors_ColumnID,
|
|
||||||
PBXFileDataSource_Warnings_ColumnID,
|
|
||||||
PBXFileDataSource_Target_ColumnID,
|
|
||||||
);
|
|
||||||
};
|
|
||||||
PBXPerProjectTemplateStateSaveDate = 348474226;
|
|
||||||
PBXWorkspaceStateSaveDate = 348474226;
|
|
||||||
};
|
|
||||||
perUserProjectItems = {
|
|
||||||
D48F923814C54A47007626C8 = D48F923814C54A47007626C8 /* PBXTextBookmark */;
|
|
||||||
D48F925214C54B80007626C8 /* PBXTextBookmark */ = D48F925214C54B80007626C8 /* PBXTextBookmark */;
|
|
||||||
D4C40DC71492DE0C0098EA8B = D4C40DC71492DE0C0098EA8B /* PBXTextBookmark */;
|
|
||||||
D4DCA72D144F9BEB00D336A4 = D4DCA72D144F9BEB00D336A4 /* PBXTextBookmark */;
|
|
||||||
};
|
|
||||||
sourceControlManager = D40BDF9813403FC900B0BE1F /* Source Control */;
|
|
||||||
userBuildSettings = {
|
|
||||||
};
|
|
||||||
};
|
|
||||||
08FB7796FE84155DC02AAC07 /* main.cpp */ = {
|
|
||||||
uiCtxt = {
|
|
||||||
sepNavIntBoundsRect = "{{0, 0}, {1011, 6812}}";
|
|
||||||
sepNavSelRange = "{63, 0}";
|
|
||||||
sepNavVisRange = "{835, 1307}";
|
|
||||||
sepNavWindowFrame = "{{61, 173}, {750, 558}}";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
8DD76F620486A84900D96B5E /* automata7 */ = {
|
|
||||||
activeExec = 0;
|
|
||||||
executables = (
|
|
||||||
D40BDF8D13403FC300B0BE1F /* automata7 */,
|
|
||||||
);
|
|
||||||
};
|
|
||||||
D40BDF8D13403FC300B0BE1F /* automata7 */ = {
|
|
||||||
isa = PBXExecutable;
|
|
||||||
activeArgIndices = (
|
|
||||||
);
|
|
||||||
argumentStrings = (
|
|
||||||
);
|
|
||||||
autoAttachOnCrash = 1;
|
|
||||||
breakpointsEnabled = 0;
|
|
||||||
configStateDict = {
|
|
||||||
};
|
|
||||||
customDataFormattersEnabled = 1;
|
|
||||||
dataTipCustomDataFormattersEnabled = 1;
|
|
||||||
dataTipShowTypeColumn = 1;
|
|
||||||
dataTipSortType = 0;
|
|
||||||
debuggerPlugin = GDBDebugging;
|
|
||||||
disassemblyDisplayState = 0;
|
|
||||||
dylibVariantSuffix = "";
|
|
||||||
enableDebugStr = 1;
|
|
||||||
environmentEntries = (
|
|
||||||
);
|
|
||||||
executableSystemSymbolLevel = 0;
|
|
||||||
executableUserSymbolLevel = 0;
|
|
||||||
libgmallocEnabled = 0;
|
|
||||||
name = automata7;
|
|
||||||
savedGlobals = {
|
|
||||||
};
|
|
||||||
showTypeColumn = 0;
|
|
||||||
sourceDirectories = (
|
|
||||||
);
|
|
||||||
};
|
|
||||||
D40BDF9813403FC900B0BE1F /* Source Control */ = {
|
|
||||||
isa = PBXSourceControlManager;
|
|
||||||
fallbackIsa = XCSourceControlManager;
|
|
||||||
isSCMEnabled = 0;
|
|
||||||
scmConfiguration = {
|
|
||||||
repositoryNamesForRoots = {
|
|
||||||
"" = "";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
D40BDF9913403FC900B0BE1F /* Code sense */ = {
|
|
||||||
isa = PBXCodeSenseManager;
|
|
||||||
indexTemplatePath = "";
|
|
||||||
};
|
|
||||||
D48F923814C54A47007626C8 /* PBXTextBookmark */ = {
|
|
||||||
isa = PBXTextBookmark;
|
|
||||||
fRef = 08FB7796FE84155DC02AAC07 /* main.cpp */;
|
|
||||||
name = "main.cpp: 3";
|
|
||||||
rLen = 0;
|
|
||||||
rLoc = 63;
|
|
||||||
rType = 0;
|
|
||||||
vrLen = 1296;
|
|
||||||
vrLoc = 845;
|
|
||||||
};
|
|
||||||
D48F925214C54B80007626C8 /* PBXTextBookmark */ = {
|
|
||||||
isa = PBXTextBookmark;
|
|
||||||
fRef = 08FB7796FE84155DC02AAC07 /* main.cpp */;
|
|
||||||
name = "main.cpp: 3";
|
|
||||||
rLen = 0;
|
|
||||||
rLoc = 63;
|
|
||||||
rType = 0;
|
|
||||||
vrLen = 1307;
|
|
||||||
vrLoc = 835;
|
|
||||||
};
|
|
||||||
D4C40DC71492DE0C0098EA8B /* PBXTextBookmark */ = {
|
|
||||||
isa = PBXTextBookmark;
|
|
||||||
fRef = 08FB7796FE84155DC02AAC07 /* main.cpp */;
|
|
||||||
name = "main.cpp: 3";
|
|
||||||
rLen = 0;
|
|
||||||
rLoc = 63;
|
|
||||||
rType = 0;
|
|
||||||
vrLen = 1047;
|
|
||||||
vrLoc = 0;
|
|
||||||
};
|
|
||||||
D4DCA72D144F9BEB00D336A4 /* PBXTextBookmark */ = {
|
|
||||||
isa = PBXTextBookmark;
|
|
||||||
fRef = 08FB7796FE84155DC02AAC07 /* main.cpp */;
|
|
||||||
name = "main.cpp: 454";
|
|
||||||
rLen = 9;
|
|
||||||
rLoc = 12353;
|
|
||||||
rType = 0;
|
|
||||||
vrLen = 1746;
|
|
||||||
vrLoc = 1573;
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Workspace
|
|
||||||
version = "1.0">
|
|
||||||
<FileRef
|
|
||||||
location = "self:interface.xcodeproj">
|
|
||||||
</FileRef>
|
|
||||||
</Workspace>
|
|
|
@ -1,47 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Bucket
|
|
||||||
type = "1"
|
|
||||||
version = "1.0">
|
|
||||||
<FileBreakpoints>
|
|
||||||
<FileBreakpoint
|
|
||||||
shouldBeEnabled = "No"
|
|
||||||
ignoreCount = "0"
|
|
||||||
continueAfterRunningActions = "No"
|
|
||||||
isPathRelative = "1"
|
|
||||||
filePath = "main.cpp"
|
|
||||||
timestampString = "368315146.447438"
|
|
||||||
startingColumnNumber = "9223372036854775807"
|
|
||||||
endingColumnNumber = "9223372036854775807"
|
|
||||||
startingLineNumber = "41"
|
|
||||||
endingLineNumber = "41">
|
|
||||||
</FileBreakpoint>
|
|
||||||
<FileBreakpoint
|
|
||||||
shouldBeEnabled = "No"
|
|
||||||
ignoreCount = "0"
|
|
||||||
continueAfterRunningActions = "No"
|
|
||||||
isPathRelative = "1"
|
|
||||||
filePath = "main.cpp"
|
|
||||||
timestampString = "368480470.721832"
|
|
||||||
startingColumnNumber = "9223372036854775807"
|
|
||||||
endingColumnNumber = "9223372036854775807"
|
|
||||||
startingLineNumber = "904"
|
|
||||||
endingLineNumber = "904"
|
|
||||||
landmarkName = "main(int argc, char** argv)"
|
|
||||||
landmarkType = "7">
|
|
||||||
</FileBreakpoint>
|
|
||||||
<FileBreakpoint
|
|
||||||
shouldBeEnabled = "No"
|
|
||||||
ignoreCount = "0"
|
|
||||||
continueAfterRunningActions = "No"
|
|
||||||
isPathRelative = "1"
|
|
||||||
filePath = "particle.cpp"
|
|
||||||
timestampString = "368498289.590653"
|
|
||||||
startingColumnNumber = "9223372036854775807"
|
|
||||||
endingColumnNumber = "9223372036854775807"
|
|
||||||
startingLineNumber = "26"
|
|
||||||
endingLineNumber = "26"
|
|
||||||
landmarkName = "ParticleSystem::simulate (float deltaTime)"
|
|
||||||
landmarkType = "5">
|
|
||||||
</FileBreakpoint>
|
|
||||||
</FileBreakpoints>
|
|
||||||
</Bucket>
|
|
|
@ -1,84 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Scheme
|
|
||||||
version = "1.3">
|
|
||||||
<BuildAction
|
|
||||||
parallelizeBuildables = "YES"
|
|
||||||
buildImplicitDependencies = "YES">
|
|
||||||
<BuildActionEntries>
|
|
||||||
<BuildActionEntry
|
|
||||||
buildForTesting = "YES"
|
|
||||||
buildForRunning = "YES"
|
|
||||||
buildForProfiling = "YES"
|
|
||||||
buildForArchiving = "YES"
|
|
||||||
buildForAnalyzing = "YES">
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "8DD76F620486A84900D96B5E"
|
|
||||||
BuildableName = "interface"
|
|
||||||
BlueprintName = "interface"
|
|
||||||
ReferencedContainer = "container:interface.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</BuildActionEntry>
|
|
||||||
</BuildActionEntries>
|
|
||||||
</BuildAction>
|
|
||||||
<TestAction
|
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
|
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
|
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
||||||
buildConfiguration = "Debug">
|
|
||||||
<Testables>
|
|
||||||
</Testables>
|
|
||||||
<MacroExpansion>
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "8DD76F620486A84900D96B5E"
|
|
||||||
BuildableName = "interface"
|
|
||||||
BlueprintName = "interface"
|
|
||||||
ReferencedContainer = "container:interface.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</MacroExpansion>
|
|
||||||
</TestAction>
|
|
||||||
<LaunchAction
|
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
|
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
|
|
||||||
launchStyle = "0"
|
|
||||||
useCustomWorkingDirectory = "NO"
|
|
||||||
buildConfiguration = "Debug"
|
|
||||||
debugDocumentVersioning = "YES"
|
|
||||||
allowLocationSimulation = "YES">
|
|
||||||
<BuildableProductRunnable>
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "8DD76F620486A84900D96B5E"
|
|
||||||
BuildableName = "interface"
|
|
||||||
BlueprintName = "interface"
|
|
||||||
ReferencedContainer = "container:interface.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</BuildableProductRunnable>
|
|
||||||
<AdditionalOptions>
|
|
||||||
</AdditionalOptions>
|
|
||||||
</LaunchAction>
|
|
||||||
<ProfileAction
|
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
||||||
savedToolIdentifier = ""
|
|
||||||
useCustomWorkingDirectory = "NO"
|
|
||||||
buildConfiguration = "Release"
|
|
||||||
debugDocumentVersioning = "YES">
|
|
||||||
<BuildableProductRunnable>
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "8DD76F620486A84900D96B5E"
|
|
||||||
BuildableName = "interface"
|
|
||||||
BlueprintName = "interface"
|
|
||||||
ReferencedContainer = "container:interface.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</BuildableProductRunnable>
|
|
||||||
</ProfileAction>
|
|
||||||
<AnalyzeAction
|
|
||||||
buildConfiguration = "Debug">
|
|
||||||
</AnalyzeAction>
|
|
||||||
<ArchiveAction
|
|
||||||
buildConfiguration = "Release"
|
|
||||||
revealArchiveInOrganizer = "YES">
|
|
||||||
</ArchiveAction>
|
|
||||||
</Scheme>
|
|
|
@ -1,22 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<key>SchemeUserState</key>
|
|
||||||
<dict>
|
|
||||||
<key>interface.xcscheme</key>
|
|
||||||
<dict>
|
|
||||||
<key>orderHint</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<key>SuppressBuildableAutocreation</key>
|
|
||||||
<dict>
|
|
||||||
<key>8DD76F620486A84900D96B5E</key>
|
|
||||||
<dict>
|
|
||||||
<key>primary</key>
|
|
||||||
<true/>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
|
@ -1,20 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Bucket
|
|
||||||
type = "1"
|
|
||||||
version = "1.0">
|
|
||||||
<FileBreakpoints>
|
|
||||||
<FileBreakpoint
|
|
||||||
shouldBeEnabled = "No"
|
|
||||||
ignoreCount = "0"
|
|
||||||
continueAfterRunningActions = "No"
|
|
||||||
filePath = "field.cpp"
|
|
||||||
timestampString = "375986878.0086"
|
|
||||||
startingColumnNumber = "9223372036854775807"
|
|
||||||
endingColumnNumber = "9223372036854775807"
|
|
||||||
startingLineNumber = "122"
|
|
||||||
endingLineNumber = "122"
|
|
||||||
landmarkName = "field_avg_neighbors(int index, glm::vec3 * result)"
|
|
||||||
landmarkType = "7">
|
|
||||||
</FileBreakpoint>
|
|
||||||
</FileBreakpoints>
|
|
||||||
</Bucket>
|
|
|
@ -1,86 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Scheme
|
|
||||||
LastUpgradeVersion = "0450"
|
|
||||||
version = "1.3">
|
|
||||||
<BuildAction
|
|
||||||
parallelizeBuildables = "YES"
|
|
||||||
buildImplicitDependencies = "YES">
|
|
||||||
<BuildActionEntries>
|
|
||||||
<BuildActionEntry
|
|
||||||
buildForTesting = "YES"
|
|
||||||
buildForRunning = "YES"
|
|
||||||
buildForProfiling = "YES"
|
|
||||||
buildForArchiving = "YES"
|
|
||||||
buildForAnalyzing = "YES">
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "8DD76F620486A84900D96B5E"
|
|
||||||
BuildableName = "interface"
|
|
||||||
BlueprintName = "interface"
|
|
||||||
ReferencedContainer = "container:interface.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</BuildActionEntry>
|
|
||||||
</BuildActionEntries>
|
|
||||||
</BuildAction>
|
|
||||||
<TestAction
|
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
||||||
buildConfiguration = "Debug">
|
|
||||||
<Testables>
|
|
||||||
</Testables>
|
|
||||||
<MacroExpansion>
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "8DD76F620486A84900D96B5E"
|
|
||||||
BuildableName = "interface"
|
|
||||||
BlueprintName = "interface"
|
|
||||||
ReferencedContainer = "container:interface.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</MacroExpansion>
|
|
||||||
</TestAction>
|
|
||||||
<LaunchAction
|
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
||||||
launchStyle = "0"
|
|
||||||
useCustomWorkingDirectory = "NO"
|
|
||||||
buildConfiguration = "Release"
|
|
||||||
ignoresPersistentStateOnLaunch = "NO"
|
|
||||||
debugDocumentVersioning = "YES"
|
|
||||||
allowLocationSimulation = "YES">
|
|
||||||
<BuildableProductRunnable>
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "8DD76F620486A84900D96B5E"
|
|
||||||
BuildableName = "interface"
|
|
||||||
BlueprintName = "interface"
|
|
||||||
ReferencedContainer = "container:interface.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</BuildableProductRunnable>
|
|
||||||
<AdditionalOptions>
|
|
||||||
</AdditionalOptions>
|
|
||||||
</LaunchAction>
|
|
||||||
<ProfileAction
|
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
||||||
savedToolIdentifier = ""
|
|
||||||
useCustomWorkingDirectory = "NO"
|
|
||||||
buildConfiguration = "Release"
|
|
||||||
debugDocumentVersioning = "YES">
|
|
||||||
<BuildableProductRunnable>
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "8DD76F620486A84900D96B5E"
|
|
||||||
BuildableName = "interface"
|
|
||||||
BlueprintName = "interface"
|
|
||||||
ReferencedContainer = "container:interface.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</BuildableProductRunnable>
|
|
||||||
</ProfileAction>
|
|
||||||
<AnalyzeAction
|
|
||||||
buildConfiguration = "Debug">
|
|
||||||
</AnalyzeAction>
|
|
||||||
<ArchiveAction
|
|
||||||
buildConfiguration = "Release"
|
|
||||||
revealArchiveInOrganizer = "YES">
|
|
||||||
</ArchiveAction>
|
|
||||||
</Scheme>
|
|
|
@ -1,22 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<key>SchemeUserState</key>
|
|
||||||
<dict>
|
|
||||||
<key>automata7.xcscheme</key>
|
|
||||||
<dict>
|
|
||||||
<key>orderHint</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<key>SuppressBuildableAutocreation</key>
|
|
||||||
<dict>
|
|
||||||
<key>8DD76F620486A84900D96B5E</key>
|
|
||||||
<dict>
|
|
||||||
<key>primary</key>
|
|
||||||
<true/>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
31
interface/CMakeLists.txt
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
|
project(interface)
|
||||||
|
|
||||||
|
file(GLOB INTERFACE_SRCS src/*.cpp src/*.h)
|
||||||
|
|
||||||
|
add_executable(interface ${INTERFACE_SRCS})
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "-framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework CoreServices -framework Carbon")
|
||||||
|
endif (APPLE)
|
||||||
|
|
||||||
|
find_package(OpenGL REQUIRED)
|
||||||
|
find_package(GLUT REQUIRED)
|
||||||
|
find_package(GLM REQUIRED)
|
||||||
|
find_package(Portaudio REQUIRED)
|
||||||
|
find_package(LodePNG REQUIRED)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${OPENGL_INCLUDE_DIRS}
|
||||||
|
${GLUT_INCLUDE_DIRS}
|
||||||
|
${GLM_INCLUDE_DIRS}
|
||||||
|
${PORTAUDIO_INCLUDE_DIRS}
|
||||||
|
${LODEPNG_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
target_link_libraries(interface
|
||||||
|
${OPENGL_LIBRARY}
|
||||||
|
${GLUT_LIBRARY}
|
||||||
|
${PORTAUDIO_LIBRARY}
|
||||||
|
${LODEPNG_LIBRARY}
|
||||||
|
)
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 8.4 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
@ -9,7 +9,7 @@
|
||||||
#ifndef __interface__Agent__
|
#ifndef __interface__Agent__
|
||||||
#define __interface__Agent__
|
#define __interface__Agent__
|
||||||
|
|
||||||
#include "glm.hpp"
|
#include <glm/glm.hpp>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
|
@ -10,7 +10,7 @@
|
||||||
#define __interface__Audio__
|
#define __interface__Audio__
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "portaudio.h"
|
#include <Portaudio/portaudio.h>
|
||||||
#include "Head.h"
|
#include "Head.h"
|
||||||
#include "AudioData.h"
|
#include "AudioData.h"
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#define __interface__AudioSource__
|
#define __interface__AudioSource__
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "glm.hpp"
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
class AudioSource {
|
class AudioSource {
|
||||||
public:
|
public:
|
|
@ -9,7 +9,7 @@
|
||||||
#ifndef __interface__Cube__
|
#ifndef __interface__Cube__
|
||||||
#define __interface__Cube__
|
#define __interface__Cube__
|
||||||
|
|
||||||
#include "glm.hpp"
|
#include <glm/glm.hpp>
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
#include <GLUT/glut.h>
|
#include <GLUT/glut.h>
|
|
@ -7,7 +7,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "Field.h"
|
#include "Field.h"
|
||||||
#include "glm.hpp"
|
#include <glm/glm.hpp>
|
||||||
#define FIELD_SCALE 0.00050
|
#define FIELD_SCALE 0.00050
|
||||||
#define COLOR_DRIFT_RATE 0.001f // per-frame drift of particle color towards field element color
|
#define COLOR_DRIFT_RATE 0.001f // per-frame drift of particle color towards field element color
|
||||||
#define COLOR_MIN 0.2f // minimum R/G/B value at 0,0,0 - also needs setting in cloud.cpp
|
#define COLOR_MIN 0.2f // minimum R/G/B value at 0,0,0 - also needs setting in cloud.cpp
|
|
@ -17,7 +17,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "glm.hpp"
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
// Field is a lattice of vectors uniformly distributed FIELD_ELEMENTS^(1/3) on side
|
// Field is a lattice of vectors uniformly distributed FIELD_ELEMENTS^(1/3) on side
|
||||||
const int FIELD_ELEMENTS = 1000;
|
const int FIELD_ELEMENTS = 1000;
|
|
@ -9,7 +9,7 @@
|
||||||
#ifndef __interface__Finger__
|
#ifndef __interface__Finger__
|
||||||
#define __interface__Finger__
|
#define __interface__Finger__
|
||||||
|
|
||||||
#include "glm.hpp"
|
#include <glm/glm.hpp>
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
#include <GLUT/glut.h>
|
#include <GLUT/glut.h>
|
|
@ -9,7 +9,7 @@
|
||||||
#ifndef __interface__Hand__
|
#ifndef __interface__Hand__
|
||||||
#define __interface__Hand__
|
#define __interface__Hand__
|
||||||
|
|
||||||
#include "glm.hpp"
|
#include <glm/glm.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "Field.h"
|
#include "Field.h"
|
|
@ -9,7 +9,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "Head.h"
|
#include "Head.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "vector_angle.hpp"
|
#include <glm/glm.hpp>
|
||||||
#include "SerialInterface.h"
|
#include "SerialInterface.h"
|
||||||
|
|
||||||
float skinColor[] = {1.0, 0.84, 0.66};
|
float skinColor[] = {1.0, 0.84, 0.66};
|
|
@ -9,7 +9,7 @@
|
||||||
#ifndef __interface__Lattice__
|
#ifndef __interface__Lattice__
|
||||||
#define __interface__Lattice__
|
#define __interface__Lattice__
|
||||||
|
|
||||||
#include "glm.hpp"
|
#include <glm/glm.hpp>
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
#include <GLUT/glut.h>
|
#include <GLUT/glut.h>
|
|
@ -9,7 +9,7 @@
|
||||||
#ifndef __interface__Oscilloscope__
|
#ifndef __interface__Oscilloscope__
|
||||||
#define __interface__Oscilloscope__
|
#define __interface__Oscilloscope__
|
||||||
|
|
||||||
#include "glm.hpp"
|
#include <glm/glm.hpp>
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include <GLUT/glut.h>
|
#include <GLUT/glut.h>
|
|
@ -9,7 +9,7 @@
|
||||||
#ifndef __interface__Particle__
|
#ifndef __interface__Particle__
|
||||||
#define __interface__Particle__
|
#define __interface__Particle__
|
||||||
|
|
||||||
#include "glm.hpp"
|
#include <glm/glm.hpp>
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
#include <GLUT/glut.h>
|
#include <GLUT/glut.h>
|
|
@ -6,7 +6,7 @@
|
||||||
#ifndef __interface__SerialInterface__
|
#ifndef __interface__SerialInterface__
|
||||||
#define __interface__SerialInterface__
|
#define __interface__SerialInterface__
|
||||||
|
|
||||||
#include "glm.hpp"
|
#include <glm/glm.hpp>
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
#include <GLUT/glut.h>
|
#include <GLUT/glut.h>
|
|
@ -13,7 +13,7 @@
|
||||||
#else
|
#else
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#endif
|
#endif
|
||||||
#include "lodepng.h"
|
#include <LodePNG/lodepng.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
#include "glm.hpp"
|
#include <glm/glm.hpp>
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#ifndef __interface__Util__
|
#ifndef __interface__Util__
|
||||||
#define __interface__Util__
|
#define __interface__Util__
|
||||||
|
|
||||||
#include "glm.hpp"
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
float azimuth_to(glm::vec3 head_pos, glm::vec3 source_pos);
|
float azimuth_to(glm::vec3 head_pos, glm::vec3 source_pos);
|
||||||
float angle_to(glm::vec3 head_pos, glm::vec3 source_pos, float render_yaw, float head_yaw);
|
float angle_to(glm::vec3 head_pos, glm::vec3 source_pos, float render_yaw, float head_yaw);
|
|
@ -36,8 +36,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include "glm.hpp"
|
#include <glm/glm.hpp>
|
||||||
#include "portaudio.h"
|
|
||||||
|
|
||||||
// Bring in OpenCV
|
// Bring in OpenCV
|
||||||
|
|
4
mixer/.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
socket
|
||||||
|
sftp-config.json
|
||||||
|
.DS_Store
|
||||||
|
*.raw
|
7
mixer/CMakeLists.txt
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
|
project(mixer)
|
||||||
|
|
||||||
|
file(GLOB MIXER_SRCS src/*.cpp src/*.h)
|
||||||
|
|
||||||
|
add_executable(mixer ${MIXER_SRCS})
|
292
mixer/src/socket.cpp
Normal file
|
@ -0,0 +1,292 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <math.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fstream>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
const int MAX_AGENTS = 1000;
|
||||||
|
const int LOGOFF_CHECK_INTERVAL = 1000;
|
||||||
|
|
||||||
|
const int UDP_PORT = 55443;
|
||||||
|
|
||||||
|
const int BUFFER_LENGTH_BYTES = 1024;
|
||||||
|
const int BUFFER_LENGTH_SAMPLES = BUFFER_LENGTH_BYTES / sizeof(int16_t);
|
||||||
|
const float SAMPLE_RATE = 22050.0;
|
||||||
|
const float BUFFER_SEND_INTERVAL_USECS = (BUFFER_LENGTH_SAMPLES/SAMPLE_RATE) * 1000000;
|
||||||
|
|
||||||
|
const int MAX_SAMPLE_VALUE = std::numeric_limits<int16_t>::max();
|
||||||
|
const int MIN_SAMPLE_VALUE = std::numeric_limits<int16_t>::min();
|
||||||
|
|
||||||
|
const int MAX_SOURCE_BUFFERS = 10;
|
||||||
|
|
||||||
|
int16_t* whiteNoiseBuffer;
|
||||||
|
int whiteNoiseLength;
|
||||||
|
|
||||||
|
#define ECHO_DEBUG_MODE 0
|
||||||
|
|
||||||
|
sockaddr_in address, dest_address;
|
||||||
|
socklen_t destLength = sizeof(dest_address);
|
||||||
|
|
||||||
|
struct AgentList {
|
||||||
|
sockaddr_in agent_addr;
|
||||||
|
bool active;
|
||||||
|
timeval time;
|
||||||
|
} agents[MAX_AGENTS];
|
||||||
|
|
||||||
|
int num_agents = 0;
|
||||||
|
|
||||||
|
struct SourceBuffer {
|
||||||
|
int16_t sourceAudioData[BUFFER_LENGTH_SAMPLES];
|
||||||
|
bool transmitted;
|
||||||
|
} sourceBuffers[MAX_SOURCE_BUFFERS];
|
||||||
|
|
||||||
|
double diffclock(timeval *clock1, timeval *clock2)
|
||||||
|
{
|
||||||
|
double diffms = (clock2->tv_sec - clock1->tv_sec) * 1000.0;
|
||||||
|
diffms += (clock2->tv_usec - clock1->tv_usec) / 1000.0; // us to ms
|
||||||
|
return diffms;
|
||||||
|
}
|
||||||
|
|
||||||
|
double usecTimestamp(timeval *time, double addedUsecs = 0) {
|
||||||
|
return (time->tv_sec * 1000000.0) + time->tv_usec + addedUsecs;
|
||||||
|
}
|
||||||
|
|
||||||
|
int create_socket()
|
||||||
|
{
|
||||||
|
// Create socket
|
||||||
|
int handle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||||
|
|
||||||
|
if (handle <= 0) {
|
||||||
|
printf("Failed to create socket: %d\n", handle);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
int network_init()
|
||||||
|
{
|
||||||
|
int handle = create_socket();
|
||||||
|
|
||||||
|
// Bind socket to port
|
||||||
|
address.sin_family = AF_INET;
|
||||||
|
address.sin_addr.s_addr = INADDR_ANY;
|
||||||
|
address.sin_port = htons( (unsigned short) UDP_PORT );
|
||||||
|
|
||||||
|
if (bind(handle, (const sockaddr*) &address, sizeof(sockaddr_in)) < 0) {
|
||||||
|
printf( "failed to bind socket\n" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
int addAgent(sockaddr_in dest_address, void *audioData) {
|
||||||
|
// Search for agent in list and add if needed
|
||||||
|
int is_new = 0;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < num_agents; i++) {
|
||||||
|
if (dest_address.sin_addr.s_addr == agents[i].agent_addr.sin_addr.s_addr
|
||||||
|
&& dest_address.sin_port == agents[i].agent_addr.sin_port) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((i == num_agents) || (agents[i].active == false)) {
|
||||||
|
is_new = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
agents[i].agent_addr = dest_address;
|
||||||
|
agents[i].active = true;
|
||||||
|
gettimeofday(&agents[i].time, NULL);
|
||||||
|
|
||||||
|
memcpy(sourceBuffers[i].sourceAudioData, audioData, BUFFER_LENGTH_BYTES);
|
||||||
|
sourceBuffers[i].transmitted = false;
|
||||||
|
|
||||||
|
if (i == num_agents) {
|
||||||
|
num_agents++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return is_new;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct send_buffer_struct {
|
||||||
|
int socket_handle;
|
||||||
|
};
|
||||||
|
|
||||||
|
void *send_buffer_thread(void *args)
|
||||||
|
{
|
||||||
|
struct send_buffer_struct *buffer_args = (struct send_buffer_struct *) args;
|
||||||
|
int handle = buffer_args->socket_handle;
|
||||||
|
|
||||||
|
int sentBytes;
|
||||||
|
int currentFrame = 1;
|
||||||
|
timeval startTime, sendTime, now;
|
||||||
|
|
||||||
|
int16_t *clientMix = new int16_t[BUFFER_LENGTH_SAMPLES];
|
||||||
|
int16_t *masterMix = new int16_t[BUFFER_LENGTH_SAMPLES];
|
||||||
|
|
||||||
|
gettimeofday(&startTime, NULL);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
sentBytes = 0;
|
||||||
|
|
||||||
|
int sampleOffset = ((currentFrame - 1) * BUFFER_LENGTH_SAMPLES) % whiteNoiseLength;
|
||||||
|
memcpy(masterMix, whiteNoiseBuffer + sampleOffset, BUFFER_LENGTH_BYTES);
|
||||||
|
|
||||||
|
gettimeofday(&sendTime, NULL);
|
||||||
|
|
||||||
|
for (int a = 0; a < num_agents; a++) {
|
||||||
|
if (diffclock(&agents[a].time, &sendTime) <= LOGOFF_CHECK_INTERVAL) {
|
||||||
|
memcpy(clientMix, masterMix, BUFFER_LENGTH_BYTES);
|
||||||
|
|
||||||
|
for (int b = 0; b < MAX_SOURCE_BUFFERS; b++) {
|
||||||
|
if (b != a && !sourceBuffers[b].transmitted) {
|
||||||
|
for (int s = 0; s < BUFFER_LENGTH_SAMPLES; s++) {
|
||||||
|
// we have source buffer data for this sample
|
||||||
|
int mixSample = clientMix[s] + sourceBuffers[b].sourceAudioData[s];
|
||||||
|
|
||||||
|
int sampleToAdd = std::max(mixSample, MIN_SAMPLE_VALUE);
|
||||||
|
sampleToAdd = std::min(sampleToAdd, MAX_SAMPLE_VALUE);
|
||||||
|
|
||||||
|
clientMix[s] = sampleToAdd;
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceBuffers[b].transmitted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sockaddr_in dest_address = agents[a].agent_addr;
|
||||||
|
|
||||||
|
sentBytes = sendto(handle, clientMix, BUFFER_LENGTH_BYTES,
|
||||||
|
0, (sockaddr *) &dest_address, sizeof(dest_address));
|
||||||
|
|
||||||
|
if (sentBytes < BUFFER_LENGTH_BYTES) {
|
||||||
|
std::cout << "Error sending mix packet! " << sentBytes << strerror(errno) << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gettimeofday(&now, NULL);
|
||||||
|
|
||||||
|
double usecToSleep = usecTimestamp(&startTime, (currentFrame * BUFFER_SEND_INTERVAL_USECS)) - usecTimestamp(&now);
|
||||||
|
|
||||||
|
if (usecToSleep > 0) {
|
||||||
|
usleep(usecToSleep);
|
||||||
|
} else {
|
||||||
|
std::cout << "NOT SLEEPING!";
|
||||||
|
}
|
||||||
|
|
||||||
|
currentFrame++;
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct process_arg_struct {
|
||||||
|
int16_t *packet_data;
|
||||||
|
sockaddr_in dest_address;
|
||||||
|
};
|
||||||
|
|
||||||
|
void *process_client_packet(void *args)
|
||||||
|
{
|
||||||
|
struct process_arg_struct *process_args = (struct process_arg_struct *) args;
|
||||||
|
|
||||||
|
sockaddr_in dest_address = process_args->dest_address;
|
||||||
|
|
||||||
|
if (addAgent(dest_address, process_args->packet_data)) {
|
||||||
|
std::cout << "Added agent: " <<
|
||||||
|
inet_ntoa(dest_address.sin_addr) << " on " <<
|
||||||
|
dest_address.sin_port << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool different_clients(sockaddr_in addr1, sockaddr_in addr2)
|
||||||
|
{
|
||||||
|
return addr1.sin_addr.s_addr != addr2.sin_addr.s_addr ||
|
||||||
|
(addr1.sin_addr.s_addr == addr2.sin_addr.s_addr &&
|
||||||
|
addr1.sin_port != addr2.sin_port);
|
||||||
|
}
|
||||||
|
|
||||||
|
void white_noise_buffer_init() {
|
||||||
|
// open a pointer to the audio file
|
||||||
|
FILE *whiteNoiseFile = fopen("opera.raw", "r");
|
||||||
|
|
||||||
|
// get length of file
|
||||||
|
std::fseek(whiteNoiseFile, 0, SEEK_END);
|
||||||
|
whiteNoiseLength = std::ftell(whiteNoiseFile) / sizeof(int16_t);
|
||||||
|
std::rewind(whiteNoiseFile);
|
||||||
|
|
||||||
|
// read that amount of samples from the file
|
||||||
|
whiteNoiseBuffer = new int16_t[whiteNoiseLength];
|
||||||
|
std::fread(whiteNoiseBuffer, sizeof(int16_t), whiteNoiseLength, whiteNoiseFile);
|
||||||
|
|
||||||
|
// close it
|
||||||
|
std::fclose(whiteNoiseFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, const char * argv[])
|
||||||
|
{
|
||||||
|
timeval now, last_agent_update;
|
||||||
|
int received_bytes = 0;
|
||||||
|
|
||||||
|
// read in the workclub white noise file as a base layer of audio
|
||||||
|
white_noise_buffer_init();
|
||||||
|
|
||||||
|
int handle = network_init();
|
||||||
|
|
||||||
|
if (!handle) {
|
||||||
|
std::cout << "Failed to create listening socket.\n";
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
std::cout << "Network Started. Waiting for packets.\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
gettimeofday(&last_agent_update, NULL);
|
||||||
|
|
||||||
|
int16_t packet_data[BUFFER_LENGTH_SAMPLES];
|
||||||
|
|
||||||
|
for (int b = 0; b < MAX_SOURCE_BUFFERS; b++) {
|
||||||
|
sourceBuffers[b].transmitted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct send_buffer_struct send_buffer_args;
|
||||||
|
send_buffer_args.socket_handle = handle;
|
||||||
|
|
||||||
|
pthread_t buffer_send_thread;
|
||||||
|
pthread_create(&buffer_send_thread, NULL, send_buffer_thread, (void *)&send_buffer_args);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
received_bytes = recvfrom(handle, (int16_t*)packet_data, BUFFER_LENGTH_BYTES,
|
||||||
|
0, (sockaddr*)&dest_address, &destLength);
|
||||||
|
if (ECHO_DEBUG_MODE) {
|
||||||
|
sendto(handle, packet_data, BUFFER_LENGTH_BYTES,
|
||||||
|
0, (sockaddr *) &dest_address, sizeof(dest_address));
|
||||||
|
} else {
|
||||||
|
struct process_arg_struct args;
|
||||||
|
args.packet_data = packet_data;
|
||||||
|
args.dest_address = dest_address;
|
||||||
|
|
||||||
|
pthread_t client_process_thread;
|
||||||
|
pthread_create(&client_process_thread, NULL, process_client_packet, (void *)&args);
|
||||||
|
pthread_join(client_process_thread, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_join(buffer_send_thread, NULL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|