aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am5
-rw-r--r--src/pix_opencv_clahe.cc4
-rw-r--r--src/pix_opencv_clahe.h2
-rw-r--r--src/pix_opencv_contours.cc71
-rw-r--r--src/pix_opencv_contours.h1
5 files changed, 31 insertions, 52 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 2457e78..51666a3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,8 +2,9 @@
AUTOMAKE_OPTIONS = foreign
pkglib_LTLIBRARIES = pix_opencv.la
-pix_opencv_la_CXXFLAGS = @GEM_CPPFLAGS@ @PD_CPPFLAGS@ @FACETRACKER_CPPFLAGS@
-pix_opencv_la_LDFLAGS = -module -avoid-version -shared -shrext .@EXTENSION@ @GEM_LDFLAGS@ @PD_LDFLAGS@ @FACETRACKER_LDFLAGS@
+pix_opencv_la_CXXFLAGS = @GEM_CPPFLAGS@ @PD_CPPFLAGS@ @FACETRACKER_CPPFLAGS@ @OPENCV_CFLAGS@
+pix_opencv_la_LDFLAGS = -module -avoid-version -shared -shrext .@EXTENSION@ @GEM_LDFLAGS@ @PD_LDFLAGS@ @FACETRACKER_LDFLAGS@ @OPENCV_LDFLAGS@
+pix_opencv_la_LIBADD = @OPENCV_LIBS@
pix_opencv_la_includedir=$(includedir)/src
pix_opencv_la_include_HEADERS = Blob.hpp \
blobtrack.h \
diff --git a/src/pix_opencv_clahe.cc b/src/pix_opencv_clahe.cc
index 4de7cfc..625158f 100644
--- a/src/pix_opencv_clahe.cc
+++ b/src/pix_opencv_clahe.cc
@@ -33,7 +33,7 @@ CPPEXTERN_NEW_WITH_THREE_ARGS(pix_opencv_clahe, t_floatarg, A_DEFFLOAT, t_floata
//
/////////////////////////////////////////////////////////
pix_opencv_clahe :: pix_opencv_clahe(t_float clipLimit, int width, int height)
- : m_clipLimit(40), m_tileGridSize(Size(8,8)), m_rendering(false)
+ : m_clipLimit(40), m_tileGridSize(cv::Size(8,8)), m_rendering(false)
{
if ( clipLimit > 0. ){
m_clipLimit = clipLimit;
@@ -42,7 +42,7 @@ pix_opencv_clahe :: pix_opencv_clahe(t_float clipLimit, int width, int height)
m_tileGridSize=cv::Size(width, height);
} else if (width > 0 || height > 0) {
int max = width > height ? width : height;
- m_tileGridSize=Size ( max, max );
+ m_tileGridSize=cv::Size ( max, max );
}
}
diff --git a/src/pix_opencv_clahe.h b/src/pix_opencv_clahe.h
index 6d03a53..91d54d3 100644
--- a/src/pix_opencv_clahe.h
+++ b/src/pix_opencv_clahe.h
@@ -78,7 +78,7 @@ class GEM_EXPORT pix_opencv_clahe : public GemPixObj
bool m_gpuMode;
float m_clipLimit;
- Size m_tileGridSize;
+ cv::Size m_tileGridSize;
bool m_rendering;
};
#endif // for header file
diff --git a/src/pix_opencv_contours.cc b/src/pix_opencv_contours.cc
index bf4410d..23d470e 100644
--- a/src/pix_opencv_contours.cc
+++ b/src/pix_opencv_contours.cc
@@ -35,7 +35,6 @@ CPPEXTERN_NEW(pix_opencv_contours)
//
/////////////////////////////////////////////////////////
pix_opencv_contours :: pix_opencv_contours() : \
- m_repeat_point(1), \
m_epsilon(2), \
m_enable_contours(1), \
m_enable_hulls(1), \
@@ -301,7 +300,6 @@ void pix_opencv_contours :: obj_setupCallback(t_class *classPtr)
CPPEXTERN_MSG1(classPtr, "hierarchy_level", hierarchyMess, double);
CPPEXTERN_MSG1(classPtr, "taboutput", taboutputMess, float);
CPPEXTERN_MSG3(classPtr, "settab", tableMess, t_symbol*, t_symbol*, t_symbol*);
- CPPEXTERN_MSG1(classPtr, "repeat_point", repeat_pointMess, float);
}
void pix_opencv_contours :: outputCount(){
@@ -309,7 +307,7 @@ void pix_opencv_contours :: outputCount(){
for( size_t i = 0 ; i < m_contours.size(); i++ ){
m_totalPointsCount+=m_contours[i].size();
}
- m_totalPointsCount+=m_contours.size()*m_repeat_point*2; // add 2 points for each contour (on start and end)
+ m_totalPointsCount+=m_contours.size()*2; // add 2 points for each contour (on start and end)
t_atom count_atom[2];
SETFLOAT(count_atom, m_contours.size());
@@ -369,7 +367,7 @@ void pix_opencv_contours :: outputBlobs(imageStruct &image){
apt2+=2;
}
- SETFLOAT(apt+15, m_contours[i].size()+m_repeat_point*2); // number of points in segment
+ SETFLOAT(apt+15, m_contours[i].size()); // number of points in segment
SETFLOAT(apt+16, (float) length);
}
}
@@ -390,38 +388,25 @@ void pix_opencv_contours :: outputContours(imageStruct &image){
{
if (!m_contours[i].empty() && m_contours[i].size() > 2) {
- int size = 2+(m_repeat_point*2+m_contours[i].size())*2;
+ int size = 2+2*m_contours[i].size();
t_atom*acontours = new t_atom[size];
t_atom* apt=acontours;
- SETFLOAT(apt, static_cast<t_float>(m_repeat_point*2+m_contours[i].size()));
+ SETFLOAT(apt, static_cast<t_float>(m_contours[i].size()));
SETFLOAT(apt+1, 2.0);
apt+=2;
-
- for ( size_t j = 0 ; j < m_repeat_point ; j++){
- cv::Point pt = m_contours[i][0];
- SETFLOAT(apt, (float) pt.x/image.xsize);
- SETFLOAT(apt+1,(float) pt.y/image.ysize);
- apt+=2;
- }
-
- for ( size_t j = 1 ; j < m_contours[i].size() ; j++){
+
+ size_t j;
+ for ( j = 0 ; j < m_contours[i].size() ; j++){
cv::Point pt = m_contours[i][j];
SETFLOAT(apt,(float) pt.x/image.xsize);
SETFLOAT(apt+1,(float) pt.y/image.ysize);
apt+=2;
}
-
- for ( size_t j = 0 ; j < m_repeat_point ; j++){
- cv::Point pt = m_contours[i][0]; // repeat the first point to close the contour
- SETFLOAT(apt, (float) pt.x/image.xsize);
- SETFLOAT(apt+1,(float) pt.y/image.ysize);
- apt+=2;
- }
-
+
outlet_anything(m_dataout_middle, gensym("contour"), size, acontours);
if(acontours) {
- delete acontours;
+ delete[] acontours;
acontours=NULL;
}
}
@@ -436,7 +421,7 @@ void pix_opencv_contours :: outputContours(imageStruct &image){
return;
}
- int vecxsize(0), vecysize(0), veczsize(0);
+ int vecxsize(0), vecysize(0), veczsize(0), vecsize(0);
t_garray *ax, *ay, *az;
t_word *vecx, *vecy, *vecz;
@@ -487,11 +472,13 @@ void pix_opencv_contours :: outputContours(imageStruct &image){
}
}
+ vecsize=min(min(vecxsize,vecysize),veczsize);
+
int n=0;
for( size_t i = 0 ; i < m_contours.size(); i++ )
{
- if (n >= vecxsize || n>=vecysize || n>=veczsize)
+ if ( n >= vecsize )
{
error("array are not wide enough");
break;
@@ -501,14 +488,12 @@ void pix_opencv_contours :: outputContours(imageStruct &image){
cv::Point pt;
pt = m_contours[i][0];
//~ start with blank point
- for (j=0; j<m_repeat_point; j++){
- vecx[n].w_float = (float) pt.x/image.xsize;
- vecy[n].w_float = (float) pt.y/image.ysize;
- vecz[n].w_float = 0.;
- n++;
- }
+ vecx[n].w_float = (float) pt.x/image.xsize;
+ vecy[n].w_float = (float) pt.y/image.ysize;
+ vecz[n].w_float = 0.;
+ n++;
- for ( j = 0 ; j < m_contours[i].size() && n < vecxsize ; j++) {
+ for ( j = 0 ; j < m_contours[i].size() ; j++) {
pt = m_contours[i][j];
@@ -517,16 +502,15 @@ void pix_opencv_contours :: outputContours(imageStruct &image){
vecz[n].w_float = 1.;
n++;
}
+
// close contour
- pt = m_contours[i][0];
- for (j=0; j<m_repeat_point && n < vecxsize; j++){ // TODO what is this loop ??? m_repeat_point is either 0 or 1...
- vecx[n].w_float = (float) pt.x/image.xsize;
- vecy[n].w_float = (float) pt.y/image.ysize;
- vecz[n].w_float = 0.;
- n++;
+ if ( n < vecsize ){
+ pt = m_contours[i][0];
+ vecx[n].w_float = (float) pt.x/image.xsize;
+ vecy[n].w_float = (float) pt.y/image.ysize;
+ vecz[n].w_float = 1.;
+ n++;
}
-
-
}
//~ comment the redraw fnt if not needed
garray_redraw(ax);
@@ -575,11 +559,6 @@ void pix_opencv_contours :: taboutputMess(float arg)
m_taboutput = arg > 0;
}
-void pix_opencv_contours :: repeat_pointMess(float arg)
-{
- m_repeat_point = arg > 1 ? arg : 1;
-}
-
void pix_opencv_contours :: tableMess(t_symbol*xarray, t_symbol*yarray, t_symbol*zarray)
{
// check if arrays exist
diff --git a/src/pix_opencv_contours.h b/src/pix_opencv_contours.h
index 01810e3..fd30e6b 100644
--- a/src/pix_opencv_contours.h
+++ b/src/pix_opencv_contours.h
@@ -76,7 +76,6 @@ private:
std::vector<std::vector<int> > m_convexhulls;
std::vector<int> m_area;
- unsigned int m_repeat_point;
double m_epsilon;