mirror of
				https://github.com/bspeice/libcvautomation
				synced 2025-11-04 02:10:35 -05:00 
			
		
		
		
	Formalize the build process and integrate autotools
This commit is contained in:
		
							
								
								
									
										11
									
								
								libcvautomation/Makefile.am
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								libcvautomation/Makefile.am
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
			
		||||
AM_CFLAGS = -Wall -O2 -I$(top_srcdir)/include
 | 
			
		||||
AM_LDFLAGS =
 | 
			
		||||
AM_LIBS = -shared
 | 
			
		||||
 | 
			
		||||
#Lists the libraries to build
 | 
			
		||||
lib_LTLIBRARIES = libcvautomation.la
 | 
			
		||||
libcvautomation_la_SOURCES = libcvautomation-opencv.c libcvautomation-opencv.h libcvautomation-x11.c libcvautomation-x11.h libcvautomation.h
 | 
			
		||||
#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-x11.h
 | 
			
		||||
							
								
								
									
										0
									
								
								libcvautomation/configure.ac
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								libcvautomation/configure.ac
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										206
									
								
								libcvautomation/libcvautomation-opencv.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										206
									
								
								libcvautomation/libcvautomation-opencv.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,206 @@
 | 
			
		||||
/*
 | 
			
		||||
 * =====================================================================================
 | 
			
		||||
 *
 | 
			
		||||
 *       Filename:  libcvautomation-opencv.c
 | 
			
		||||
 *
 | 
			
		||||
 *    Description:  
 | 
			
		||||
 *
 | 
			
		||||
 *        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
 | 
			
		||||
 *
 | 
			
		||||
 * =====================================================================================
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <libcvautomation/libcvautomation-opencv.h>
 | 
			
		||||
 | 
			
		||||
/* 
 | 
			
		||||
 * ===  FUNCTION  ======================================================================
 | 
			
		||||
 *         Name:  matchSubImage
 | 
			
		||||
 *      Returns:  CvPoint if a match is found, null if not
 | 
			
		||||
 * =====================================================================================
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
CvPoint matchSubImage ( IplImage *rootImage, IplImage *subImage, int searchMethod, double tolerance )
 | 
			
		||||
{
 | 
			
		||||
	/* We have the two OpenCV images we want, go ahead and find if there are any matches */
 | 
			
		||||
	IplImage	*result;
 | 
			
		||||
	CvPoint		minloc, maxloc; /* Location for the match - depending on search algorithm,
 | 
			
		||||
									the result may be in either minloc or maxloc */
 | 
			
		||||
	CvPoint		badpoint; /* (-1, -1), used to indicate an error */
 | 
			
		||||
	double		minval, maxval;
 | 
			
		||||
	int			rootImage_width, rootImage_height;
 | 
			
		||||
	int			subImage_width, subImage_height;
 | 
			
		||||
	int			result_width, result_height;
 | 
			
		||||
 | 
			
		||||
	badpoint.x = badpoint.y = -1;
 | 
			
		||||
 | 
			
		||||
	/* Make sure we have valid images */
 | 
			
		||||
	if ( rootImage == 0 || subImage == 0) {
 | 
			
		||||
		/* Otherwise return invalid */
 | 
			
		||||
		minloc.x = minloc.y = -1;
 | 
			
		||||
		return minloc;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Set up the parameters for our result image */
 | 
			
		||||
	rootImage_width		= rootImage->width;
 | 
			
		||||
	rootImage_height	= rootImage->height;
 | 
			
		||||
	subImage_width	= subImage->width;
 | 
			
		||||
	subImage_height	= subImage->height;
 | 
			
		||||
	result_width	= rootImage_width - subImage_width + 1;
 | 
			
		||||
	result_height	= rootImage_height - subImage_height + 1;
 | 
			
		||||
 | 
			
		||||
	/* Initialize our result image */
 | 
			
		||||
	result = cvCreateImage( cvSize( result_width, result_height ), IPL_DEPTH_32F, 1 );
 | 
			
		||||
 | 
			
		||||
	/* Compute the result image */
 | 
			
		||||
	cvMatchTemplate( rootImage, subImage, result, searchMethod );
 | 
			
		||||
	cvMinMaxLoc( result, &minval, &maxval, &minloc, &maxloc, 0 );
 | 
			
		||||
 | 
			
		||||
	/* Free memory for the result image
 | 
			
		||||
	 * Note that we don't control the root or sub image,
 | 
			
		||||
	 * so don't mess with those */
 | 
			
		||||
	cvReleaseImage( &result );
 | 
			
		||||
 | 
			
		||||
	/* Make sure that we have enough correlation to return a result,
 | 
			
		||||
	 * and then return the match location*/
 | 
			
		||||
	/* Return the match location */
 | 
			
		||||
	if ( searchMethod == CV_TM_SQDIFF || searchMethod == CV_TM_SQDIFF_NORMED )
 | 
			
		||||
	{
 | 
			
		||||
		if ( minval < tolerance )
 | 
			
		||||
			return minloc;
 | 
			
		||||
		else
 | 
			
		||||
			return badpoint;
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		if ( maxval > tolerance )
 | 
			
		||||
			return maxloc;
 | 
			
		||||
		else
 | 
			
		||||
			return badpoint;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}		/* -----  end of function matchSubImage  ----- */
 | 
			
		||||
 | 
			
		||||
/* 
 | 
			
		||||
 * ===  FUNCTION  ======================================================================
 | 
			
		||||
 *         Name:  matchSubImage_location
 | 
			
		||||
 *  Description:  Match a root image and sub image from filename
 | 
			
		||||
 * =====================================================================================
 | 
			
		||||
 */
 | 
			
		||||
CvPoint matchSubImage_location ( const char *rootImage_location, const char *subImage_location, int searchMethod, double tolerance )
 | 
			
		||||
{
 | 
			
		||||
	/* This is basically a wrapper for matchSubImage( IplImage, IplImage )
 | 
			
		||||
	 * All we do is load the images from the given filenames, and then
 | 
			
		||||
	 * pass off the result to the above-named function */
 | 
			
		||||
	IplImage *rootImage;
 | 
			
		||||
	rootImage = cvLoadImage( rootImage_location, CV_LOAD_IMAGE_COLOR );
 | 
			
		||||
 | 
			
		||||
	IplImage *subImage;
 | 
			
		||||
	subImage = cvLoadImage( subImage_location, CV_LOAD_IMAGE_COLOR );
 | 
			
		||||
 | 
			
		||||
	CvPoint return_point;
 | 
			
		||||
	return_point.x = return_point.y = -1;
 | 
			
		||||
 | 
			
		||||
	/* Make sure we have good images */
 | 
			
		||||
	if ( rootImage == 0 || subImage == 0 )
 | 
			
		||||
	{
 | 
			
		||||
		/* Return error */
 | 
			
		||||
		return return_point;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return_point = matchSubImage( rootImage, subImage, searchMethod, tolerance );
 | 
			
		||||
 | 
			
		||||
	/* Free up the memory we created */
 | 
			
		||||
	cvReleaseImage( &rootImage );
 | 
			
		||||
	cvReleaseImage( &subImage );
 | 
			
		||||
 | 
			
		||||
	/* Our return_point will already be NULL if there's no match */
 | 
			
		||||
	return return_point;
 | 
			
		||||
 | 
			
		||||
}		/* -----  end of function matchSubImage  ----- */
 | 
			
		||||
 | 
			
		||||
/* 
 | 
			
		||||
 * ===  FUNCTION  ======================================================================
 | 
			
		||||
 *         Name:  matchSubImage_a
 | 
			
		||||
 *  Description:  Match a root image and sub image from an array of sub-images.
 | 
			
		||||
 *  				The list contains an element for each sub-image to specify its own
 | 
			
		||||
 *  				searchMethod and threshold value.
 | 
			
		||||
 * =====================================================================================
 | 
			
		||||
 */
 | 
			
		||||
void matchSubImage_a ( IplImage *rootImage, cvautomationList *subImageArray, int listSize )
 | 
			
		||||
{
 | 
			
		||||
	/* This is also a higher-end wrapper for matchSubImage, but is mostly aimed
 | 
			
		||||
	 * at making python support for multiple images very easy. */
 | 
			
		||||
 | 
			
		||||
	CvPoint resultPoint;
 | 
			
		||||
	cvautomationList curr;
 | 
			
		||||
 | 
			
		||||
	int x = 0;
 | 
			
		||||
	for ( x = 0; x < listSize; x++ )
 | 
			
		||||
	{
 | 
			
		||||
		curr = subImageArray[x];
 | 
			
		||||
		if ( subImageArray[x].cvaImage != 0 )
 | 
			
		||||
			resultPoint = matchSubImage ( rootImage, curr.cvaImage, curr.searchMethod, curr.tolerance );
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			/* We have a sub-image filename, go ahead and create the actual image. */
 | 
			
		||||
			IplImage *subImage;
 | 
			
		||||
			subImage = cvLoadImage( curr.fileName, CV_LOAD_IMAGE_COLOR );
 | 
			
		||||
 | 
			
		||||
			resultPoint = matchSubImage ( rootImage, subImage, curr.searchMethod, curr.tolerance );
 | 
			
		||||
 | 
			
		||||
			cvReleaseImage( &subImage );
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		curr.resultPoint = resultPoint;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* 
 | 
			
		||||
 * ===  FUNCTION  ======================================================================
 | 
			
		||||
 *         Name:  matchSubImage_list_location
 | 
			
		||||
 *  Description:  Match a root image from location, and sub image from
 | 
			
		||||
 *  				an array of sub-images.
 | 
			
		||||
 *  				The list contains an element for each sub-image to specify its own
 | 
			
		||||
 *  				searchMethod and threshold value.
 | 
			
		||||
 * =====================================================================================
 | 
			
		||||
 */
 | 
			
		||||
void matchSubImage_a_location ( const char *rootImageFileName, cvautomationList *subImageArray, int listSize )
 | 
			
		||||
{
 | 
			
		||||
	/* This is also a higher-end wrapper for matchSubImage, but is mostly aimed
 | 
			
		||||
	 * at making python support for multiple images very easy. */
 | 
			
		||||
 | 
			
		||||
	CvPoint resultPoint;
 | 
			
		||||
	cvautomationList curr;
 | 
			
		||||
 | 
			
		||||
	IplImage *rootImage;
 | 
			
		||||
	rootImage = cvLoadImage( rootImageFileName, CV_LOAD_IMAGE_COLOR );
 | 
			
		||||
 | 
			
		||||
	int x = 0;
 | 
			
		||||
	for ( x = 0; x < listSize; x++ )
 | 
			
		||||
	{
 | 
			
		||||
		curr = subImageArray[x];
 | 
			
		||||
		if ( subImageArray[x].cvaImage != 0 )
 | 
			
		||||
			resultPoint = matchSubImage ( rootImage, curr.cvaImage, curr.searchMethod, curr.tolerance );
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			/* We have a sub-image filename, go ahead and create the actual image. */
 | 
			
		||||
			IplImage *subImage;
 | 
			
		||||
			subImage = cvLoadImage( curr.fileName, CV_LOAD_IMAGE_COLOR );
 | 
			
		||||
 | 
			
		||||
			resultPoint = matchSubImage ( rootImage, subImage, curr.searchMethod, curr.tolerance );
 | 
			
		||||
 | 
			
		||||
			cvReleaseImage( &subImage );
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		curr.resultPoint = resultPoint;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cvReleaseImage( &rootImage );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										207
									
								
								libcvautomation/libcvautomation-x11.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										207
									
								
								libcvautomation/libcvautomation-x11.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,207 @@
 | 
			
		||||
/*
 | 
			
		||||
 * =====================================================================================
 | 
			
		||||
 *
 | 
			
		||||
 *       Filename:  libcvautomation-x11.c
 | 
			
		||||
 *
 | 
			
		||||
 *    Description:  
 | 
			
		||||
 *
 | 
			
		||||
 *        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
 | 
			
		||||
 *
 | 
			
		||||
 * =====================================================================================
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <libcvautomation/libcvautomation-x11.h>
 | 
			
		||||
 | 
			
		||||
/* 
 | 
			
		||||
 * ===  FUNCTION  ======================================================================
 | 
			
		||||
 *         Name:  matchSubImage_X11
 | 
			
		||||
 *  Description:  Match a sub image using the X11 root window as root
 | 
			
		||||
 * =====================================================================================
 | 
			
		||||
 */
 | 
			
		||||
CvPoint matchSubImage_X11( char *displayLocation, IplImage *subImage, int searchMethod, int tolerance )
 | 
			
		||||
{
 | 
			
		||||
	/* First things first, grab the root X window and convert it to
 | 
			
		||||
	 * the IplImage format.
 | 
			
		||||
	 * Much of this code was ripped lovingly from:
 | 
			
		||||
	 * 	http://opencv.willowgarage.com/wiki/ximage2opencvimage */
 | 
			
		||||
	IplImage *X_IPL;
 | 
			
		||||
	CvSize imageSize;
 | 
			
		||||
	CvPoint resultPoint;
 | 
			
		||||
 | 
			
		||||
	XImage *rootImage;
 | 
			
		||||
	XColor color;
 | 
			
		||||
	Display *display;
 | 
			
		||||
	Screen *screen;
 | 
			
		||||
	unsigned long rmask, gmask, bmask;
 | 
			
		||||
	unsigned long rshift, rbits,
 | 
			
		||||
					gshift, gbits,
 | 
			
		||||
					bshift, bbits;
 | 
			
		||||
	unsigned char colorChannel[3];
 | 
			
		||||
 | 
			
		||||
	int startX = 0, startY = 0;
 | 
			
		||||
	unsigned int width, height;
 | 
			
		||||
 | 
			
		||||
	/* Setting up the X screengrab is the first order of business */
 | 
			
		||||
	display = XOpenDisplay(displayLocation);
 | 
			
		||||
	screen = DefaultScreenOfDisplay(display);
 | 
			
		||||
	
 | 
			
		||||
	width = screen->width;
 | 
			
		||||
	height = screen->height;
 | 
			
		||||
 | 
			
		||||
	rootImage = XGetImage( display, DefaultRootWindow(display),
 | 
			
		||||
							startX, startY, width, height,
 | 
			
		||||
							AllPlanes, ZPixmap );
 | 
			
		||||
 | 
			
		||||
	/* Make sure that we're good to go before going any farther */
 | 
			
		||||
	if ( rootImage == NULL || display == NULL || screen == NULL )
 | 
			
		||||
	{
 | 
			
		||||
		fprintf( stderr, "Couldn't grab the root window!" );
 | 
			
		||||
		resultPoint.x = -1;
 | 
			
		||||
		resultPoint.y = -1;
 | 
			
		||||
		return resultPoint;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Set up the OpenCV Image */
 | 
			
		||||
	imageSize.width = rootImage->width;
 | 
			
		||||
	imageSize.height = rootImage->height;
 | 
			
		||||
	X_IPL = cvCreateImage( imageSize, IPL_DEPTH_8U, 3 ); /* 3 channels - RGB */
 | 
			
		||||
 | 
			
		||||
	/* This if block converts the X root window to an IPL image. See you on the other side! */
 | 
			
		||||
	unsigned int x, y; /* To be used later */
 | 
			
		||||
 | 
			
		||||
	if ( screen->depths->depth == 24 )
 | 
			
		||||
	{
 | 
			
		||||
		/* Actually convert the XImage to Ipl */
 | 
			
		||||
		rmask = screen->root_visual->red_mask;
 | 
			
		||||
		gmask = screen->root_visual->green_mask;
 | 
			
		||||
		bmask = screen->root_visual->blue_mask;
 | 
			
		||||
 | 
			
		||||
		/* I honestly have no clue how most of the below code works */
 | 
			
		||||
		/* TODO: Figure out how this code works and document it */
 | 
			
		||||
		rshift = 0; rbits = 0;
 | 
			
		||||
		while ( !(rmask & 1) ){
 | 
			
		||||
			rshift++;
 | 
			
		||||
			rmask >>= 1; /* Right bitshift by 1 */
 | 
			
		||||
		}
 | 
			
		||||
		while (rmask & 1) {
 | 
			
		||||
			rbits++;
 | 
			
		||||
			rmask >>= 1; /* Right bitshift by 1 */
 | 
			
		||||
		}
 | 
			
		||||
		if (rbits > 8) {
 | 
			
		||||
			rshift += rbits - 8;
 | 
			
		||||
			rbits = 8;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		gshift = 0; gbits = 0;
 | 
			
		||||
		while ( !(gmask & 1) ){
 | 
			
		||||
			gshift++;
 | 
			
		||||
			gmask >>= 1; /* Right bitshift by 1 */
 | 
			
		||||
		}
 | 
			
		||||
		while (gmask & 1) {
 | 
			
		||||
			gbits++;
 | 
			
		||||
			gmask >>= 1; /* Right bitshift by 1 */
 | 
			
		||||
		}
 | 
			
		||||
		if (gbits > 8) {
 | 
			
		||||
			gshift += gbits - 8;
 | 
			
		||||
			gbits = 8;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		bshift = 0; bbits = 0;
 | 
			
		||||
		while ( !(bmask & 1) ){
 | 
			
		||||
			bshift++;
 | 
			
		||||
			bmask >>= 1; /* Right bitshift by 1 */
 | 
			
		||||
		}
 | 
			
		||||
		while (bmask & 1) {
 | 
			
		||||
			bbits++;
 | 
			
		||||
			bmask >>= 1; /* Right bitshift by 1 */
 | 
			
		||||
		}
 | 
			
		||||
		if (bbits > 8) {
 | 
			
		||||
			bshift += bbits - 8;
 | 
			
		||||
			bbits = 8;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for ( x = 0; x < rootImage->width; x++) {
 | 
			
		||||
			for ( y = 0; y < rootImage->height; y++) {
 | 
			
		||||
				color.pixel = XGetPixel ( rootImage, x, y );
 | 
			
		||||
				colorChannel[0] = ((color.pixel >> bshift) & ((1 << bbits) - 1)) << (8 - bbits);
 | 
			
		||||
				colorChannel[1] = ((color.pixel >> gshift) & ((1 << gbits) - 1)) << (8 - gbits);
 | 
			
		||||
				colorChannel[2] = ((color.pixel >> rshift) & ((1 << rbits) - 1)) << (8 - rbits);
 | 
			
		||||
				CV_IMAGE_ELEM(X_IPL, uchar, y, x * X_IPL->nChannels) = colorChannel[0];
 | 
			
		||||
				CV_IMAGE_ELEM(X_IPL, uchar, y, x * X_IPL->nChannels + 1) = colorChannel[1];
 | 
			
		||||
				CV_IMAGE_ELEM(X_IPL, uchar, y, x * X_IPL->nChannels + 2) = colorChannel[2];
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		/* Slow alternative for non-24-bit-depth images */
 | 
			
		||||
		/* I don't know how this works either. */
 | 
			
		||||
		/* TODO: Figure out how this code works and document it */
 | 
			
		||||
		Colormap colormap = DefaultColormap( &display, DefaultScreen ( &display ));
 | 
			
		||||
		for ( x = 0; x < rootImage->width; x++ ) {
 | 
			
		||||
			for ( y = 0; y < rootImage->height; y++ ) {
 | 
			
		||||
				color.pixel = XGetPixel ( rootImage, x, y );
 | 
			
		||||
				XQueryColor( display, colormap, &color );
 | 
			
		||||
				CV_IMAGE_ELEM(X_IPL, uchar, y, x * X_IPL->nChannels) = color.blue;
 | 
			
		||||
				CV_IMAGE_ELEM(X_IPL, uchar, y, x * X_IPL->nChannels + 1) = color.green;
 | 
			
		||||
				CV_IMAGE_ELEM(X_IPL, uchar, y, x * X_IPL->nChannels + 2) = color.red;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Now that we've got the image we want as X_IPL, time to actually do the comparison.
 | 
			
		||||
	 * However, we don't want to do any more work than we have to - send our images off
 | 
			
		||||
	 * to matchSubImage in libopencvautomation-opencv. */
 | 
			
		||||
 | 
			
		||||
	resultPoint = matchSubImage ( X_IPL, subImage, searchMethod, tolerance );
 | 
			
		||||
 | 
			
		||||
	/* Clean up the CV image we created, as well as all X resources */
 | 
			
		||||
	XDestroyImage( rootImage );
 | 
			
		||||
	XCloseDisplay( display );
 | 
			
		||||
	cvReleaseImage( &X_IPL );
 | 
			
		||||
 | 
			
		||||
	/* Return and be done */
 | 
			
		||||
	return resultPoint;
 | 
			
		||||
 | 
			
		||||
}		/* -----  end of function matchSubImage_X11  ----- */
 | 
			
		||||
 | 
			
		||||
/* 
 | 
			
		||||
 * ===  FUNCTION  ======================================================================
 | 
			
		||||
 *         Name:  matchSubImage_X11
 | 
			
		||||
 *  Description:  Match a sub image using the X11 root window as root, from filename
 | 
			
		||||
 * =====================================================================================
 | 
			
		||||
 */
 | 
			
		||||
CvPoint matchSubImage_X11_location( char *displayLocation, const char *subImage_location, int searchMethod, int tolerance )
 | 
			
		||||
{
 | 
			
		||||
	/* This is basically a wrapper for matchSubImage_X11( char *display, IplImage )
 | 
			
		||||
	 * All we do is load the sub-image from the given filename, and then
 | 
			
		||||
	 * pass off the result to the above-named function */
 | 
			
		||||
 | 
			
		||||
	IplImage *subImage;
 | 
			
		||||
	subImage = cvLoadImage( subImage_location, CV_LOAD_IMAGE_COLOR );
 | 
			
		||||
 | 
			
		||||
	CvPoint return_point;
 | 
			
		||||
 | 
			
		||||
	/* Make sure we have a good image */
 | 
			
		||||
	if ( subImage == 0 )
 | 
			
		||||
	{
 | 
			
		||||
		/* Return error */
 | 
			
		||||
		return return_point;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return_point = matchSubImage_X11( displayLocation, subImage, searchMethod, tolerance );
 | 
			
		||||
 | 
			
		||||
	/* Free up the memory we created */
 | 
			
		||||
	cvReleaseImage( &subImage );
 | 
			
		||||
 | 
			
		||||
	/* Our return_point will already be bad if there's no match,
 | 
			
		||||
	 * we don't need to worry about setting it. */
 | 
			
		||||
	return return_point;
 | 
			
		||||
 | 
			
		||||
}		/* -----  end of function matchSubImage_X11_location  ----- */
 | 
			
		||||
		Reference in New Issue
	
	Block a user