From 45905d84542af369f069fcd679234a87be14406c Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Thu, 28 Jun 2012 12:35:04 -0400 Subject: [PATCH] Fix up the build process in preparation for release 1.0 --- configure.ac | 4 - examples/Makefile.am | 3 +- .../libcvautomation/libcvautomation-opencv.h | 0 .../libcvautomation/libcvautomation-xlib.h | 0 .../libcvautomation/libcvautomation-xtest.h | 0 .../opencv1/libcvautomation/libcvautomation.h | 59 ++++++++++ .../libcvautomation/libcvautomation-opencv.h | 56 ++++++++++ .../libcvautomation/libcvautomation-xlib.h | 51 +++++++++ .../libcvautomation/libcvautomation-xtest.h | 101 ++++++++++++++++++ .../libcvautomation/libcvautomation.h | 11 +- libcvautomation/Makefile.am | 12 ++- libcvautomation/libcvautomation-xtest.c | 15 ++- 12 files changed, 287 insertions(+), 25 deletions(-) rename include/{ => opencv1}/libcvautomation/libcvautomation-opencv.h (100%) rename include/{ => opencv1}/libcvautomation/libcvautomation-xlib.h (100%) rename include/{ => opencv1}/libcvautomation/libcvautomation-xtest.h (100%) create mode 100644 include/opencv1/libcvautomation/libcvautomation.h create mode 100644 include/opencv2/libcvautomation/libcvautomation-opencv.h create mode 100644 include/opencv2/libcvautomation/libcvautomation-xlib.h create mode 100644 include/opencv2/libcvautomation/libcvautomation-xtest.h rename include/{ => opencv2}/libcvautomation/libcvautomation.h (89%) diff --git a/configure.ac b/configure.ac index 50b0e8d..8d6702a 100644 --- a/configure.ac +++ b/configure.ac @@ -31,9 +31,6 @@ AC_PATH_X #Configure OpenCV - version 2+ breaks a lot of things PKG_CHECK_MODULES([OpenCV], [opencv >= 2.0.0], [use_opencv2=true], [use_opencv1=true]) AM_CONDITIONAL(USEOPENCV2, [test "$use_opencv2" != ""]) -if test "$use_opencv2" != ""; then - AC_DEFINE(USEOPENCV2) -fi if test "$use_opencv1" != ""; then echo "could not find OpenCV version 2.0.0 or higher, checking for 1.0.0 or higher..." PKG_CHECK_MODULES([OpenCV], [opencv >= 1.0.0]) @@ -47,7 +44,6 @@ AC_ARG_WITH(examples, [ --with-examples build example programs '['defau AM_CONDITIONAL(BUILD_EXAMPLES, [test "$with_examples" != "no"]) if test "$with_examples" != "no"; then #Headers needed for cva-match - echo building examples AC_CHECK_HEADERS([limits.h stdlib.h unistd.h]) fi diff --git a/examples/Makefile.am b/examples/Makefile.am index 6582e0a..bdcf239 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,9 +1,10 @@ #Need to include the -Ilibcvautomation so that libcvautomation.h can find everything that it needs -AM_CFLAGS = -Wall -O2 -I$(top_srcdir)/include #-I$(top_srcdir)/include/libcvautomation if USEOPENCV2 AM_LDFLAGS = -L../libcvautomation/.libs -lcvautomation `pkg-config --libs x11` -lopencv_imgproc -lopencv_core -lopencv_highgui -lXtst +AM_CFLAGS = -Wall -Werror -O2 -I$(top_srcdir)/include/opencv2 #-I$(top_srcdir)/include/libcvautomation else AM_LDFLAGS = -L../libcvautomation/.libs -lcvautomation `pkg-config --libs x11` `pkg-config --libs opencv` -lXtst +AM_CFLAGS = -Wall -Werror -O2 -I$(top_srcdir)/include/opencv1 #-I$(top_srcdir)/include/libcvautomation endif #Build only if we're building the examples diff --git a/include/libcvautomation/libcvautomation-opencv.h b/include/opencv1/libcvautomation/libcvautomation-opencv.h similarity index 100% rename from include/libcvautomation/libcvautomation-opencv.h rename to include/opencv1/libcvautomation/libcvautomation-opencv.h diff --git a/include/libcvautomation/libcvautomation-xlib.h b/include/opencv1/libcvautomation/libcvautomation-xlib.h similarity index 100% rename from include/libcvautomation/libcvautomation-xlib.h rename to include/opencv1/libcvautomation/libcvautomation-xlib.h diff --git a/include/libcvautomation/libcvautomation-xtest.h b/include/opencv1/libcvautomation/libcvautomation-xtest.h similarity index 100% rename from include/libcvautomation/libcvautomation-xtest.h rename to include/opencv1/libcvautomation/libcvautomation-xtest.h diff --git a/include/opencv1/libcvautomation/libcvautomation.h b/include/opencv1/libcvautomation/libcvautomation.h new file mode 100644 index 0000000..2ac0fb4 --- /dev/null +++ b/include/opencv1/libcvautomation/libcvautomation.h @@ -0,0 +1,59 @@ +/* + * ===================================================================================== + * + * Filename: libcvautomation.h + * + * Description: Include wrapper for libcvautomation subsections + * + * Version: 1.0 + * Created: 06/21/2012 12:20:43 PM + * Revision: none + * Compiler: gcc + * + * Author: Bradlee Speice (), bspeice.nc@gmail.com + * Organization: + * + * ===================================================================================== + */ +#ifndef LIBCVAUTOMATION_H +#define LIBCVAUTOMATION_H + +/* C includes */ +#include +#include + +/* OpenCV includes */ +#include +#include + +/* X11 includes */ +#include +#include +#include + +/* Define a basic structure to help us with using multiple-picture arguments + * Yes, it's a hackish implementation, nobody said you had to use this one. */ +typedef struct { + /* Use one or the other of fileName or cvaImage - cvaImage takes priority */ + IplImage *cvaImage; + char *fileName; + + CvPoint resultPoint; + int searchMethod; + int tolerance; + +} cvautomationList; + +/* Define another basic structure for points */ +typedef struct { + int x, y; +} cvaPoint; + +/* Project component includes */ +/* The includes come here to make sure all function prototypes have access + * to the cvautomationList struct */ +#include +#include +#include + +#endif /* LIBCVAUTOMATION_H */ diff --git a/include/opencv2/libcvautomation/libcvautomation-opencv.h b/include/opencv2/libcvautomation/libcvautomation-opencv.h new file mode 100644 index 0000000..ffe0d73 --- /dev/null +++ b/include/opencv2/libcvautomation/libcvautomation-opencv.h @@ -0,0 +1,56 @@ +/* + * ===================================================================================== + * + * Filename: libcvautomation-opencv.h + * + * Description: Function definitions for opencv functionality + * + * Version: 1.0 + * Created: 06/21/2012 08:34:21 AM + * Revision: none + * Compiler: gcc + * + * Author: Bradlee Speice, bspeice@uncc.edu + * Organization: MOSAIC at University of North Carolina at Charlotte + * + * ===================================================================================== + */ +#ifndef LIBCVAUTOMATION_OPENCV_H +#define LIBCVAUTOMATION_OPENCV_H + +#include + +/* It should be noted that the following are the macros for template matching: + * CV_TM_SQDIFF (default) + * CV_TM_SQDIFF_NORMED + * CV_TM_CCORR + * CV_TM_CCORR_NORMED + * CV_TM_CCOEFF + * CV_TM_CCOEFF_NORMED + */ + +/* Match a root image and sub image */ +CvPoint matchSubImage ( IplImage *rootImage, IplImage *subImage, int searchMethod, double tolerance ); + +/* Match a root image and sub image, return the center */ +CvPoint matchSubImage_center ( IplImage *rootImage, IplImage *subImage, int searchMethod, double tolerance ); + +/* Match a root image and sub image from filename */ +CvPoint matchSubImage_location ( const char *rootImage_location, const char *subImage_location, int searchMethod, double tolerance ); + +/* Match a root image and sub image from filename, return the center */ +CvPoint matchSubImage_location_center ( const char *rootImage_location, const char *subImage_location, int searchMethod, double tolerance ); + +/* Match a root image and sub images from an array of images */ +void matchSubImage_a ( IplImage *rootImage, cvautomationList *subImageArray, int listSize ); + +/* Match a root image and sub images from an array of images, return the center */ +void matchSubImage_a_center ( IplImage *rootImage, cvautomationList *subImageArray, int listSize ); + +/* Match a root image and sub images from an array of images */ +void matchSubImage_a_location ( const char *rootImageFileName, cvautomationList *subImageArray, int listSize ); + +/* Match a root image and sub images from an array of images, return the center */ +void matchSubImage_a_location_center ( const char *rootImageFileName, cvautomationList *subImageArray, int listSize ); + +#endif /* LIBCVAUTOMATION_OPENCV_H */ diff --git a/include/opencv2/libcvautomation/libcvautomation-xlib.h b/include/opencv2/libcvautomation/libcvautomation-xlib.h new file mode 100644 index 0000000..2b0b919 --- /dev/null +++ b/include/opencv2/libcvautomation/libcvautomation-xlib.h @@ -0,0 +1,51 @@ +/* + * ===================================================================================== + * + * Filename: libcvautomation-xlib.h + * + * Description: Function definitions for X11 operations + * + * Version: 1.0 + * Created: 06/21/2012 08:34:21 AM + * Revision: none + * Compiler: gcc + * + * Author: Bradlee Speice, bspeice@uncc.edu + * Organization: MOSAIC at University of North Carolina at Charlotte + * + * ===================================================================================== + */ + +#ifndef LIBCVAUTOMATION_XLIB_H +#define LIBCVAUTOMATION_XLIB_H + +#include + +/* It should be noted that the following are the macros for template matching: + * CV_TM_SQDIFF (default) + * CV_TM_SQDIFF_NORMED + * CV_TM_CCORR + * CV_TM_CCORR_NORMED + * CV_TM_CCOEFF + * CV_TM_CCOEFF_NORMED + */ + +/* Custom wrapper for XOpenDisplay function */ +Display* cvaOpenDisplay ( char *displayName ); + +/* Custom wrapper for XCloseDisplay funtion */ +void cvaCloseDisplay ( Display *displayLocation ); + +/* Match a sub image using the X11 root window as root */ +CvPoint matchSubImage_X11( Display *displayLocation, IplImage *subImage, int searchMethod, int tolerance ); + +/* Match a sub image using the X11 root window as root, return the center */ +CvPoint matchSubImage_X11_center( Display *displayLocation, IplImage *subImage, int searchMethod, int tolerance ); + +/* Match a sub image using X11 as root, from filename */ +CvPoint matchSubImage_X11_location( Display *displayLocation, const char *subImage_location, int search_method, int tolerance ); + +/* Match a sub image using X11 as root, from filename, return the center */ +CvPoint matchSubImage_X11_location_center( Display *displayLocation, const char *subImage_location, int search_method, int tolerance ); + +#endif /* LIBCVAUTOMATION_XLIB_H */ diff --git a/include/opencv2/libcvautomation/libcvautomation-xtest.h b/include/opencv2/libcvautomation/libcvautomation-xtest.h new file mode 100644 index 0000000..8cab087 --- /dev/null +++ b/include/opencv2/libcvautomation/libcvautomation-xtest.h @@ -0,0 +1,101 @@ +/* + * ===================================================================================== + * + * Filename: libcvautomation-xinput.h + * + * Description: + * + * Version: 1.0 + * Created: 06/26/2012 09:08:41 AM + * Revision: none + * Compiler: gcc + * + * Author: Bradlee Speice (), bspeice.nc@gmail.com + * Organization: + * + * ===================================================================================== + */ + +#ifndef LIBCVAUTOMATION_XTEST_H +#define LIBCVAUTOMATION_XTEST_H + +#include + +/* Make sure that the XTest extension is supported. + * If it's not, return 0 (false) */ +Bool xte_XTestSupported ( Display *displayLocation ); + +/* Get the current location of the pointer */ +cvaPoint xte_pointerLocation ( Display *displayLocation ); + +/* Click the mouse where it is currently at */ +void xte_clickMouse ( Display *displayLocation, int mouseButton ); + +/* Click the mouse on an absolute screen location */ +void xte_clickMouseXY ( Display *displayLocation, int xLocation, int yLocation, int mouseButton ); + +/* Click the mouse on a screen location relative to where it currently is */ +void xte_clickMouseRXY ( Display *displayLocation, int xIncrement, int yIncrement, int mouseButton ); + +/* Click the mouse at the top-left corner of an image on the specified display */ +cvaPoint xte_clickMouseImage ( Display *displayLocation, IplImage *subImage, int mouseButton, int searchMethod, int tolerance ); + +/* Click the mouse at the top-left corner of an image on the specified display + * where the subImage is a file location */ +cvaPoint xte_clickMouseImage_location ( Display *displayLocation, const char *fileName, int mouseButton, int searchMethod, int tolerance ); + +/* Click the mouse at the center of an image on the specified display */ +cvaPoint xte_clickMouseImage_center ( Display *displayLocation, IplImage *subImage, int mouseButton, int searchMethod, int tolerance ); + +/* Click the mouse at the center of an image on the specified display + * where the subImage is a file location */ +cvaPoint xte_clickMouseImage_location_center ( Display *displayLocation, const char *fileName, int mouseButton, int searchMethod, int tolerance ); + +/* Move the mouse to a location and leave it there */ +void xte_hoverMouseXY ( Display *displayLocation, int xLocation, int yLocation ); + +/* Move the mouse to a location relative to where it currently is and leave it there */ +void xte_hoverMouseRXY ( Display *displayLocation, int xIncrement, int yIncrement ); + +/* Move the mouse to a location at the top-left corner of an image on the specified display + * but don't click the mouse */ +cvaPoint xte_hoverMouseImage ( Display *displayLocation, IplImage *subImage, int searchMethod, int tolerance ); + +/* Move the mouse to a location at the top-left corner of an image from file on the specified display + * but don't click the mouse */ +cvaPoint xte_hoverMouseImage_location ( Display *displayLocation, const char *filename, int searchMethod, int tolerance ); + +/* Move the mouse to a location at the center of an image on the specified display + * but don't click the mouse */ +cvaPoint xte_hoverMouseImage_center ( Display *displayLocation, IplImage *subImage, int searchMethod, int tolerance ); + +/* Move the mouse to a location at the center of an image from file on the specified display + * but don't click the mouse */ +cvaPoint xte_hoverMouseImage_location_center ( Display *displayLocation, const char *fileName, int searchMethod, int tolerance ); + +/* Push a mouse button down, but don't release it */ +void xte_mouseDown ( Display *displayLocation, int mouseButton ); + +/* Let a mouse button up */ +void xte_mouseUp ( Display *displayLocation, int mouseButton ); + +/* Move the mouse a little bit */ +void xte_mouseJiggle ( Display *displayLocation ); + +/* Press and release a key + * Note that we use a string for *key, since keys like "space" are still valid. */ +void xte_clickKey ( Display *displayLocation, char *key ); + +/* Press and release keys in a string */ +void xte_clickKeyStr ( Display *displayLocation, char *string ); + +/* Press a key down */ +void xte_keyDown ( Display *displayLocation, char *key ); + +/* Release a key */ +void xte_keyUp ( Display *displayLocation, char *key ); + +/* Use one of the functions by command name */ +cvaPoint xte_commandString ( Display *displayLocation, char *command, int mouseButton, int searchMethod, int tolerance ); + +#endif /* LIBCVAUTOMATION_XTEST_H */ diff --git a/include/libcvautomation/libcvautomation.h b/include/opencv2/libcvautomation/libcvautomation.h similarity index 89% rename from include/libcvautomation/libcvautomation.h rename to include/opencv2/libcvautomation/libcvautomation.h index ce53788..9a3b14d 100644 --- a/include/libcvautomation/libcvautomation.h +++ b/include/opencv2/libcvautomation/libcvautomation.h @@ -22,19 +22,12 @@ #include #include -#ifdef USEOPENCV2 -/* OpenCV2 includes - some filenames are different */ +/* OpenCV2 includes - some filenames are different + * from the OpenCV1 counterparts */ #include #include #include -#else -/* OpenCV includes */ -#include -#include - -#endif /* #ifdef OPENCV2 */ - /* X11 includes */ #include #include diff --git a/libcvautomation/Makefile.am b/libcvautomation/Makefile.am index 3633b25..7dbb056 100644 --- a/libcvautomation/Makefile.am +++ b/libcvautomation/Makefile.am @@ -1,4 +1,8 @@ -AM_CFLAGS = -Wall -O2 -I$(top_srcdir)/include +if USEOPENCV2 +AM_CFLAGS = -Wall -Werror -O2 -I$(top_srcdir)/include/opencv2 +else +AM_CFLAGS = -Wall -Werror -O2 -I$(top_srcdir)/include/opencv1 +endif AM_LDFLAGS = AM_LIBS = -shared @@ -8,4 +12,8 @@ libcvautomation_la_SOURCES = libcvautomation-opencv.c libcvautomation-opencv.h l #libcvautomation_CFLAGS = -shared -I$(top_srcdir)/include -I$(top_srcdir)/libcvautomation -I$(top_srcdir)/include/libcvautomation #Lists the headers to distribute -pkginclude_HEADERS = $(top_srcdir)/include/libcvautomation/libcvautomation.h $(top_srcdir)/include/libcvautomation/libcvautomation-opencv.h $(top_srcdir)/include/libcvautomation/libcvautomation-xlib.h $(top_srcdir)/include/libcvautomation/libcvautomation-xtest.h +if USEOPENCV2 +pkginclude_HEADERS = $(top_srcdir)/include/opencv2/libcvautomation/libcvautomation.h $(top_srcdir)/include/opencv2/libcvautomation/libcvautomation-opencv.h $(top_srcdir)/include/opencv2/libcvautomation/libcvautomation-xlib.h $(top_srcdir)/include/opencv2/libcvautomation/libcvautomation-xtest.h +else +pkginclude_HEADERS = $(top_srcdir)/include/opencv1/libcvautomation/libcvautomation.h $(top_srcdir)/include/opencv1/libcvautomation/libcvautomation-opencv.h $(top_srcdir)/include/opencv1/libcvautomation/libcvautomation-xlib.h $(top_srcdir)/include/opencv1/libcvautomation/libcvautomation-xtest.h +endif diff --git a/libcvautomation/libcvautomation-xtest.c b/libcvautomation/libcvautomation-xtest.c index 5d228bc..a1457fe 100644 --- a/libcvautomation/libcvautomation-xtest.c +++ b/libcvautomation/libcvautomation-xtest.c @@ -582,10 +582,7 @@ void xte_keyUp ( Display *displayLocation, char *key ) cvaPoint xte_commandString ( Display *displayLocation, char *commandString, int mouseButton, int searchMethod, int tolerance ) { /* Alright, this function bears a bit of talking about. - * The way it works is that you give the **command two parameters: - * [0]: The command - * [1]: The command argument - * And what happens is that I test here for the command, and pass it off. + * What happens is that I test here for the command, and pass it off. * This functionality was inspired by xte from xautomation, * the original can be found at: http://hoopajoo.net/projects/xautomation.html * Most of the code for parsing is the same, just easier to do it that way. */ @@ -593,9 +590,13 @@ cvaPoint xte_commandString ( Display *displayLocation, char *commandString, int /* Note that most of the functions don't need mouseButton, searchMethod, or tolerance, * but they're here to make sure that they're available if needed. */ + cvaPoint resultPoint; + resultPoint.x = -1; + resultPoint.y = -1; + /* Perform basic sanity checking */ if (commandString == NULL) - return; + return resultPoint; /* And now we sanitize the input */ char *s_commandString; @@ -734,9 +735,5 @@ cvaPoint xte_commandString ( Display *displayLocation, char *commandString, int free(keyString); } - cvaPoint resultPoint; - resultPoint.x = -1; - resultPoint.y = -1; - return resultPoint; }