Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Experiments with OpenCV.

  • Loading branch information...
commit 1f896405eaac0b1a4ec0481a4f9477e1929aa829 1 parent 833104c
Rémy Oudompheng authored
Showing with 24 additions and 2 deletions.
  1. +2 −0  .gitignore
  2. +7 −2 configure.ac
  3. +15 −0 src/matcher/patterns.c
View
2  .gitignore
@@ -3,9 +3,11 @@
*.d
/Makefile
/bin/
+/configure
/config.h
/config.log
/config.status
+/libtool
/m4/
/minidjvu/Makefile
/minidjvu/obj/
View
9 configure.ac
@@ -102,6 +102,11 @@ jpeg_ok='no'
AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
[jpeg_libs="-ljpeg"; jpeg_ok='yes'])
+PKG_PROG_PKG_CONFIG()
+PKG_CHECK_MODULES([OPENCV], [opencv])
+CFLAGS="$CFLAGS $OPENCV_CFLAGS"
+LIBS="$LIBS $OPENCV_LIBS"
+
# Checks for header files.
if test "$tiff" != 'no'; then
@@ -204,8 +209,8 @@ AC_TYPE_SIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
-CFLAGS="$CFLAGS -Wall -Wshadow"
-CFLAGS="$CFLAGS -pedantic-errors -Wpointer-arith -Waggregate-return"
+CFLAGS="$CFLAGS -std=c99 -Wall -Wshadow"
+CFLAGS="$CFLAGS -pedantic -Wpointer-arith -Waggregate-return"
CFLAGS="$CFLAGS -Wlong-long -Wredundant-decls -Wcast-qual -Wcast-align"
DEFS="$DEFS -D__STRICT_ANSI__ -DNDEBUG"
OPTS="-Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations"
View
15 src/matcher/patterns.c
@@ -16,6 +16,7 @@
#include <assert.h>
#include <math.h>
+#include <cv.h>
#define TIMES_TO_THIN 1
#define TIMES_TO_THICKEN 1
@@ -117,6 +118,7 @@ typedef struct ComparableImageData
int32 mass_center_x, mass_center_y;
byte signature[SIGNATURE_SIZE]; /* for shiftdiff 1 and 3 tests */
byte signature2[SIGNATURE_SIZE]; /* for shiftdiff 2 test */
+ IplImage *img;
} Image;
@@ -544,6 +546,16 @@ MDJVU_IMPLEMENT mdjvu_pattern_t mdjvu_pattern_create_from_array(mdjvu_matcher_op
img->pith2_outer = NULL;
}
+ img->img = cvCreateImage(cvSize(w, h), IPL_DEPTH_8U, 1);
+
+ for (i = 0; i < h; i++)
+ {
+ int32 j;
+ uchar *row = (uchar *)(img->img->imageData + i * img->img->widthStep);
+ for (j = 0; j < w; j++)
+ row[j]=pixels[i][j];
+ }
+
return (mdjvu_pattern_t) img;
}/*}}}*/
@@ -668,6 +680,9 @@ static int compare_patterns(mdjvu_pattern_t ptr1, mdjvu_pattern_t ptr2,/*{{{*/
}
#endif
+ double diff = cvMatchShapes(i1->img, i2->img, CV_CONTOURS_MATCH_I2, 0);
+ printf("state %d, diff=%f\n", state, diff);
+
return state;
}/*}}}*/
Please sign in to comment.
Something went wrong with that request. Please try again.