Oracle Visual Information Retrieval Java Classes User's Guide and Reference Release 8.1.7 Part Number A85333-01 |
|
Oracle Visual Information Retrieval Java Classes describes the ORDVir object type.
Methods invoked at the ORDVir level that are handed off for processing to the database source plug-in have byte[ ] ctx[ ]
as a context parameter. In cases where a client system is connecting to a database server, the space for the parameter is created by the client (in the reference examples, 4000 bytes of space), but the content of the context parameter is generated by the server. The context parameter is passed from the client to the server for the processing of context information.
See Oracle Visual Information Retreival User's Guide and Reference for more information.
You will need to include the following import statements in your Java file to run Visual Information Retrieval methods:
import java.sql.*; import java.io.*; import oracle.jdbc.driver.*; import oracle.sql.*; import oracle.ord.im.*;
The examples in this reference chapter are based on the assumption that the following operations have already been performed:
For examples of making a connection and populating a local object, see Section 2.2.2.
This section presents reference information on the methods that operate on ORDVir objects.
public void analyze( )
Sets the value for the application ORDVir object signature attribute based on the image data.
None.
None.
SQLException
virObj.analyze( );
public boolean checkProperties( )
Checks whether or not the properties stored in the media data of the local object are consistent with the attributes of the local object.
None.
This method returns TRUE if the attribute values stored in the object attributes are the same as the properties stored in the image data; otherwise, this method returns FALSE.
java.sql.SQLException
if(virObj.checkProperties( )) System.out.println("checkProperties successful");
public void clearLocal( )
Clears the source local field of the application ORDVir object.
None.
None.
java.sql.SQLException
virObj.clearLocal( );
public int convert(String operations)
Converts the application ORDVir object signature data to a format usable on the database server (host) machine.
The type of processing done to the image signature. The following operations are available:
Operation Keyword | Description |
---|---|
BYTEORDER |
Converts the signature to the natural order of the host machine, regardless of its initial state. |
This method returns 0 if successful; otherwise, this method returns a non-zero integer.
SQLException
int i = virObj.convert("BYTEORDER"); if(i == 0) System.out.println("convert successful");
where:
public static int convert(byte[ ] signature, String operations, OracleConnection connection)
Converts the application ORDVir object signature data to a format usable on the database server (host) machine.
Unlike the non-static version of this function, the static function can directly operate on signature data without an instance of an ORDVir object.
The signature of the image, as created by the analyze( ) method.
The type of processing done to the image signature. The following operations are available:
Operation Keyword | Description |
---|---|
BYTEORDER |
Converts the signature to the natural order of the host machine, regardless of its initial state. |
An object that represents the connection to the database.
This method returns 0 if successful; otherwise, this method returns a non-zero integer.
SQLException
int i = virObj.convert(signature,"BYTEORDER",connection); if(i == 0) System.out.println("convert successful");
where:
public void copy(OrdVir dest)
Copies image data from the application ORDVir object source to a destination ORDVir object on the server.
The ORDVir object to which the data will be copied.
None.
java.sql.SQLException
//create and populate an object named virObj2 virObj.copy(virObj2);
where:
public void deleteContent( )
Deletes the media data in the BLOB in the application ORDVir object.
None.
None.
java.sql.SQLException
audObj.deleteContent( );
public void export (byte[ ] ctx[ ], String sourceType, String sourceLocation, String sourceName)
Exports the data from the application ORDVir object to the location specified in the parameters. The location is of the form sourceType://sourceLocation/sourceName
.
This method will only work if you are running Oracle database release 8.1.7 or higher.
See Chapter 4 of Oracle8i interMedia Audio, Image, and Video User's Guide and Reference for more information.
The source plug-in context information. It is set to NULL if there is no context information.
The source type to which the content will be exported. Only "FILE" is natively supported.
The location on the database server to which the content will be exported.
The source name to which the content will be exported.
None.
java.sql.SQLException
byte[ ] ctx = new byte[4000][1]; virObj.export(ctx,"FILE","IMAGEDIR","image.gif");
where:
public oracle.sql.BFILE getBFILE( )
Gets the BFILE attribute of the application ORDVir object.
None.
This method returns the BFILE.
java.sql.SQLException
BFILE imageBFILE = virObj.getBFILE( );
public String getCompressionFormat( )
Gets the compression format attribute of the application ORDVir object as a String.
None.
This method returns the compression format attribute, as a String.
java.sql.SQLException
String compression = virObj.getCompressionFormat( );
public oracle.sql.BLOB getContent( )
Gets the LOB locator from the application ORDVir object.
None.
This method returns the LOB locator of the application object.
java.sql.SQLException
BLOB localContent = virObj.getContent( );
public String getContentFormat( )
Gets the content format attribute of the application ORDVir object as a String.
None.
This method returns the content format attribute, as a String.
java.sql.SQLException
String format = virObj.getContentFormat( );
public int getContentLength( )
Gets the content length of the media data in the application ORDVir object.
None.
This method returns the content length of the media data, in bytes.
java.sql.SQLException
int length = virObj.getContentLength( );
public byte[ ] getDataInByteArray( )
Gets data from the LOB locator of the application ORDVir object and puts it in a local byte array.
None.
This method returns the byte array from which the data will be read.
java.sql.SQLException
java.io.IOException
java.lang.OutOfMemoryError
byte[ ] byteArr = virObj.getDataInByteArray( );
public boolean getDataInFile(String filename)
Gets data from the LOB locator of the application ORDVir object and puts it in a local file.
The name of the file that the data will be downloaded into.
This method returns TRUE if loading is successful; otherwise, this method returns FALSE.
java.sql.SQLException
java.io.IOException
boolean load = virObj.getDataInFile("output1.dat"); if(load) System.out.println("getDataInFile completed successfully"); else System.out.println("Error in getDataInFile");
where:
public InputStream getDataInStream( )
Gets data from the LOB locator of the application ORDVir object and puts it in a local input stream.
None.
This method returns the input stream from which the data will be read.
java.sql.SQLException
InputStream inpStream = virObj.getDataInStream( );
public String getFormat( )
Gets the format attribute of the application ORDVir object as a String.
None.
This method returns the format attribute as a String.
java.sql.SQLException
String format = virObj.getFormat( );
public int getHeight( )
Gets the height of the application ORDVir object.
None.
This method returns the height of the ORDVir object, in pixels.
java.sql.SQLException
int height = virObj.getHeight( );
public OrdImage getImage( )
Gets the application ORDVir object ORDImage object information.
None.
This method returns the ORDImage object.
java.sql.SQLException
ORDImage imgObj = virObj.getImage( );
public String getMimeType( )
Gets the MIME type of the application ORDVir object as a String.
None.
This method returns the MIME type of the ORDVir object, as a String.
java.sql.SQLException
String mime = virObj.getMimeType( );
public byte[ ] getSignature( )
Gets the signature of the application ORDVir object.
None.
This method returns the signature of the application ORDVir object.
java.sql.SQLException
byte[ ] sig = virObj.getSignature( );
public String getSource( )
Gets the application ORDVir object source information, including the source location, name, and type.
None.
This method returns a String containing the object source information.
java.sql.SQLException
String sourceName = virObj.getSource( );
public String getSourceLocation( )
Gets the application ORDVir object source location as a String.
None.
This method returns a String containing the object source location.
java.sql.SQLException
String location = virObj.getSourceLocation( );
public String getSourceName( )
Gets the application ORDVir object source name as a String.
None.
This method returns a String containing the object source name.
java.sql.SQLException
String name = virObj.getSourceName( );
public String getSourceType( )
Gets the application ORDVir object source location as a String.
None.
This method returns a String containing the object source type.
java.sql.SQLException
String type = virObj.getSourceType( );
public java.sql.Timestamp getUpdateTime( )
Gets a Timestamp object that contains information on when the application ORDVir object was most recently updated.
None.
This method returns a Timestamp object that contains the time of the most recent update.
java.sql.SQLException
Timestamp time = virObj.getUpdateTime( );
public int getWidth( )
Gets the width of the application ORDVir object.
None.
This method returns the width of the ORDVir object, in pixels.
java.sql.SQLException
int width = virObj.getWidth( );
public void importData(byte[ ] ctx[ ])
Imports data from an external source into the application ORDImage object.
The srcType, srcLocation, and srcName attributes must all be defined for this method to work.
The source plug-in context information. It is set to NULL if there is no context information.
None.
java.sql.SQLException
byte[ ] ctx = new byte[4000][1]; virObj.importData(ctx)
where:
public void importFrom(byte[ ] ctx[ ], String sourceType, String sourceLocation, String sourceName)
Imports data from an external source into the application ORDVir object. The location of the external source is of the form sourceType://sourceLocation/sourceName
.
The source plug-in context information. See Oracle8i interMedia Audio, Image, and Video User's Guide and Reference for more information.
The source type from which the data will be imported.
The source location from which the data will be imported.
The source name from which the data will be imported.
None.
java.sql.SQLException
byte[ ] ctx = new byte[4000][1]; virObj.importFrom("FILE","IMAGEDIR","testimg.dat");
where:
public boolean isLocal( )
Checks if the application ORDVir object local attribute is set.
None.
This method returns TRUE if the ORDVir object local attribute is set; otherwise, this method returns FALSE.
java.sql.SQLException
if(virObj.isLocal( )) System.out.println("local attribute is true"); else System.out.println("local attribuite is false");
public boolean loadDataFromByteArray(byte[ ] byteArr)
Loads data from the local byte buffer into the database ORDVir object LOB locator and into the application object. It also calls setLocal( ), which sets the local field of the application ORDVir object, but not the database object, and setUpdateTime(null), which sets the updateTime attribute to the SYSDATE of the database server.
The name of the local byte array from which to load data.
This method returns TRUE if loading is successful; otherwise, this method returns FALSE.
java.sql.SQLException
java.io.IOException
byte[ ] data = new byte[32000]; FileInputStream fStream = new FileInputStream("testimg.dat"); fStream.read(data,0,32300); boolean success = virObj.loadDataFromByteArray(data); if(success) System.out.println("loadDataFromByteArray was successful"); else System.out.println("loadDataFromByteArray was unsuccessful");
where:
public boolean loadDataFromFile(String filename)
Loads data from the local file into the database ORDVir object LOB locator and into the application object. It also calls setLocal( ), which sets the local field of the application ORDVir object, but not the database object, and setUpdateTime(null), which sets the updateTime attribute to the SYSDATE of the database server.
The name of the local file from which to load data.
This method returns TRUE if loading is successful; otherwise, this method returns FALSE.
java.sql.SQLException
java.io.IOException
virObj.loadDataFromFile("testimg.dat");
where:
public boolean loadDataFromInputStream(InputStream inpStream)
Loads data from the local input stream into the database ORDVir object LOB locator and into the application object. It also calls setLocal( ), which sets the local field of the application ORDVir object, but not the database object, and setUpdateTime(null), which sets the updateTime attribute to the SYSDATE of the database server.
The name of the local input stream from which to load data.
This method returns TRUE if loading is successful; otherwise, this method returns FALSE.
java.sql.SQLException
java.io.IOException
FileInputStream fStream = new FileInputStream("testimg.dat"); virObj.loadDataFromInputStream(fStream);
where:
public OrdVir( )
Creates an ORDVir object.
This method is the default ORDVir constructor.
None.
None.
None.
None.
public void process(String command)
Executes a given command on the application ORDVir object.
For more information on the commands that can be processed, see Oracle8i interMedia Audio, Image, and Video User's Guide and Reference.
The command to be executed.
None.
java.sql.SQLException
virObj.process("fileFormat=JFIF");
where:
public void processCopy(String command, OrdVir dest)
Copies data from the application ORDVir object to a destination ORDVir object and modifies the copy according to the specified command.
The command to be executed.
The object that will receive the results of the command.
None.
java.sql.SQLException
//create and populate an OrdVir object named virObj2 virObj.processCopy("maxScale=32 32, fileFormat= GIFF", virObj2);
where:
public float score(byte[ ] signature2, String attrWeights)
Compares the image signature of the application ORDVir object to the signature stored in signature2 using the weights stored in attrWeights.
The signature to be compared with the signature of the application ORDVir object.
A list of weights to apply to each visual attribute. The following attributes can be specified. You must specify a value greater than 0.0 for at least one attribute. There is no mandatory value that the weights must add to; however, it is recommended that you ensure that you are consistent with the total used in your application. The visual attributes are the following:
This method returns the score, which is a value between 0.0 and 100.0.
java.sql.SQLException
float score = virObj.score(signature2, "localcolor=1.0");
where:
public static float score(byte[ ] signature1, byte[ ] signature2, String attrWeights,
OracleConnection connection)
Compares the image signature stored in signature1 to the signature stored in signature2 using the weights stored in attrWeights.
Unlike the non-static version of this function, the static function can directly operate on signature data without an instance of an ORDVir object.
The first signature.
The second signature, which will be compared to signature1.
A list of weights to apply to each visual attribute. The following attributes can be specified. You must specify a value greater than 0.0 for at least one attribute. There is no mandatory value that the weights must add to; however, it is recommended that you ensure that you are consistent with the total used in your application. The visual attributes are the following:
An object that represents the connection to the database.
This method returns the score, which is a value between 0.0 and 100.0.
java.sql.SQLException
float score = virObj.score(signature1, signature2, "localcolor=1.0", connection);
where:
public void setCompressionFormat(String CompressionFormat)
Sets the compression format attribute of the application ORDVir object.
setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). This method will set only the attribute value; it does not change the media file itself.
The compression format to be set.
None.
java.sql.SQLException
None.
public void setContentFormat(String ContentFormat)
Sets the content format attribute of the application ORDVir object.
setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). This method will set only the attribute value; it does not change the media file itself.
The content format to be set.
None.
java.sql.SQLException
None.
public void setContentLength(int newContentLength)
Sets the content length of the media data in the application ORDVir object.
setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). This method will set only the attribute value; it does not change the media file itself.
The new content length to be set, in bytes.
None.
java.sql.SQLException
None.
public void setFormat(String Format)
Sets the format attribute of the application ORDVir object.
setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). This method will set only the attribute value; it does not change the media file itself.
The format of the contents of the ORDVir object, as a String object.
None.
java.sql.SQLException
None.
public void setHeight(int newHeight)
Sets the height of the application ORDVir object.
setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). This method will set only the attribute value; it does not change the media file itself.
The new height to be set, in pixels.
None.
java.sql.SQLException
virObj.setHeight(24);
where:
public void setImage(OrdImage image)
Sets the ORDImage object in the application ORDVir object.
setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). This method will set only the attribute value; it does not change the media file itself.
The ORDImage object to be set.
None.
java.sql.SQLException
//create and populate an OrdImage object named imgObj virObj.setImage(imgObj);
where:
public void setLocal( )
Sets the source local field of the application ORDVir object.
None
None.
java.sql.SQLException
virObj.setLocal( );
public void setMimeType(String MimeType)
Sets the MIME type of the application ORDVir object.
setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). This method will set only the attribute value; it does not change the media file itself.
The MIME type of the contents of the ORDVir object, as a String.
None.
java.sql.SQLException
virObj.setMimeType("image/bmp");
where:
public void setProperties( )
Reads the image data, extracts attributes, and sets the application ORDVir object attributes according to the values stored in the content data header.
The properties to be set include height, width, data size of the on-disk image, file type, image type, compression type, and MIME type.
None.
None.
java.sql.SQLException
virObj.setProperties( );
public void setProperties(String command)
Sets the application ORDVir object attributes according to the values stored in the given String. This method is used for foreign image files. The properties that can be set are listed in Oracle8i interMedia Audio, Image, and Video User's Guide and Reference.
The object attribute values to be set.
None.
java.sql.SQLException
String properties = "width=123 height=321 compressionformat=NONE userString=DJM dataOffset=128 scanlineorder=INVERSE pixelorder=REVERSE interleaving=BIL numberOfBands=1 defaultChannelSelection=1"; virObj.setProperties(properties);
where:
public void setSignature(byte[ ] signature)
Sets the signature of the application ORDVir object. This signature must be generated by the analyze( ) method.
setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). This method will set only the attribute value; it does not change the media file itself.
The signature to be set.
None.
java.sql.SQLException
virObj.setSignature(imgSignature);
where:
public void setSource(String sourceType, String sourceLocation, String sourceName)
Sets the application ORDVir object source information.
The type of the source.
The location of the source.
The name of the source.
None.
java.sql.SQLException
virObj.setSource("FILE","IMAGEDIR","jdoe.gif");
where:
public void setUpdateTime(java.sql.Timestamp currentTime)
Sets the update time in the application ORDVir object to the current time.
setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). This method will set only the attribute value; it does not change the media file itself.
The current time, which will be set in the ORDVir object. This value should be set to null; the method will then use the system date (SYSDATE) of the database server.
None.
java.sql.SQLException
virObj.setUpdateTime(null);
public void setWidth(int newWidth)
Sets the width of the application ORDVir object.
setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). This method will set only the attribute value; it does not change the media file itself.
The width to be set, in pixels.
None.
java.sql.SQLException
virObj.setWidth(24);
where:
public int similar(byte[ ] signature2, String attrWeights, float threshold)
Compares the image signatures in the application ORDVir object and signature2, using the weights provided. If the result of the comparison is less than or equal to the provided threshold, the images are considered a match.
The signature to be compared to the signature of the application ORDVir object.
A list of weights to apply to each visual attribute. The following attributes can be specified. You must specify a value greater than 0.0 for at least one attribute. There is no mandatory value that the weights must add to; however, it is recommended that you ensure that you are consistent with the total used in your application. The visual attributes are the following:
The value that must be attained to be considered a match.
This method returns 1 if the images match; otherwise, this method returns 0.
java.sql.SQLException
int i = virObj.similar(signature2, "localcolor=1.0", 10);
where:
public static int similar(byte[ ] signature1, byte[ ] signature2, String attrWeights, float threshold,
OracleConnection connection)
Compares the image signatures in signature1 and signature2, using the weights provided. If the result of the comparison is less than or equal to the provided threshold, the images are considered a match.
Unlike the non-static version of this function, the static function can directly operate on signature data without an instance of an ORDVir object.
The first signature.
The second signature, which will be compared to signature1.
A list of weights to apply to each visual attribute. The following attributes can be specified. You must specify a value greater than 0.0 for at least one attribute. There is no mandatory value that the weights must add to; however, it is recommended that you ensure that you are consistent with the total used in your application. The visual attributes are the following:
The value that must be attained to be considered a match.
An object that represents the connection to the database.
This method returns 1 if the images match; otherwise, this method returns 0.
java.sql.SQLException
int i = virObj.similar(signature1, signature2, "localcolor=1.0", 10, connection);
where:
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|