Oracle8 Visual Information Retrieval Cartridge User's Guide Release 1.0.1 A55255-02 |
|
A sample program is included with Visual Information Retrieval Cartridge to demonstrate how to load two images into the database, generate their signatures, and then compare their signatures using a weighted similarity function.
This program uses two data files, virdemo1.dat and virdemo2.dat, as its input. No other input or parameters are required.
The following assumptions are made:
There are two ways to run the sample program: using the included sample images, or using your own images.
Example B-1 runs the sample program using the included image files. The images are compared using the following attribute weights:
% virdemo Image 1 and 2 have a similarity score of 0.0
Example B-2 shows how to specify your own images on the command line. The images must reside in the VIRDEMODIR directory.
% virdemo <image1> <image2> <global_color> <local_color> <texture> <structure>
All six parameters: the two file names and four attribute weights (ranging from 0.0 to 1.0) must be specified in this sample program. Note that when using the Score( ) operator in your own applications, it is only necessary to provide at least one attribute weight.
Several other sample image files have been provided in the VIRDEMODIR directory to demonstrate the effects of emphasizing the different visual attributes. You can use an image viewer (such as xv) to display the images, and then compare them using the sample program, experimenting with different weights. Figure B-1 shows the sample images.
The relative distance between the images being compared is called the score and is output during the execution of the sample program. A lower score indicates a closer match. A score of zero would indicate a perfect match.
A score is only valid for a given set of weights for the four visual attributes. If you change the weights, the results will change. For example, consider a comparison of national flags. The flag of Cote d'Ivoire (the Ivory Coast) is composed of three equal vertical color stripes: orange, white, and green. The flag of Ireland is composed of three vertical stripes in the reverse order: green, white, and orange. A comparison of flag images based on global color or structure would consider these two flags identical. However, a comparison emphasizing local color would return a much larger distance between the two images, indicating a poor match1.
#ifdef RCSID static char *RCSid = "$Header: virdemo.c 05-nov-97 jhebert Exp $ "; #endif /* RCSID */ /* Copyright (c) Oracle Corporation 1997. All Rights Reserved. */ /* NAME virdemo.c - out-of-the-box demo using the visual information retrieval cartridge DESCRIPTION This program demonstrates how to use Visual Information Retrieval Cartridge to load two images into the database, generate their signatures, and then compare their signatures using a weighted similarity function. The program will use two data files provided with the cartridge named virdemo1.dat and virdemo2.dat as its input so no parameter is required. The relative distance between the images being compared is called the score and is output during the execution of the sample program. An image viewer (such as xv) may be used to view the input images. Sample usage1: virdemo virdemo1.dat, virdemo2.dat -- images to be compared with default weights as: globalcolor = 1.0 localcolor = 1.0 texture = 1.0 structure = 1.0 Sample usage2: virdemo <datafile.dat> <datafile.dat> <gc> <lc> <tx> <st> gc,lc,tx,st -- globalcolor,localcolor,texture,structure. Optionally, user-provided image files can be specified on the command line as shown above, provided that they reside in the VIRDEMODIR directory (see assumptions below). Note: All 6 parameters (2 file names and 4 values in the range [0.0,1.0]) must be given for sample usage 2. ENVIRONMENT: The following assumptions are made: 1) Visual Information Retrieval Cartridge has been installed and PUBLIC has EXECUTE privilege on it. 2) Install script has been run and thus created VIRDEMODIR directory and granted PUBLIC READ access in order that the image data file can be read into the database. 3) virdemo1.dat and virdemo2.dat are valid image files that reside in
the VIRDEMODIR directory and the user has read/write access to the directory. 4) User SCOTT has the default password. PUBLIC FUNCTION(S) PRIVATE FUNCTION(S) RETURNS NOTES The table VIRDEMOTAB is left in the SCOTT account in the default database for the user's viewing as well. The VIRDEMODIR directory will likewise be left in the system account. MODIFIED (MM/DD/YY) jhebert 11/05/97 - Edit comments in sample program rchopra 09/02/97 - Remove redundant HandleFree stmts rchopra 07/21/97 - Creation (modified from imgdemo.c by svivian) */ #include <stdio.h> #ifndef OCI_ORACLE #include <oci.h> #endif /* local routines */ static sb4 init_handles(); static sb4 attach_server(); static sb4 log_on(); static void logout(); static sb4 create_table(); static void drop_table(); static sb4 load_cart(); static sb4 test_1_vir(char *, char *, char *, char *); static void report_error(); #define TRUE 1 #define FALSE 0 #define MAXBUFLEN 16384 #define STMTLEN 512 #define FNAMELEN 80 #define ARGLEN 10 #define NUMIMGS 2 static OCIEnv *envhp; static OCIServer *srvhp; static OCISvcCtx *svchp; static OCIError *errhp; static OCISession *authp; static OCIStmt *stmthp; static OCILobLocator *blob, *bfile; static OCIDefine *defnp1, *defnp2; static OCIBind *bndhp, *bndhp1,*bndhp2,*bndhp3,*bndhp4; static text *user = (text *)"SCOTT"; static text *upwd = (text *)"TIGER"; int main(int argc, char *argv[]) { char iname[2][FNAMELEN]; char g_col[ARGLEN], l_col[ARGLEN], texture[ARGLEN], strct[ARGLEN]; if (argc == 7) { strcpy(iname[0], argv[1]); strcpy(iname[1], argv[2]); strcpy(g_col,argv[3]); strcpy(l_col,argv[4]); strcpy(texture,argv[5]); strcpy(strct,argv[6]); } else if (argc == 1) { strcpy(iname[0], "virdemo1.dat"); strcpy(iname[1], "virdemo2.dat"); strcpy(g_col,"1.0"); strcpy(l_col,"1.0"); strcpy(texture,"1.0"); strcpy(strct,"1.0"); } else { (void) fprintf(stdout,"Incorrect number of parameters\n"); logout(); return OCI_ERROR; } if (init_handles()) { (void) fprintf(stdout,"FAILED: init_handles()\n"); return OCI_ERROR; } if (attach_server()) { (void)fprintf (stdout, "FAILED: attach_server()\n"); logout(); return OCI_ERROR; } if (log_on(user,upwd)) { (void) fprintf(stdout,"FAILED: log_on()\n"); logout(); return OCI_ERROR; } if (create_table(iname)) { (void) fprintf(stdout,"FAILED: create_table()\n"); logout(); return OCI_ERROR; } (void)fprintf (stdout, "\nLoading data into cartridge...\n"); if (load_cart()) { (void) fprintf(stdout,"FAILED: load_cart()\n"); logout(); return OCI_ERROR; } (void)fprintf (stdout, "\nTesting...\n"); if (test_1_vir(g_col,l_col,texture,strct)) { (void)fprintf (stdout, "\nFAILED: test_1_vir()\n"); logout(); return OCI_ERROR; } (void)fprintf (stdout, "\nDisconnecting from database...\n"); logout(); (void)fprintf (stdout, "\nDemo completed successfully.\n"); return OCI_SUCCESS; } /* end main */ /* * ----------------------------------------------------------------- * init_handles - initialize environment, allocate handles, etc. * ----------------------------------------------------------------- */ sb4 init_handles() { sword status; if (OCIInitialize((ub4) OCI_DEFAULT, (dvoid *)0, (dvoid * (*)(dvoid *, size_t)) 0, (dvoid * (*)(dvoid *, dvoid *, size_t))0, (void (*)(dvoid *, dvoid *)) 0 )) { (void) fprintf(stdout,"FAILED: OCIInitialize()\n"); return OCI_ERROR; } /* initialize environment handle */ if (OCIEnvInit((OCIEnv **) &envhp, (ub4) OCI_DEFAULT, (size_t) 0, (dvoid **) 0 )) { (void) fprintf(stdout,"FAILED: OCIEnvInit()\n"); return OCI_ERROR; } if (OCIHandleAlloc((dvoid *) envhp, (dvoid **) &svchp, (ub4) OCI_HTYPE_SVCCTX, (size_t) 0, (dvoid **) 0)) { (void) fprintf(stdout,"FAILED: OCIHandleAlloc()\n"); return OCI_ERROR; } if (OCIHandleAlloc((dvoid *) envhp, (dvoid **) &errhp, (ub4) OCI_HTYPE_ERROR, (size_t) 0, (dvoid **) 0)) { (void) fprintf(stdout,"FAILED: OCIHandleAlloc()\n"); return OCI_ERROR; } if (OCIHandleAlloc((dvoid *) envhp, (dvoid **) &stmthp, (ub4) OCI_HTYPE_STMT, (size_t) 0, (dvoid **) 0)) { (void) fprintf(stdout,"FAILED: OCIHandleAlloc()\n"); return OCI_ERROR; } if (OCIHandleAlloc((dvoid *) envhp, (dvoid **) &srvhp, (ub4) OCI_HTYPE_SERVER, (size_t) 0, (dvoid **) 0)) { (void) fprintf(stdout,"FAILED: OCIHandleAlloc()\n"); return OCI_ERROR; } if (OCIHandleAlloc((dvoid *) envhp, (dvoid **) &authp, (ub4) OCI_HTYPE_SESSION, (size_t) 0, (dvoid **) 0)) { (void) fprintf(stdout,"FAILED: OCIHandleAlloc()\n"); return OCI_ERROR; } /* allocate the lob locator variables */ if (OCIDescriptorAlloc((dvoid *) envhp, (dvoid **) &blob, (ub4)OCI_DTYPE_LOB, (size_t) 0, (dvoid **) 0)) { (void) fprintf(stdout,"FAILED: OCIDescriptorAlloc(blob)\n"); return OCI_ERROR; } /* allocate the lob locator variables - will change to OCI_DTYPE_FILE */ if (OCIDescriptorAlloc((dvoid *) envhp, (dvoid **) &bfile, (ub4)OCI_DTYPE_LOB, (size_t) 0, (dvoid **) 0)) { (void) fprintf(stdout,"FAILED: OCIDescriptorAlloc(bfile)\n"); return OCI_ERROR; } /* allocate the define handles */ if (OCIHandleAlloc((dvoid *) stmthp, (dvoid **) &defnp1, (ub4) OCI_HTYPE_DEFINE, (size_t) 0, (dvoid **) 0)) { (void) fprintf(stdout,"FAILED: OCIHandleAlloc()\n"); return OCI_ERROR; } if (OCIHandleAlloc((dvoid *) stmthp, (dvoid **) &defnp2, (ub4) OCI_HTYPE_DEFINE, (size_t) 0, (dvoid **) 0)) { (void) fprintf(stdout,"FAILED: OCIHandleAlloc()\n"); return OCI_ERROR; } /* allocate the bind handles */ if (OCIHandleAlloc((dvoid *) stmthp, (dvoid **) &bndhp, (ub4) OCI_HTYPE_BIND, (size_t) 0, (dvoid **) 0)) { (void) fprintf(stdout,"FAILED: OCIHandleAlloc()\n"); return OCI_ERROR; } if (OCIHandleAlloc((dvoid *) stmthp, (dvoid **) &bndhp1, (ub4) OCI_HTYPE_BIND, (size_t) 0, (dvoid **) 0)) { (void) fprintf(stdout,"FAILED: OCIHandleAlloc()\n"); return OCI_ERROR; } if (OCIHandleAlloc((dvoid *) stmthp, (dvoid **) &bndhp2, (ub4) OCI_HTYPE_BIND, (size_t) 0, (dvoid **) 0)) { (void) fprintf(stdout,"FAILED: OCIHandleAlloc()\n"); return OCI_ERROR; } if (OCIHandleAlloc((dvoid *) stmthp, (dvoid **) &bndhp3, (ub4) OCI_HTYPE_BIND, (size_t) 0, (dvoid **) 0)) { (void) fprintf(stdout,"FAILED: OCIHandleAlloc()\n"); return OCI_ERROR; } if (OCIHandleAlloc((dvoid *) stmthp, (dvoid **) &bndhp4, (ub4) OCI_HTYPE_BIND, (size_t) 0, (dvoid **) 0)) { (void) fprintf(stdout,"FAILED: OCIHandleAlloc()\n"); return OCI_ERROR; } return OCI_SUCCESS; } /* end init_handles */ /* * ----------------------------------------------------------------- * attach_server - attach to default server * ----------------------------------------------------------------- */ sb4 attach_server() { /* attach to the server - use default host? */ if (OCIServerAttach(srvhp, errhp, (text *) NULL, 0, (ub4) OCI_DEFAULT)) { (void) fprintf(stdout,"FAILED: OCIServerAttach()\n"); return OCI_ERROR; } /* set the server attribute in the service context */ if (OCIAttrSet((dvoid *) svchp, (ub4) OCI_HTYPE_SVCCTX, (dvoid *) srvhp, (ub4) 0, (ub4) OCI_ATTR_SERVER, errhp)) { (void) fprintf(stdout,"FAILED: OCIAttrSet()\n"); return OCI_ERROR; } return (OCI_SUCCESS); } /* end attach_server */ /* * ----------------------------------------------------------------- * log_on - log on to server * ----------------------------------------------------------------- */ sb4 log_on( text *uid, text *pwd ) { if (OCIAttrSet((dvoid *) authp, (ub4) OCI_HTYPE_SESSION, (dvoid *) uid, (ub4) strlen((char *)uid), (ub4) OCI_ATTR_USERNAME, errhp)) { (void) fprintf(stdout,"FAILED: OCIAttrSet()\n"); return OCI_ERROR; } if (OCIAttrSet((dvoid *) authp, (ub4) OCI_HTYPE_SESSION, (dvoid *) pwd, (ub4) strlen((char *)pwd), (ub4) OCI_ATTR_PASSWORD, errhp)) { (void) fprintf(stdout,"FAILED: OCIAttrSet()\n"); return OCI_ERROR; } /* log on */ if (OCISessionBegin(svchp, errhp, authp, (ub4) OCI_CRED_RDBMS, (ub4) OCI_DEFAULT)) { (void) fprintf(stdout,"FAILED: OCISessionBegin()\n"); return OCI_ERROR; } /* set the session attribute in the service context */ if (OCIAttrSet((dvoid *) svchp, (ub4) OCI_HTYPE_SVCCTX, (dvoid *) authp, (ub4) 0, (ub4) OCI_ATTR_SESSION, errhp)) { (void) fprintf(stdout,"FAILED: OCIAttrSet()\n"); return OCI_ERROR; } return OCI_SUCCESS; } /* end log_on */ /* * ----------------------------------------------------------------- * create_table - Create table VIRDEMOTAB and insert NUMIMGS rows. * ----------------------------------------------------------------- */ sb4 create_table(char iname[NUMIMGS][FNAMELEN]) { text *crtstmt = (text *) "CREATE TABLE VIRDEMOTAB (C1 INT, C2 ORDSYS.ORDVirF, C3 ORDSYS.ORDVirB)"; text insstmt[STMTLEN]; int counter; /* * drop table first if it exists and then re-create. */ drop_table(); /* * create table */ if (OCIStmtPrepare(stmthp, errhp, crtstmt, (ub4) strlen((char *) crtstmt), (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT)) { (void) fprintf(stdout,"FAILED: OCIStmtPrepare() crtstmt\n"); report_error(); return OCI_ERROR; } (void)fprintf (stdout, "\nCreating and populating table VIRDEMOTAB...\n"); if (OCIStmtExecute(svchp, stmthp, errhp, (ub4) 1, (ub4) 0, (CONST OCISnapshot *) 0, (OCISnapshot *) 0, (ub4) OCI_DEFAULT)) { (void) fprintf(stdout,"FAILED: creating table\n"); report_error(); return OCI_ERROR; } /* * populate table with simple inserts */ for (counter=0;counter<NUMIMGS;counter++) { sprintf ((char*)insstmt,"INSERT INTO VIRDEMOTAB VALUES (%d,ORDSYS.ORDVirF(bfilename('VIRDEMODIR','%s'), NULL,NULL,NULL,NULL,NULL,NULL,NULL),ORDSYS.ORDVirB(empty_blob(),NULL,NULL,NULL,NULL,NULL,NULL,NULL))",counter+1,
iname[counter]); if (OCIStmtPrepare(stmthp, errhp, insstmt, (ub4) strlen((char *) insstmt), (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT)) { (void) fprintf(stdout,"FAILED: OCIStmtPrepare() insstmt\n"); report_error(); return OCI_ERROR; } if (OCIStmtExecute(svchp, stmthp, errhp, (ub4) 1, (ub4) 0, (CONST OCISnapshot *) 0, (OCISnapshot *) 0, (ub4) OCI_DEFAULT)) { (void) fprintf(stdout,"FAILED: OCIStmtExecute() insstmt\n"); report_error(); return OCI_ERROR; } } /* end for stmt */ (void) OCITransCommit(svchp, errhp, (ub4)0); return OCI_SUCCESS; } /* end create_table */ /* *------------------------------------------------------------------- * drop_table - Drop table VIRDEMOTAB *------------------------------------------------------------------- */ void drop_table() { text *sqlstmt = (text *) "DROP TABLE VIRDEMOTAB"; ub1 ebuf[256]; text *sqlstate=0; ub4 errcodep; (void)fprintf(stdout,"\nDropping table VIRDEMOTAB...\n"); if (OCIStmtPrepare(stmthp, errhp, sqlstmt, (ub4) strlen((char *) sqlstmt), (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT)) { (void) fprintf(stdout,"FAILED: drop table\n"); return; } (void)OCIStmtExecute(svchp, stmthp, errhp, (ub4) 1, (ub4) 0, (CONST OCISnapshot *) 0, (OCISnapshot *) 0, (ub4) OCI_DEFAULT); return; } /* end drop_table */ /* * ------------------------------------------------------------------- * logout - Logoff and disconnect from the server. Free handles. * ------------------------------------------------------------------- */ void logout() { (void) OCISessionEnd(svchp, errhp, authp, (ub4) 0); (void) OCIServerDetach(srvhp, errhp, (ub4) OCI_DEFAULT); (void) fprintf(stdout,"\nLogged off and detached from server.\n"); (void) OCIHandleFree((dvoid *) srvhp, (ub4) OCI_HTYPE_SERVER); (void) OCIHandleFree((dvoid *) svchp, (ub4) OCI_HTYPE_SVCCTX); (void) OCIHandleFree((dvoid *) errhp, (ub4) OCI_HTYPE_ERROR); (void) OCIHandleFree((dvoid *) authp, (ub4) OCI_HTYPE_SESSION); (void) OCIDescriptorFree((dvoid *) blob, (ub4) OCI_DTYPE_LOB); (void) OCIDescriptorFree((dvoid *) bfile, (ub4) OCI_DTYPE_LOB); (void) OCIHandleFree((dvoid *) stmthp, (ub4) OCI_HTYPE_STMT); return; } /* end logout */ /* * ----------------------------------------------------------------- * report_error - retrieve error message and print it out. * ----------------------------------------------------------------- */ void report_error() { text msgbuf[1024]; sb4 errcode; (void) OCIErrorGet((dvoid *) errhp, (ub4) 1, (text *) NULL, &errcode, msgbuf, (ub4) sizeof(msgbuf), (ub4) OCI_HTYPE_ERROR); (void) fprintf(stdout,"ERROR CODE = %d\n", errcode); (void) fprintf(stdout,"%s\n", msgbuf); return; } /* end report_error */ /* * ----------------------------------------------------------------- * load_cart - load data into Visual Information Retrieval Cartridge * * Populate the cartidge columns based on the contents of the BFILE. * The sequence of steps is to select the types and then use the * contents to set the properties and perform the copy from the * BFILE to the BLOB. * ----------------------------------------------------------------- */ sb4 load_cart() { int num_img = NUMIMGS; text *sqlstmt = (text *) "DECLARE \ A ORDSYS.ORDVirF;\ B ORDSYS.ORDVirB;\ BEGIN\ FOR i IN 1..:NUMIMGS LOOP\ SELECT C2, C3 INTO A,B FROM VIRDEMOTAB WHERE C1 = i FOR UPDATE;\ \ A.setProperties;\ A.copyContent(B.content);\ B.setProperties;\ UPDATE VIRDEMOTAB SET C2 = A WHERE C1 = i;\ UPDATE VIRDEMOTAB SET C3 = B WHERE C1 = i;\ END LOOP;\ COMMIT;\ END;"; if (OCIStmtPrepare(stmthp, errhp, sqlstmt, (ub4) strlen((char *)sqlstmt), (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT)) { (void) fprintf(stdout,"FAILED: OCIStmtPrepare() sqlstmt\n"); report_error(); return OCI_ERROR; } /* bind the placeholder :NUMIMGS to a program variable */ if (OCIBindByName (stmthp, &bndhp, errhp, (text *) ":NUMIMGS", -1, (ub1 *) &num_img, (sword) sizeof(num_img), SQLT_INT, (dvoid *) 0, (ub2 *) 0, (ub2) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT)) { (void) fprintf(stdout,"FAILED: OCIBindByName() sqlstmt\n"); report_error(); return OCI_ERROR; } /* execute the select and fetch one row */ if (OCIStmtExecute(svchp, stmthp, errhp, (ub4) 1, (ub4) 0, (CONST OCISnapshot*) 0, (OCISnapshot*) 0, (ub4) OCI_DEFAULT)) { (void) fprintf(stdout,"FAILED: OCIStmtExecute() sqlstmt\n"); report_error(); return OCI_ERROR; } return OCI_SUCCESS; } /* end load_cart */ /* * -------------------------------------------------------------------- * test_1_vir = Analyze the contents of the BLOB and BFILE and return the * score based on the weights assigned to the different features * ---------------------------------------------------------------------- */ sb4 test_1_vir(char *g_c, char * l_c, char * txtr, char * stre) { float w_sum = -1.999; /* dummy value */ text *sqlstmt = (text *) "DECLARE \ A ORDSYS.ORDVirF; \ B ORDSYS.ORDVirB; \ a_sig RAW(2000);\ b_sig RAW(2000);\ BEGIN \ SELECT C2 INTO A FROM VIRDEMOTAB WHERE C1=1 FOR UPDATE;\ SELECT C3 INTO B FROM VIRDEMOTAB WHERE C1=2 FOR UPDATE;\ ORDSYS.VIR.Analyze(A.content, a_sig);\ ORDSYS.VIR.Analyze(B.content, b_sig);\ :weighted_sum := ORDSYS.VIR.score(a_sig, b_sig, 'globalcolor='|| :g_color || ', localcolor= '|| :l_color || ', texture=' || :texture || ', structure=' || :strct);\ END;"; if (OCIStmtPrepare(stmthp, errhp, sqlstmt, (ub4) strlen((char *)sqlstmt), (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT)) { (void) fprintf(stdout,"FAILED: OCIStmtPrepare() sqlstmt\n"); report_error(); return OCI_ERROR; } /* bind the placeholder :weighted_sum to a program variable */ if (OCIBindByName (stmthp, &bndhp, errhp, (text *) ":weighted_sum", -1, (ub1 *) &w_sum, (sword) sizeof(w_sum), SQLT_FLT, (dvoid *) 0, (ub2 *) 0, (ub2) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT)) { (void) fprintf(stdout,"FAILED: OCIBindByName() sqlstmt : weighted_sum\n"); report_error(); return OCI_ERROR; } /* bind the placeholder :g_color to a program variable */ if (OCIBindByName (stmthp, &bndhp1, errhp, (text *) ":g_color", strlen(":g_color"), (ub1 *) g_c, (sword) strlen(g_c)*sizeof(g_c), SQLT_STR, (dvoid *) 0, (ub2 *) 0, (ub2) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT)) { (void) fprintf(stdout,"FAILED: OCIBindByName() sqlstmt : g_color\n"); report_error(); return OCI_ERROR; } /* bind the placeholder :l_color to a program variable */ if (OCIBindByName (stmthp, &bndhp2, errhp, (text *) ":l_color", strlen(":l_color"), (ub1 *) l_c, (sword) strlen(l_c)*sizeof(l_c), SQLT_STR, (dvoid *) 0, (ub2 *) 0, (ub2) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT)) { (void) fprintf(stdout,"FAILED: OCIBindByName() sqlstmt :l_color\n"); report_error(); return OCI_ERROR; } /* bind the placeholder :texture to a program variable */ if (OCIBindByName (stmthp, &bndhp3, errhp, (text *) ":texture", strlen(":texture"), (ub1 *) txtr, (sword) strlen(txtr)*sizeof(txtr), SQLT_STR, (dvoid *) 0, (ub2 *) 0, (ub2) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT)) { (void) fprintf(stdout,"FAILED: OCIBindByName() sqlstmt\n : texture"); report_error(); return OCI_ERROR; } /* bind the placeholder :strct to a program variable */ if (OCIBindByName (stmthp, &bndhp4, errhp, (text *) ":strct", strlen(":strct"), (ub1 *) stre, (sword) strlen(stre)*sizeof(stre), SQLT_STR, (void *) 0, (ub2 *) 0, (ub2) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT)) { (void) fprintf(stdout,"FAILED: OCIBindByName() sqlstmt : strct\n"); report_error(); return OCI_ERROR; } /* execute the select and fetch one row */ if (OCIStmtExecute(svchp, stmthp, errhp, (ub4) 1, (ub4) 0, (CONST OCISnapshot*) 0, (OCISnapshot*) 0, (ub4) OCI_DEFAULT)) { (void) fprintf(stdout,"FAILED: OCIStmtExecute() sqlstmt\n"); report_error(); return OCI_ERROR; } (void) fprintf(stdout, "Image 1 and 2 have similarity score of %f\n", w_sum); return OCI_SUCCESS; } /* end of file virdemo.c */
1
In the case of using Visual Information Retrieval for flag recognition, you would obviously need to know which direction the flag was facing in the test images.