The Image Extender provides three APIs to query the cataloged images in a table column. The APIs differ only in whether they require a query string or query object as input:
API | Input |
---|---|
QbQueryStringSearch | Query string |
QbQuerySearch | Query object handle |
QbQueryNameSearch | Query object name |
In all three APIs, you also:
You also point to an array of output structures to contain the results of the search. In response, the Image Extender returns in these structures the handles of the target images whose feature values are most similar to the feature value of the query. It also returns a score for each image that indicates how similar the feature value of the image is to the query. The structure is defined in the include (header) file for QBIC, dmbqbapi.h, as follows:
typedef struct{ char imageHandle[MMDB_BASE_HANDLE_LEN+1]; SQLDOUBLE SCORE } QbResult;
You must allocate an array large enough to hold the maximum number of results you specify, and point to the array in the API. You must also point to a counter; the Image Extender sets the value of the counter to the number of results it returns.
In the following example, the QbQueryStringSearch API is used to query by content the cataloged images in a table column. Notice that the pointer to the query scope is set to a zero value.
QbResult returns[MaxQueryReturns]; SQLINTEGER maxResults=qbiMaxQueryReturns; SQLINTEGER count; QbQueryHandle qHandle; QbResult results[qbiMaxQueryReturns]; rc=QbQueryStringSearch( "QbColorFeatureClass color=<255, 0, 0>" /*query string */ "employee", /* user table */ "picture", /* image column */ maxResults, /* maximum number of results */ 0, /* query scope pointer * / qbiArray, /* store results in an array */ &count, /* count of returned images */ results); /* array of returned results */
Here is a request that uses the QbQuerySearch API. Notice that the query object handle is specified as input.
QbResult returns[MaxQueryReturns]; SQLINTEGER maxResults=qbiMaxQueryReturns; SQLINTEGER count; QbQueryHandle qHandle; QbResult results[qbiMaxQueryReturns]; rc=QbQuerySearch( qHandle, / query object handle */ "employee", /* user table */ "picture", /* image column */ maxResults, /* maximum number of results */ 0, /* query scope pointer * / qbiArray, /* store results in an array */ &count, /* count of returned images */ results); /* array of returned results */