From 571183fa779448fb8813c8e21fa9ceeaabab01ca Mon Sep 17 00:00:00 2001 From: Yan Wong Date: Tue, 11 Nov 2014 23:18:33 +0000 Subject: [PATCH 1/6] New makefile for OS X 10.9, remove bad readme2 --- README2 | 1 - opencv_gpb/Makefile.osx | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) delete mode 100644 README2 create mode 100644 opencv_gpb/Makefile.osx diff --git a/README2 b/README2 deleted file mode 100644 index 0cb6ed7..0000000 --- a/README2 +++ /dev/null @@ -1 +0,0 @@ -www.1238090.com \ No newline at end of file diff --git a/opencv_gpb/Makefile.osx b/opencv_gpb/Makefile.osx new file mode 100644 index 0000000..aa70bd1 --- /dev/null +++ b/opencv_gpb/Makefile.osx @@ -0,0 +1,29 @@ +#Makefile for OS X, compiles OK using g++ == clang++ on 10.9, with homebrew versions of opencv, arpack, and gcc (tested with installed gcc/gfortran 4.9.1) + +CC = g++ + +CFLAGS = `pkg-config --cflags opencv` -I./include/gPb -I./include/sPb -I./include/seg + +LIBS = `pkg-config --libs opencv` -L/usr/local/lib -larpack -L$(shell dirname `gfortran --print-file-name libgfortran.a`) -lgfortran + +SRC = src/main.cpp \ + src/gPb/globalPb.cpp \ + src/gPb/Filters.cpp \ + src/sPb/buildW.cpp \ + src/sPb/ic.cpp \ + src/sPb/affinity.cpp \ + src/sPb/smatrix.cpp \ + src/sPb/normCut.cpp \ + src/seg/watershed.cpp \ + src/seg/VisWatershed.cpp \ + src/seg/contour2ucm.cpp \ + src/seg/ucm_mean_pb.cpp \ + src/seg/uvt.cpp + +OBJ = gPb + +program: + $(CC) -o $(OBJ) $(SRC) $(CFLAGS) $(LIBS) + +clean: + rm $(OBJ) \ No newline at end of file From 45bc4ff1352d3f2e5c68775d494a04d279638faf Mon Sep 17 00:00:00 2001 From: Yan Wong Date: Tue, 11 Nov 2014 23:26:55 +0000 Subject: [PATCH 2/6] Use ISO C (1999) isfinite, and correct exit() call --- opencv_gpb/src/sPb/affinity.cpp | 2 +- opencv_gpb/src/seg/VisWatershed.cpp | 17 ++++++++++------- opencv_gpb/src/seg/watershed.cpp | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/opencv_gpb/src/sPb/affinity.cpp b/opencv_gpb/src/sPb/affinity.cpp index a6a6be1..3d564b5 100644 --- a/opencv_gpb/src/sPb/affinity.cpp +++ b/opencv_gpb/src/sPb/affinity.cpp @@ -44,7 +44,7 @@ float C_IC_SS(float ic) val += (ic / 0.3130)*-1.3113; const float post = 1.0 / (1.0 + exp(-val)); - if (!finite(post)) { + if (!isfinite(post)) { return 0; } if (post < 0) { diff --git a/opencv_gpb/src/seg/VisWatershed.cpp b/opencv_gpb/src/seg/VisWatershed.cpp index 1e8e228..e02e4dd 100644 --- a/opencv_gpb/src/seg/VisWatershed.cpp +++ b/opencv_gpb/src/seg/VisWatershed.cpp @@ -99,19 +99,19 @@ assert( 0 <= diff && diff <= 255 ); \ if( CV_MAT_TYPE(src->type) != CV_8UC3 ) { printf("Only 8-bit, 3-channel input images are supported"); - exit; + exit(EXIT_FAILURE); } //CV_ERROR( CV_StsUnsupportedFormat, "Only 8-bit, 3-channel input images are supported" ); if( CV_MAT_TYPE(dst->type) != CV_32SC1 ) { printf("Only 32-bit, 1-channel output images are supported"); - exit; + exit(EXIT_FAILURE); } //CV_ERROR( CV_StsUnsupportedFormat, "Only 32-bit, 1-channel output images are supported" ); if( !CV_ARE_SIZES_EQ( src, dst )) { printf("The input and output images must have the same size"); - exit; + exit(EXIT_FAILURE); } //CV_ERROR( CV_StsUnmatchedSizes, "The input and output images must have the same size" ); @@ -188,7 +188,7 @@ assert( 0 <= diff && diff <= 255 ); \ // if there is no markers, exit immediately if( i == NQ ) - exit; + exit(EXIT_FAILURE); active_queue = i; img = src->data.ptr; @@ -224,17 +224,20 @@ assert( 0 <= diff && diff <= 255 ); \ t = m[-1]; if( t > 0 ) lab = t; t = m[1]; - if( t > 0 ) + if( t > 0 ) { if( lab == 0 ) lab = t; else if( t != lab ) lab = WSHED; + } t = m[-mstep]; - if( t > 0 ) + if( t > 0 ) { if( lab == 0 ) lab = t; else if( t != lab ) lab = WSHED; + } t = m[mstep]; - if( t > 0 ) + if( t > 0 ) { if( lab == 0 ) lab = t; else if( t != lab ) lab = WSHED; + } assert( lab != 0 ); m[0] = lab; diff --git a/opencv_gpb/src/seg/watershed.cpp b/opencv_gpb/src/seg/watershed.cpp index b966719..b96bec1 100644 --- a/opencv_gpb/src/seg/watershed.cpp +++ b/opencv_gpb/src/seg/watershed.cpp @@ -141,8 +141,8 @@ watershedFull(const cv::Mat & image, //viscous forced watershed: //cv::viswatershed(image3, regions, 3, 0.015); - // OpenCV convention: -1 for boundaries, zone index start a 0 - // Matlab convention: 0 for boundaries, zone index start a 1 + // OpenCV convention: -1 for boundaries, zone index start at 0 + // Matlab convention: 0 for boundaries, zone index start at 1 regions = regions + 1; } } From 86dc1e8887b26f03f8e03421de0908344b81d166 Mon Sep 17 00:00:00 2001 From: Yan Wong Date: Tue, 11 Nov 2014 23:37:28 +0000 Subject: [PATCH 3/6] Add simple catch to avoid segfault if no file given --- opencv_gpb/src/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/opencv_gpb/src/main.cpp b/opencv_gpb/src/main.cpp index d845e1a..732fef8 100644 --- a/opencv_gpb/src/main.cpp +++ b/opencv_gpb/src/main.cpp @@ -51,6 +51,10 @@ void on_trackbar(int, void* ) int main(int argc, char** argv) { //info block + if (argc < 2) { + cout<<"Give the name of an image file to analyse using gPb"< Date: Wed, 12 Nov 2014 09:21:50 +0000 Subject: [PATCH 4/6] Remove libfortran dependencies as per https://github.com/HiDiYANG/gPb-GSoC/issues/3 --- opencv_gpb/Makefile | 2 +- opencv_gpb/Makefile.osx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/opencv_gpb/Makefile b/opencv_gpb/Makefile index 584244d..7b54778 100644 --- a/opencv_gpb/Makefile +++ b/opencv_gpb/Makefile @@ -1,7 +1,7 @@ CC = g++ CFLAGS = `pkg-config --cflags opencv` -I./include/gPb -I./include/sPb -I./include/seg -LIBS = `pkg-config --libs opencv` -L/opt/local/lib -larpack -lparpack -L/opt/local/lib/gcc47 -lgfortran +LIBS = `pkg-config --libs opencv` -L/opt/local/lib -larpack -lparpack SRC = src/main.cpp \ src/gPb/globalPb.cpp \ diff --git a/opencv_gpb/Makefile.osx b/opencv_gpb/Makefile.osx index aa70bd1..467c85c 100644 --- a/opencv_gpb/Makefile.osx +++ b/opencv_gpb/Makefile.osx @@ -1,10 +1,10 @@ -#Makefile for OS X, compiles OK using g++ == clang++ on 10.9, with homebrew versions of opencv, arpack, and gcc (tested with installed gcc/gfortran 4.9.1) +#Makefile for OS X, compiles and runs OK using g++ == clang++ on 10.9, with homebrew versions of opencv and arpack CC = g++ CFLAGS = `pkg-config --cflags opencv` -I./include/gPb -I./include/sPb -I./include/seg -LIBS = `pkg-config --libs opencv` -L/usr/local/lib -larpack -L$(shell dirname `gfortran --print-file-name libgfortran.a`) -lgfortran +LIBS = `pkg-config --libs opencv` -L/usr/local/lib -larpack SRC = src/main.cpp \ src/gPb/globalPb.cpp \ From 4cbf00836c6670ba9d9b46fd5ea0e7bf23cbd6ef Mon Sep 17 00:00:00 2001 From: hyanwong Date: Wed, 12 Nov 2014 11:22:19 +0000 Subject: [PATCH 5/6] Create README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..057a2df --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +gPb-GSoC +======== + +Forked from https://github.com/HiDiYANG/gPb-GSoC, code distributed under identical license conditions. + +The main point of this fork is to get the code working under openCV python, as per http://docs.opencv.org/trunk/doc/py_tutorials/py_bindings/py_bindings_basics/py_bindings_basics.html + +Python development will happen in the "Python" branch, https://github.com/hyanwong/gPb-GSoC/tree/Python From 8b0c23a5764a94d7a073d94e9c27e6cd8a6d30fe Mon Sep 17 00:00:00 2001 From: Yan Wong Date: Wed, 12 Nov 2014 11:24:53 +0000 Subject: [PATCH 6/6] Revert "Create README.md" This reverts commit 4cbf00836c6670ba9d9b46fd5ea0e7bf23cbd6ef. --- README.md | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 057a2df..0000000 --- a/README.md +++ /dev/null @@ -1,8 +0,0 @@ -gPb-GSoC -======== - -Forked from https://github.com/HiDiYANG/gPb-GSoC, code distributed under identical license conditions. - -The main point of this fork is to get the code working under openCV python, as per http://docs.opencv.org/trunk/doc/py_tutorials/py_bindings/py_bindings_basics/py_bindings_basics.html - -Python development will happen in the "Python" branch, https://github.com/hyanwong/gPb-GSoC/tree/Python