Вы находитесь на странице: 1из 101

interMedia API Improvements

Oracle interMedia New Features 1-1


Objectives

After completing this lesson, you should be able to:


• Use the constructor methods of the interMedia
objects
• Use the export method of the interMedia objects
• List and describe the methods of the interMedia
relational interface

Oracle interMedia New Features 1-2


Constructors

• Static methods added to ORDAudio, ORDDoc,


ORDImage, and ORDVideo to initialize these
types
• Easier to use than default constructors
• Avoid default constructors to ensure that code
will continue to work if interMedia types are
evolved in the future

Static methods have been added to each of the media types, ORDImage, ORDAudio,
ORDVideo, and ORDDoc, which allow for easy initialization of instances of these types.
Oracle recommends that you begin using the new init() method as soon as possible, as we may
evolve the interMedia object types in the future. ORDDoc is a new object type added to interMedia
in this version. It is discussed in lesson 4.

Oracle interMedia New Features 1-3


Two init Specifications

• init() sets:
– updateTime to SYSDATE
– local to 1
– LOBs to empty
– All other attributes to NULL
• init(srcType, srcLocation, srcName)sets:
– updateTime to SYSDATE
– local to 0
– LOBs to empty
– srcType, srcLocation, srcName to input
parameters
– All other attributes to NULL

The construction method is called init and can be used in one of two variations:
• The first specification takes no parameters and initializes all the media type's attributes to
NULL, with the exceptions noted on the slide. Use this method if you intend the media
source to be local, and you intend to populate the BLOB by a mechanism other than the
import method
• The second variation takes three string parameters and sets the attributes as noted on the
slide. Use this method if you intend the media source to be external, or you intend to
populate the BLOB by the import method.
The local variable indicates where the data is stored. If 1, then the data is stored in a LOB in the
database. A zero indicates that the data is stored in an external source location.

Oracle interMedia New Features 1-4


Constructors: SQL Example

INSERT
INSERT INTO
INTO mediatable
mediatable VALUES
VALUES ((
3154,
3154,
ORDSYS.ORDImage.init
ORDSYS.ORDImage.init ((
'FILE','MEDIADIR',
'FILE','MEDIADIR',
'product3154.jpg'),
'product3154.jpg'),
ORDSYS.ORDAudio.init(),
ORDSYS.ORDAudio.init(),
...
... );
);

Inserts a row with:


• ID = 3154
• An image column that points to the file ‘product3154.jpg in the Oracle
directory, MEDIADIR
• An audio column initialized to an empty audio
MEDIADIR is an Oracle directory object created with the CREATE OR REPLACE
DIRECTORY command. It points to a file system directory accessible to the Oracle server.

Oracle interMedia New Features 1-5


Export

• The export method existed in earlier versions


for source plugins only
• Now export works for srcType FILE
• Similar to a file copy operation
– The original data in the BLOB is not
touched
– clearLocal is not called
– Data still assumed to be local
• Call the deleteContent method after export
to free up BLOB storage if desired

Export now works for srcType FILE. The semantics for export are as follows:
• It is similar to a file copy operation. That is, the original data stored in the BLOB is
not touched other than for reading purposes.
• It is not an exact mirror operation to import(), because clearLocal() is not
called automatically by export() whereas import() calls setLocal().
If your intent is to no longer manage the multimedia data within the database after the
export() method is used but you do intend to continue to reference the multimedia
data, such as a BFILE, then you should call deleteContent() to free up the BLOB
storage and clear the local flag.

Oracle interMedia New Features 1-6


Export

• Requires a directory object the user is


privileged to access
• Requires DBMS_JAVA.GRANT_PERMISSION to
specify which files a user may write to

The ability to write a file on the database server is a powerful one. This ability could
potentially be used in malicious ways. One might attempt to overwrite critical database
files or simply write large or numerous files in order to fill the server's disks.
Because of these possibilities certain privileges must be in place before export() will
work for a user:
• export() will only write to an Oracle directory object the user has privilege to
access. That is, a directory the user has either created themselves with the SQL
CREATE DIRECTORY command or one that they have been granted read privileges
on.
• To further restrict which files can be written to,
DBMS_JAVA.GRANT_PERMISSIONmust be used to specify which files can be
written to

Oracle interMedia New Features 1-7


Export: Example

1. Create an Oracle Directory object


CREATE
CREATE OR
OR REPLACE
REPLACE DIRECTORY
DIRECTORY MEDIADIR
MEDIADIR
AS
AS 'C:\MEDIAFILES';
'C:\MEDIAFILES';

2. Make the Oracle directory accessible to the user

GRANT
GRANT READ
READ
ON
ON DIRECTORY
DIRECTORY MEDIADIR
MEDIADIR
TO
TO mediauser
mediauser
WITH
WITH GRANT
GRANT OPTION;
OPTION;

MEDIADIR is an Oracle directory object created with the CREATE OR REPLACE


DIRECTORY command. It points to a directory accessible to the Oracle server, in this case
C:\MEDIAFILES.

Oracle interMedia New Features 1-8


Export: Example

3. Grant file permission to the user

CALL
CALL DBMS_JAVA.GRANT_PERMISSION
DBMS_JAVA.GRANT_PERMISSION ((
'MEDIAUSER',
'MEDIAUSER',
'java.io.FilePermission',
'java.io.FilePermission',
'C:\MEDIAFILES\product3145.wav',
'C:\MEDIAFILES\product3145.wav',
'write'
'write' );
);

This call allows the user MEDIAUSER to write the file product3145.wav to the specified
file system directory.
See the Oracle9i Java Developer’s Guide, Security and Performance for more information.

Oracle interMedia New Features 1-9


Export: Example
4. Call the export method

DECLARE
DECLARE
aud
aud ORDSYS.ORDAudio;
ORDSYS.ORDAudio;
ctx
ctx RAW(4000)
RAW(4000) :=
:= NULL;
NULL;
BEGIN
BEGIN
SELECT
SELECT audio
audio INTO
INTO aud
aud
FROM
FROM mediatable
mediatable WHERE
WHERE NN == 3145;
3145;
aud.export
aud.export (ctx,'FILE',
(ctx,'FILE',
'MEDIADIR','product3145.wav');
'MEDIADIR','product3145.wav');
END;
END;
//

Exports the audio data stored in the audio column of the MEDIATABLE table to the file
product3145.wav in the file system directory pointed to by the Oracle directory
MEDIADIR.

Oracle interMedia New Features 1-10


Relational Interface

Why use the relational interface?


• You already have large stores of multimedia
data stored in BLOBs or BFILEs
• You have an existing application that uses
media data in BLOBs or BFILEs but you want
the features of interMedia

Application developers, who created multimedia applications without using the interMedia objects
to store and manage media data in database tables and who do not want to migrate their existing
multimedia applications to use interMedia objects, can use the interMedia relational interface for
storing and managing their media data.

Oracle interMedia New Features 1-11


Relational Interface Methods

• For ORDAudio, ORDDoc, ORDImage, and


ORDVideo:
– export: export data from BLOB to file
system
– importFrom: import data from FILE to
BLOB
– getProperties: extract properties from
media for known formats
• For images:
– process: convert, cut, scale, etc in place
– processCopy: convert, cut, scale, etc and
copy to destination image

The interMedia relational interface consists of a set of methods for:


• Extracting information directly from media data
• Processing and copying image data
• Loading the media data into the Oracle database
• Exporting media data from the Oracle database into operating system files
The primary benefit of using the interMedia relational interface is to let application developers who
store media in BLOBs take advantage of interMedia functionality requiring only minimal changes to
their applications and no changes to their schemas.
The Oracle interMedia relational interface contains a set of static methods for the interMedia objects:
ORDAudio, ORDDoc, ORDImage, and ORDVideo.

Oracle interMedia New Features 1-12


Relational Interface Guidelines

• Create a table with a media column of type


BLOB
• Add columns for any metadata you wish to
store for each media column. For example:
– Mime type
– Length
– Image height and width
– CLOB to hold XML formatted metadata
• Call interMedia static object methods passing
the media BLOB and metadata column values

Rather than storing media in interMedia object columns, users store media in BLOB columns and
metadata in separate table columns. It is up to the application to associate media with metadata
when interMedia object types are not used to manage the association for you.

Oracle interMedia New Features 1-13


Summary

In this lesson, you should have learned how to:


• Use the constructor methods of the interMedia
objects
• Use the export method of the interMedia objects
• List and describe the methods of the interMedia
relational interface

Oracle interMedia New Features 1-14


interMedia Java API Enhancements

Oracle interMedia New Features 2-1


Objectives

After completing this lesson, you should be able to:


• List the changes in the Oracle9i interMedia Java
API
• List and describe the classes used for accessing
interMedia objects from the Java Advanced
Imaging (JAI) API
• Describe how to access interMedia objects from
the Java Media Framework (JMF) API
• List the interMedia Java Classes for Servlets and
JSPs

Oracle interMedia New Features 2-2


interMedia Java API

• Allows Java applications to select and operate


on result sets containing interMedia object
columns plus other relational data
• Supports JDBC access to rich content
• Enables access to object attributes and
invocation of object methods
• Works with version 8.1.5 or higher

Oracle interMedia Java Classes enable Java applications to manipulate and modify audio, document,
image, and video data stored in Oracle9i.
Applications connect to the database, select the media object, copy that object from the database,
perform various operations and store the new media object in Oracle9i.
interMedia Java Classes support JDBC access to rich content. This support enables applications to
select and operate on a result set that contains sets of interMedia columns plus other relational data.
These classes also enable access to object attributes and invocation of object methods.
The new interMedia Java Classes work with an Oracle8i Server, version 8.1.5 or higher.

Oracle interMedia New Features 2-3


interMedia Java API
Differences from Earlier APIs
• No longer necessary to bind an application’s
copy of object to database object
• No longer necessary to flush and refresh
application’s copy to keep in synch.
• All methods, except those that load data from
an external data source into the BLOB, only
change the state of the application's copy of
the object
• Some APIs have been dropped from the new
Java classes
• Some APIs have been changed in minor ways

To support JDBC, changes have been made to the interMedia Java classes' syntax and semantics.
It is no longer necessary to explicitly bind an application's copy of the object to a database object. It
is also no longer necessary to refresh and flush the application's copy of the object to synchronize it
with the corresponding database object. Instead, users retrieve interMedia objects in their Java
programs using the standard JDBC executeQuery() function call.
Rather than flushing the application's copy of the object to the database, an explicit update is
performed by executing a standard SQL UPDATE statement using the JDBC API.
Another fundamental change is that all methods, with the exception of those that load data from an
external data source into the BLOB, change the state of the application's copy of the object. The user
must perform an explicit update as mentioned above in order to propagate changes to the database
object.

Oracle interMedia New Features 2-4


interMedia Java API: Example

while(rs.next())
while(rs.next()) {{
OrdAudio
OrdAudio audObj
audObj == (OrdAudio)
(OrdAudio)
rs.getCustomDatum(2,OrdAudio.getFactory());
rs.getCustomDatum(2,OrdAudio.getFactory());
audObj.setProperties(ctx);
audObj.setProperties(ctx);
OraclePreparedStatement
OraclePreparedStatement stmt1
stmt1 ==
(OraclePreparedStatement)conn.prepareCall(
(OraclePreparedStatement)conn.prepareCall(
"UPDATE
"UPDATE taud
taud SET
SET aud
aud == ?? WHERE
WHERE nn == "" ++ index);
index);
stmt1.setCustomDatum(1,audObj);
stmt1.setCustomDatum(1,audObj);
stmt1.execute();
stmt1.execute();
stmt1.close()
stmt1.close() ;;
}}

This example does the following;


• Gets the next row from a result set
• Populates an application audObj from the audio column of the row
• Calls the setProperties method to extract properties from the audio and populate
object attributes with this metadata
• Updates the database object with the extracted attributes
The CTX parameter allows users to write their own source plugins to support sources other
than the natively supported FILE and URL, including their own format plugins to support
file formats other than those natively supported by interMedia. Not all source and format
plugins will use a CTX parameter, but if you write your code this way you should work
with future user-written plugins.

Oracle interMedia New Features 2-5


interMedia Java API
Configuration Information
• Java environment must be correct and set up
to compile and run Java programs
• CLASSPATH must contain:
– JDK classes
– interMedia Java library in
$ORACLE_HOME/ord/jlib/ordim.zip
– JDBC and SQLJ runtime libraries
• Location of the JDBC OCI shared library must
be specified in:
– Unix LD_LIBRARY_PATH
– Windows NT PATH
• For details, see
$ORACLE_HOME/ord/im/admin/README.txt

Oracle interMedia New Features 2-6


interMedia Java API
Known Problems and Restrictions
• You must recompile your existing interMedia
Java applications after installing Oracle9i. If
you don’t want to recompile now, use
$ORACLE_HOME/ord/jlib/81/ordim817.zip
• The deprecated getCustomDatum API is used,
so ignore “uses a deprecated API” warnings
• interMedia Java Classes for Oracle9i will not
work with earlier versions of the Oracle Server
• For details, see
$ORACLE_HOME/ord/im/admin/README.txt

Oracle interMedia New Features 2-7


Java Advanced Imaging (JAI) API

• Extends the Java platform with services for


developing still image processing applications
and applets in Java
• Streamlines the process of creating powerful
imaging software solutions

Oracle interMedia New Features 2-8


interMedia BFILE and BLOB Stream
Adaptors for JAI

• Allow client applications using JAI to manipulate


image data stored in Oracle9i interMedia
• Includes the following methods:
– BfileInputStream: a SeekableStream that
reads from an Oracle BFILE
– BlobInputStream: a SeekableStream that
reads from an Oracle BLOB
– BlobOutputStream: an OutputStream that
writes to an Oracle BLOB

Stream Adaptors for JAI


Oracle’s BFILE and BLOB Stream Adaptors for JAI will allow client applications using Java
Advanced Imaging to manipulate image data stored in Oracle9i interMedia. It includes the methods
listed below.
BfileInputStream
This is a SeekableStream that reads from an Oracle BFILE.
This class uses buffering while reading from the BFILE. The simple constructor, that takes just a
BFILE as an argument, uses a default buffer size that should be suitable for most streams; however,
users can specify any buffer size desired using an alternate constructor.
BlobInputStream
This is a SeekableStream that reads from an Oracle BLOB
This class uses buffering while reading from the BLOB. The simple constructor, that takes just a
BLOB as an argument, queries the BLOB for the ideal buffer size; however, users can specify any
buffer size desired using an alternate constructor.
BlobOutputStream
This is an OutputStream that writes to an Oracle BLOB.
This class buffers writes to the underlying BLOB. The simple constructor, that takes just a BLOB as
an argument, queries the BLOB for the ideal buffer size to use for writing; however, users may
specify any buffer size desired using an alternate constructor.

Oracle interMedia New Features 2-9


Java Media Framework (JMF) API

• Extends the Java platform for incorporating


audio, video, other time-based media into Java
applications and applets.
• Is an optional package which extends the
multimedia capabilities in the J2SE platform.

Oracle interMedia custom DataSource and DataSink classes are an extension to the current
Java Media Framework (JMF) version 2.0/2.1 developed by Sun Microsystems.

Oracle interMedia New Features 2-10


interMedia DataSource and DataSink
for JMF
• Available on OTN
• Allow client applications using JMF to:
– Upload time-based media to Oracle9i interMedia
– Retrieve time-based media from Oracle9i
interMedia
• Use interMedia custom DataSource and DataSink:
– Register interMedia by adding oracle.ord to the
JMF Content Prefix List and Protocol Prefix List
– Use the correct Media Locator String
– The syntax for the locator string is:
im://[<driverType>/]<jdbcConnectString>
/<user>:<password>/<queryString>

Oracle interMedia custom DataSource and DataSink classes are an extension to the current
Java Media Framework (JMF) version 2.0/2.1 developed by Sun Microsystems. This software allows
a JMF application to upload and retrieve time-based media data stored in Oracle9i using interMedia
ORDAudio and ORDVideo objects. A protocol is defined that permits media data stored in an
Oracle database to be accessed through a URL that contains information necessary to select the
multimedia data from the database.
This feature is available on Oracle Technology Network. It is not available on the Oracle9i beta kit.
See technet.oracle.com for more information.
See www.java.sun.com/jmffor more information on Java Media Framework.

Oracle interMedia New Features 2-11


interMedia Java Classes for
Servlets and JSPs
• Classes that facilitate:
– Retrieval of multimedia data from Oracle9i
– Upload of multimedia data to Oracle9i
• Used with Java Servlets and JavaServer Pages
(JSPs)

Oracle interMedia New Features 2-12


interMedia Java Classes for
Servlets and JSPs
• OrdHttpResponseHandler facilitates retrieval
of multimedia data from Oracle9i from a Java
Servlet
• OrdHttpJspResponseHandler facilitates
retrieval of multimedia data from Oracle9i for
JavaServer Pages
• OrdHttpUploadRequest facilitates processing
of POST requests by Java Servlets and
JavaServer Pages
• OrdHttpUploadFile facilitates uploading
media data into an Oracle9i database

OrdHttpResponseHandler
This class helps with retrieval of multimedia data from the database and delivery to a browser or
other HTTP client from a Java Servlet.
OrdHttpJspResponseHandler
This class performs a similar function for JavaServer pages.
OrdHttpUploadRequest
The class enables form-based file uploading using HTML forms, encodes form data, and uploaded
files in POST requests using multipart/form-data format. This class facilitates the processing of such
POST requests by parsing the POST data and making the contents of regular form fields and the
contents of uploaded files readily accessible to a Java Servlet or JSP.
OrdHttpUploadFile
This class facilitates the handling of uploaded files. Provides an easy to use API that can load image,
audio and video data into a database.

Oracle interMedia New Features 2-13


Classes for Servlets and JSPs
Known Problems and Restrictions
• JSP engines are not required to support
access to the servlet binary output stream.
• Multimedia data must be delivered using a
binary output stream, therefore, all JSP
engines do not support the delivery of
multimedia data using the
OrdHttpJspResponseHandler class.
• If your JSP engine does not support access to
the binary output stream from within a JSP,
then you must use a servlet to deliver
multimedia data.

JSP engines are not required to support access to the servlet binary output stream. Therefore, all JSP
engines do not support the delivery of multimedia data using the
OrdHttpJspResponseHandlerclass.
All multimedia data stored in the database using the interMedia types, including text documents
stored using the ORDDOC type, is stored using a binary LOB data type. Therefore, all multimedia data
is delivered to the browser through the servlet binary output stream.
All send methods in the OrdHttpJspResponseHandlerclass mirror the initial processing of
the jsp:forward tag by calling the JspWriter.clear method to clear the page's output buffer
prior to obtaining the binary output stream. However, JSP engines are not required to support a call to
the ServletResponse.getOutputStreammethod from within a JSP.
If your JSP engine does not support access to the binary output stream from within a JSP, then you
must use a servlet to deliver multimedia data. For example:
- Use the jsp:forward tag to forward a multimedia retrieval request to a servlet, or
- Construct multimedia retrieval URLs to retrieve the data directly from a servlet.

Oracle interMedia New Features 2-14


Summary

In this lesson, you should have learned how to:


• List the difference in the Oracle9i interMedia Java
API
• List and describe the classes used for accessing
interMedia objects from the Java Advanced
Imaging (JAI) API
• Describe how to access interMedia objects from
the Java Media Framework (JMF) API
• List the interMedia Java Classes for Servlets and
JSPs

Oracle interMedia New Features 2-15


interMedia Image Processing Enhancements

Oracle interMedia New Features 3-1


Objectives

After completing this lesson, you should be able to:


• Describe the Java Advanced Imaging API (JAI)
image processing engine functionality
• List the new formats supported, new attribute
values and changes to existing processing verbs
with JAI
• Describe interMedia image matching functionality

Oracle interMedia New Features 3-2


JAI as an Image Processing Engine

• A modern imaging library


• Adds image processing capabilities to Java
• Is essentially the same as the Oracle8i PL/SQL
interface to ORDImage
• Includes support for popular new image
formats
• Is easy to extend with new format support

The Java Advanced Imaging API extends the Java platform for developing image processing
applications and applets in Java. It streamlines the process of creating powerful imaging software
solutions.
This interface is essentially the same as the Oracle8i PL/SQL interface to ORDImage. All the
additional formats will be supported through this interface, and additional verbs will be added to
the Process() methods. The SetProperties() method will also use the new functionality,
and so image object attribute values will include new values supported by JAI. The PL/SQL
methods will still mostly be forwarding functions, but they will now forward the calls into Java and
JAI.

Oracle interMedia New Features 3-3


New Formats Supported by JAI

• EXIF: Digital Still Camera Image


• PNG: Portable Network Graphics
• FPX: FlashPix
• PNM
– PBM: Portable Bitmap
– PGM: Portable Graymap
– PPM: Portable Pixmap
• WBMP: Wireless Bitmap Image

The EXIF format is essentially a variation on the JFIF format and as such the
ORDImage.setProperties()method sets the fileFormat attribute to JFIF.

Oracle interMedia New Features 3-4


Changes to ORDImage Processing Verbs

• FileFormat: new values allowed


• ContentFormat: new values allowed, except
special attribute suffixes (A,T)
• CompressionFormat : additional values
allowed
• ScanlineOrder: now valid for BMPF output
• Interleave is deprecated, functionality
subsumed into ContentFormat

See previous slides for new allowed values for fileFormat, contentFormat, and
compressionFormat.
The following values are not allowed for compressionFormat on process and
processCopy:
• JPEG-PROGRESSIVE
• GIFLZW-INTERLACED
• DEFLATE-ADAM7

Oracle interMedia New Features 3-5


Changes to ORDImage Attribute Values

• fileFormat additional values: FPIX, PNGF, PBMF,


PGMF, PPMF, WBMP
• contentFormat is MONOCHROME or a
concatenation of:
– Sample depth: 1BIT, 2BIT, 4BIT, 8BIT, 12BIT,
16BIT, 24BIT, 32BIT, 48BIT
– Sample model: BIP, BIL, BSQ
– Color model: LUT, DRCT
– Color space: GRAY, RGB
– Special attributes suffix: A, T
• compressionFormat additional values: DEFLATE,
DEFLATE-ADAM7, ASCII, RAW, JPEG-PROGRESSIVE,
GIFLZW-INTERLACED

ContentFormat
The following lists provides additional information related to the slide.
• The format MONOCHROME is two levels off black and white.
• Sample model definitions are:
– BIP: band interleaved by pixel (optional and default)
– BIL: band interleaved by line
– BSQ: band sequential
• Color model definitions are:
– LUT: pixel values are indices into a lookup table
– DRCT: pixel values directly encode color values (optional and default)
• Color space definitions are:
– GRAY: Grayscale
– RGB: Red/Green/Blue additive
• Special attributes suffix definitions are:
– A: contains an alpha channel
– T: contains a transparency color
• CompressionFormat definitions includes:
– DEFLATE: ZIP Deflate (used by PNG)
– DEFLATE-ADAM7: Interlaced ZIP Deflate (used by PNG)
– ASCII: ASCII encoding for PNM types
– RAW: Binary encoding for PNM types
– JPEG-PROGRESSIVE: Interlaced JPEG
– GIFLZW-INTERLACED: Interlaced GIF
Oracle interMedia New Features 3-6
Image Matching Concepts

• Massive collections of digital images are being


collected
• Difficulty of finding relevant images is increasing
• Two general approaches use metadata for image
retrieval:
– Manually enter metadata that can be searched
– Automate image feature extraction and object
recognition, called content-based retrieval
• With interMedia image, you can combine both
approaches

Inexpensive image-capture and storage technologies have allowed massive collections of digital
images to be created. However, as a database grows, the difficulty of finding relevant images
increases. Two general approaches to this problem have been developed, both of which use
metadata for image retrieval:
• Using information manually entered or included in the table design, such as titles,
descriptive keywords from a limited vocabulary, and predetermined classification
schemes
• Using automated image feature extraction and object recognition to classify image
content; that is, using capabilities unique to content-based retrieval
With interMedia image, you can combine both approaches in designing a table to accommodate
images: use traditional text columns to describe the semantic significance of the image. For
example, that the pictured automobile won a particular award, or that its engine has six or eight
cylinders), and use the ORDImage type for the image, to permit content-based queries based on
intrinsic attributes of the image. For example, how closely its color and shape match a picture of a
specific automobile.

Oracle interMedia New Features 3-7


Image Matching
Example Applications
• Content-based retrieval is useful for
performing queries similar to: find objects that
look like this one
• Examples:
– Trademarks, copyrights, and logos
– Art galleries and museums
– Retailing
– Fashion and fabric design
– Interior design or decorating

A Web-based interface to a retail clothing catalog might allow users to search by traditional
categories, such as style or price range, and also by image properties, such as color or texture.
Thus, a user might ask for formal shirts in a particular price range that are off-white with pin
stripes. Similarly, fashion designers could use a database with images of fabric swatches, designs,
concept sketches, and finished garments to facilitate their creative processes.

Oracle interMedia New Features 3-8


Image Matching: How Content-Based
Retrieval Works: Generating a Signature
• signature: an abstraction of an image’s
content in terms of visual attributes
• Queries deal with this abstraction, or signature
• Signature contains information about color,
texture, shape, and distribution of color
• A new object type, ORDImageSignature ,
contains the signature data
• A generateSignature method on the
ORDImageSignature object generates the
signature based on the input image stored in
an ORDImage object

A content-based retrieval system processes the information contained in image data and creates
an abstraction of its content in terms of visual attributes. Any query operations deal solely with
this abstraction rather than with the image itself. Thus, every image inserted into the database is
analyzed, and a compact representation of its content is stored in a feature vector, or signature.
The signature contains information about the following visual attributes:
• Color represents the distribution of colors within the entire image. This distribution
includes the amounts of each color, but not the locations of colors.
• Texture represents the low-level patterns and textures within the image, such as
graininess or smoothness. Unlike shape, texture is very sensitive to features that appear
with great frequency in the image.
• Shape represents the shapes that appear in the image, as determined by shape-
characterization techniques such as edge detection.
• Location represents color distributions and where they occur in an image, such as the fact
that a red-green-blue (RGB) vector for sky blue occurs in the upper half of an image.

Oracle interMedia New Features 3-9


Image Matching: How Content-Based
Retrieval Works: Matching Images

• Assign an importance measure, or weight, to


each visual attribute
• interMedia calculates an image difference, or
score, for each visual attribute by comparing
image signatures. Smaller score means closer
match.
• The overall score of the two images is the
weighted sum of each attribute

Images in the database can be retrieved by matching them with a comparison image. The
comparison image can be any image inside or outside the current database, a sketch, an
algorithmically generated image, and so forth. The matching process requires that signatures be
generated for the comparison image and each image to be compared with it. Images are seldom
identical, and therefore matching is based on a similarity-measuring function for the visual
attributes and a set of weights for each attribute. The score is the relative distance between two
images being compared. The score for each attribute is used to determine the degree of similarity
when images are compared, with a smaller distance reflecting a closer match.
When you match images, you assign an importance measure, or weight, to each of the visual
attributes, and interMedia image calculates a similarity measure for each visual attribute.
The similarity measure for each visual attribute is calculated as the score or distance between the
two images with respect to that attribute. The score can range from 0, indicating no difference, to
100, indicating the maximum possible difference. Thus, the more similar two images are with
respect to a visual attribute, the smaller the score will be for that attribute.

Oracle interMedia New Features 3-10


Image Matching: Example

The example on the following pages illustrates:


• Creating a table with image and signature
columns
• Inserting rows into the image table
• Generating a signature by:
– Selecting a row
– Extracting image properties
– Generating an image signature
– Updating the row with the image properties
and the generated signature
• Finding all images that match a query image

Oracle interMedia New Features 3-11


Image Matching Example:
Create a Table
• Create the table with image and signature columns
CREATE
CREATE TABLE
TABLE image_tab
image_tab ((
photo_id
photo_id NUMBER,
NUMBER,
photo
photo ORDSYS.ORDImage,
ORDSYS.ORDImage,
photo_signature
photo_signature
ORDSYS.ORDImageSignature,
ORDSYS.ORDImageSignature, ...)
...)
• Insert rows of images
INSERT
INSERT INTO
INTO image_tab
image_tab VALUES
VALUES ((
1,
1, ORDSYS.ORDImage.init(...),
ORDSYS.ORDImage.init(...),
ORDSYS.ORDImageSignature.init(),
ORDSYS.ORDImageSignature.init(),
...);
...);

The signature and image are stored as separate columns of the table.

Oracle interMedia New Features 3-12


Image Matching: Generating a Signature
• Call setProperties() and generateSignature()
SELECT
SELECT t.photo,
t.photo, t.photo_signature
t.photo_signature
INTO
INTO myimg,
myimg, mysig
mysig
FROM
FROM image_tab
image_tab tt
WHERE
WHERE t.photo_id
t.photo_id == 11 FOR
FOR UPDATE;
UPDATE;

myimg.setProperties();
myimg.setProperties();
mysig.generateSignature(myimg);
mysig.generateSignature(myimg);

UPDATE
UPDATE image_tab
image_tab tt
SET
SET t.photo
t.photo == myimg,
myimg,
t.photo_signature
t.photo_signature == mysig
mysig
WHERE
WHERE t.photo_id
t.photo_id == 1;
1;

The generateSignature() method generates the signatures for the images.


setProperties() must be called before the signature is generated.

Oracle interMedia New Features 3-13


Image Matching Example:
Find a Similar Image

SELECT
SELECT q.photo_id,
q.photo_id,
ORDSYS.IMGScore(123)
ORDSYS.IMGScore(123) AS
AS score
score
FROM
FROM image_tab
image_tab q,
q,
image_tab
image_tab ee
WHERE
WHERE e.photo_id
e.photo_id == '42'
'42'
AND
AND q.photo_id
q.photo_id !=!= e.photo_id
e.photo_id
AND
AND ORDSYS.IMGSimilar
ORDSYS.IMGSimilar ((
q.photo_signature,
q.photo_signature,
e.photo_signature,
e.photo_signature,
'texture=1',
'texture=1', 20.0,
20.0, 123)
123) == 1;
1;

Find PHOTO_ID and Score of Similar Images


The example on the slide selects all PHOTO_IDs, except 42, and scores for images that match
the photo with the PHOTO_ID of 42. The clause
AND q.photo_id != e.photo_id
prevents PHOTO_ID 42 from being compared to itself.
IMGSimilar returns 1, for true, if the image being compared has a score value less than the
threshold of 20.
IMGScore returns the score, or distance between the image and the comparison image. The
parameter passed to IMGScore, 123, is the reference to the IMGSimilar invocation. It is a
number that is used to link the two functions, similar to the label used in Oracle Text. If there are
multiple invocations of IMGSimilar in the same query, this parameter is used to indicate which
invocation of IMGSimilar determines the score value.
Images are determined to match based on texture only. Scores lower than 20 are considered a
match.
The number 1 is used as a Boolean to indicate true.

Oracle interMedia New Features 3-14


Image Matching Example:
Results of Finding a Similar Image
• The results of the previous query return:
– PHOTO_ID of the match row
– Score of the match
• Example output:
PHOTO_ID
PHOTO_ID SCORE
SCORE
---------
--------- ---------
---------
22 00
41
41 14
14
106
106 55

The results of the previous query indicate that the best matches for the query image. In this
example, three rows are returned with a score less than 20. The image with a PHOTO_ID of 2 is a
perfect match with a score of zero.

Oracle interMedia New Features 3-15


Image Matching: Using an Index

• Define, build and maintain an index for image


data
• Use an index type of ORDIMAGEINDEX
• Once created, the index is automatically
updated when image is inserted, removed or
modified

A domain index, or extensible index, is a new approach for supporting complex data objects.
Oracle and interMedia image cooperate to define, build, and maintain an index for image data.
This index is of type ORDIMAGEINDEX. Once it is created, the index automatically updates itself
every time an image is inserted, updated, or removed from the database table. The index is created,
managed, and accessed by routines supplied by the index type.
For better performance with large image databases, you should always create and use an index for
searching through the image signatures. The default search model compares the signature of the
query image to the signatures of all images stored in the database. This works well for simple
queries against a few images such as, "Does this picture of an automobile match the image stored
with the client’s insurance records?" However, if you want to compare that image with thousands
or millions of images to determine what kind of vehicle it is, then a linear search though the
database would be impractical. In this case, an index based on the image signatures would greatly
improve performance.

Oracle interMedia New Features 3-16


Image Matching: Using an Index
• Create the index:
CREATE
CREATE INDEX
INDEX idx1
idx1
ON
ON image_tab
image_tab (photo_signature)
(photo_signature)
INDEXTYPE
INDEXTYPE IS
IS ORDSYS.ORDIMAGEINDEX
ORDSYS.ORDIMAGEINDEX
PARAMETERS
PARAMETERS (.
(. .. .);
.);

• Compute/estimate statistics for the optimizer:

ANALYZE
ANALYZE INDEX
INDEX idx1
idx1 COMPUTE
COMPUTE STATISTICS;
STATISTICS;

The entire create index command is shown below:


CREATE INDEX idx1
ON image_tab (signature)
INDEXTYPE IS ordsys.ordimageindex
PARAMETERS (
'ordimg_data_tablespace = image_ts,
ordimg_index_tablespace = image_index_ts');
where:
• ordimg_data_tablespacespecifies the tablespace to use for the signature index data
• ordimg_index_tablespacespecifies the tablespace to use for the index on the signature
index data

Oracle interMedia New Features 3-17


Summary

In this lesson, you should have learned how to:


• Describe the JAI image processing engine
functionality
• List the formats supported by JAI and the new
attribute values and processing verbs
• Describe interMedia image matching
functionality

Oracle interMedia New Features 3-18


Using ORDDoc Object Type

Oracle interMedia New Features 4-1


Objectives

After completing this lesson, you should be able to:


• Describe the uses of the ORDDoc object
• Describe and use the attributes and methods of
the ORDDoc object
• Create and populate a table containing columns
of type ORDDoc

Oracle interMedia New Features 4-2


Why an ORDDoc Object?
• Allows for a single column that can hold any media
data, such as (image, audio, video, text, and others):
– Some applications don’t want to know about
media type
– Some applications want to build an index on
metadata for all media types
• Provides a container to hold media data and
metadata as a unit
– The data is identifiable via object type and mime
type
– Data and metadata can be stored as a unit
– Functionality associated with the object in the
form of methods

The ORDDoc object type can be used in applications that require you to store different types of
documents, such as audio, image, video, and any other type of document in the same column so
you can build a common metadata index on all the different types of documents and search across
different types of documents using this index. Note that you cannot use this same search technique
if the different types of documents are stored in different types of objects in different columns of
relational tables.
Documents may be produced by application software, text conversion utilities, speech to text
processing software, and so forth. Documents can be ASCII text files or binary files formatted by a
particular application.
Documents consist of the document data (digitized bits) and attributes that describe and
characterize the document data.
Documents can have different formats depending upon the application generating the document
data. interMedia document can store and retrieve document data of any data format. interMedia
document automatically extracts metadata from documents of known image, audio and video
formats. To automatically extract metadata from other formats, you can write your own format
plugin.

Oracle interMedia New Features 4-3


ORDDoc Attributes

CREATE
CREATE OR
OR REPLACE
REPLACE TYPE
TYPE ORDDoc
ORDDoc AS
AS OBJECT
OBJECT ((
--
-- ATTRIBUTES
ATTRIBUTES
source
source ORDSource,
ORDSource,
format
format VARCHAR2(80),
VARCHAR2(80),
mimeType
mimeType VARCHAR2(80),
VARCHAR2(80),
contentLength
contentLength INTEGER,
INTEGER,
comments
comments CLOB,.
CLOB,. .. ..
• Source: where the document is stored
• Format: the format type of the document
• Mimetype: the mime type of the document
• ContentLength: the length of the document data
• Comments: metadata in XML format

The ORDDoc object type includes the following attributes:


• Source contains information about where the document data is stored. The data may be in
a BLOB in the ORDSource object, or pointed to by source type, location and name
information stored in ORDSource. If stored externally, the data may be stored in a local
file, at a URL, or at a user-defined source.
• Format is the file format of the document. Examples include: JPG, AVI, and WAV.
• MimeType is the MIME type of the document. Examples include image/jpeg,
audio/x-wav, and video/x-msvideo.
• ContentLength is the length of the document data stored in the source
• Comments contains the extracted metadata for the document in XML form. Oracle Text
may be used to index and search this metadata field.

Oracle interMedia New Features 4-4


ORDDoc Methods

• Constructors for easy initialization of instances of


the ORDDoc object type
• Source related methods:
– Get and set the local field, the update time, and
the source information
– Import data into database BLOB
– Export from BLOB to file system
– Read, write, trim, open and close source
• Attribute related methods
– Get and set the object attributes
– Automatically extract attributes and populate the
comments field with XML attributes

Constructors
•init(): initialize with local set to 1
•init(srcType, srcLocation, srcName): initialize with local set to 0 and src
information set from the parameters passed
Source Methods
•get/setUpdateTime: get or set time document was last updated
•isLocal, setLocal, clearLocal: determines if data is local, that is, is stored in a BLOB
•setSource, getSource, getSourceType, getSourceLocation, getSourceName:
set and get source type and location information
•import, importFrom: import from file system
•export: export to file system
•getContentInLob, getContent, deleteContent: get and delete document data
•getBFILE: return a BFILE handle
•processSourceCommand: process command in source plugin
•openSource, closeSource, readFromSource, writeToSource, trimSource: file
operations on source data
Attribute Methods
•get/setMimeType
•get/setFormat
•setProperties: automatically extract properties if possible
•getContentLength

Oracle interMedia New Features 4-5


ORDDoc: Example

The example on the following slides illustrate:


• Creating and populating a table with an
ORDDoc column
• Populating properties by:
– Selecting a row
– Importing the media data from the file
system into the database
– Extracting properties from the media data
– Updating the row with the media properties

Oracle interMedia New Features 4-6


Example: Create a Table with an ORDDoc
Column
CREATE
CREATE TABLE
TABLE TDOC(
TDOC(
nn NUMBER
NUMBER
CONSTRAINT
CONSTRAINT n_pk
n_pk PRIMARY
PRIMARY KEY,
KEY,
doc
doc ORDSYS.ORDDoc
ORDSYS.ORDDoc );
);

INSERT
INSERT INTO
INTO TDOC
TDOC VALUES
VALUES (( 1,
1,
ORDSYS.ORDDoc.init
ORDSYS.ORDDoc.init ((
'FILE',
'FILE', 'DOCDIR',
'DOCDIR', 'audio.wav')
'audio.wav') );
);

INSERT
INSERT INTO
INTO TDOC
TDOC VALUES
VALUES (( 2,
2,
ORDSYS.ORDDoc.init
ORDSYS.ORDDoc.init ((
'FILE',
'FILE', 'DOCDIR',
'DOCDIR', 'image.jpg'));
'image.jpg'));

Create a table called TDOC with two columns and insert two rows. The first row points to an
audio file and the second points to an image file.

Oracle interMedia New Features 4-7


Example Import into the Database and
Extract Properties
DECLARE
DECLARE
documentObj
documentObj ORDSYS.ORDDoc;
ORDSYS.ORDDoc;
ctx
ctx RAW(4000)
RAW(4000) :=
:= NULL;
NULL;
BEGIN
BEGIN
SELECT
SELECT D.doc
D.doc INTO
INTO documentObj
documentObj FROM
FROM TDOC
TDOC DD
WHERE
WHERE D.n
D.n == 11 FOR
FOR UPDATE;
UPDATE;
documentObj.import(ctx,FALSE);
documentObj.import(ctx,FALSE);
documentObj.setProperties(ctx,TRUE);
documentObj.setProperties(ctx,TRUE);
UPDATE
UPDATE tdoc
tdoc dd
SET
SET d.doc
d.doc == documentObj
documentObj
WHERE
WHERE d.n
d.n == 1;
1;
COMMIT;
COMMIT;
END;
END;
//

The code example on the slide performs the following functions:


• Select the row with document number of 1
• Import from the file system into the database blob
• Call setProperties to automatically extract attributes and generate the XML
metadata
• Update the row to store the generated metadata and attribute values

Oracle interMedia New Features 4-8


Summary

In this lesson, you should have learned how to:


• Describe the uses of the ORDDoc object
• Describe and use the attributes and methods of
the ORDDoc object
• Create and populate a table containing columns
of type ORDDoc

Oracle interMedia New Features 4-9


interMedia Utilities

Oracle interMedia New Features 5-1


Objectives

After completing this lesson, you should be able to:


• Describe new interMedia Clipboard V2.0
capabilities
• Describe changes from previous release
• Navigate the new Clipboard User Interface

Oracle interMedia New Features 5-2


Completely Revised Clipboard Utility

• Browser-based user interface replaces current


thick client utility
• Store and retrieve multimedia data in any schema
• Organize media data as files within folders
• View media data separately in different views:
Image, Audio, and Video
• Annotate media automatically during upload
• Authenticate users and apply security controls
• Single installation per server for all users.

interMedia Clipboard for Oracle 8.1.6 and higher allows users to store and retrieve multimedia data
stored in any schema quickly and easily through a browser. The interface uses interMedia Annotation
Services to automatically annotate multimedia objects and store annotations in a CLOB when they are
loaded in the database, and to view annotations. This means users can use a single interMedia utility
to:
• Upload and download files using a browser interface
• Create and view media annotations
The Java Servlet implementation of the interMedia Clipboard for Oracle9i provides the benefit of a
single installation per server for all users.
Clipboard users can organize media data as files within hierarchically folders in the database, and have
the capability to:
• Create new folders
• Move, copy, or delete folders and files
Clipboard allows users to apply file access controls to files and folders, and authenticates users before
allowing access to protected files and folders. Clipboard support for Access Control Lists (ACLs)
allows users to:
• Grant or Deny rights to files and folders
• Read (download), and write (upload, delete, move, copy) to files
• Read and write ACLs

Oracle interMedia New Features 5-3


Changes from Previous Clipboard Release

The following activities are handled differently with


the latest release of the Clipboard:
• Viewing the organization of media data in Oracle9i
• Automatic URL generation
• Drag and drop into authoring tools
• Direct access to media from Twain devices
• Editing media in the database
• Authentication for Database Agent
• Sort order for table rows
• DELETE, UPDATE, and INSERT a row

Media data previously viewed as tables is now viewed hierarchically as files within folders that can be
created by users.
Automatic URL generation to retrieve an object from the database previously occurred when
multimedia was dragged into a Web authoring tool. Now, the Clipboard displays the URL for each
media object, which can be copied into an Web authoring tool. Media objects can no longer be
dragged from Clipboard into Web Authoring tools
Images from Twain compliant external sources, such as digital cameras and scanners, can no longer
captured directly by Clipboard for storage in the database. Store the image in a file and load the file
using Clipboard.
Previously, multimedia objects were edited within Clipboard. Now, edit media objects in the database
directly using DAV compliant editing tools or use Clipboard to download the media into a file, edit the
media and then reload the file into the database with Clipboard.
The Web Agent is no longer needed to access multimedia data, as the Clipboard can either generate its
own URLs for access through the servlet or use DAV URLs. Web Agent authentication has been
replaced by Authentication/Authorization plus access control lists (ACLs) for all files and folders. The
code wizard that created PL/SQL procedures to retrieve and store multimedia objects in the database
and set attributes of the object is no longer necessary.
Sort order for table has been replaced by Sorting of folders by type, size, date, name and delete,
update, insert row are replaced by delete, update, insert file.

Oracle interMedia New Features 5-4


Clipboard Installation and Configuration

• Clipboard configuration file enables one to specify


database, schema for default file storage
• A set of PL/SQL procedures enable exposure of
existing interMedia objects and BLOBs, in any
schema, as files in the Clipboard
• admin user with administration privileges created
by default at installation time
• Online administration page allows admin user to
add, delete, modify, and view Clipboard users
• Clipboard users may add, delete or modify ACLs
depending on rights granted to them

At installation time, the administrator must specify the database name, schema name, and whether to
expose annotation capability to end users in a configuration file which is stored on the web server.
A set of PL/SQL procedures provided in the Clipboard package or a browser-based wizard accessible
through the Administration page can be used to expose already existing interMedia objects
(ORDImage, ORDAudio, ORDVideo, ORDDoc) or BLOBs in any table and schema as files with
associated URLs in the Clipboard.
Once the clipboard has been properly installed, a user name admin (default password
manager)with administration privileges will already exist. admin is the only user which may
access the online Administration page, which allows the admin user to add, delete, modify, or view
Clipboard users. Initially, the Clipboard will not be enabled for security, meaning no ACLs may be
created anywhere. However, admin can easily enable security by visiting the admin page, and
clicking on a link which will enable security.
Once security has been enabled, all users have read, write, read ACL, and write ACL access to all files
and folders in the Clipboard. It is up to the admin user to set up the proper ACLs on existing folders.

Oracle interMedia New Features 5-5


interMedia Clipboard User Interface

• Links and buttons access all functionality


• Sort display based on name, size, type, and date

The clipboard user interface is similar to other interfaces to directories and files:
• An icon identifies whether an item is a folder or file, that is, the icons identify files of different
types.
• Each file is represented by a hyperlink of the URL which accesses the corresponding multimedia
data in the database.
• Each folder can contain folders and files. Thus, you can have a multilevel hierarchy of folders.
For example, the top-level folder, which is the view of the entire container, contains a folder,
which contains another folder, which contains another folder, and so on.
• To select a folder or file to perform an operation on it, click the box to the left of its icon or its
name. To deselect a selected item, click the box. You can select all items in a folder by clicking
Check All, and deselect all items in a folder by clicking Uncheck All.
• To perform an operation on a folder or file, select it, and then click the appropriate command
text link or button.
• To view Annotations for a file, click on the pencil. A pencil with a small plus sign indicates that
the file has been annotated.
• To add, delete, modify, or view the ACL for a file or folder, click on the pencil.
The window on the slide displays the contents of a single folder.

Oracle interMedia New Features 5-6


View Media by Type: Image, Audio, Video,
or All Media

The Clipboard provides four different views of your multimedia data. By clicking on one of the four
tabs in the upper-right corner of the Clipboard interface, you can view either images, audio, video or
all of your media in one view. Navigation through folders and sorting is available in each media view.

Oracle interMedia New Features 5-7


Example: Exposing interMedia Objects

This Clipboard in the example screen has been configured so that a column of ORDImage objects
have been exposed.
Once the objects have been exposed, they can be copied, downloaded or deleted. Support for other
operations, such as move and update, are planned for future releases. Either a whole column of objects
or a single object can be exposed.
An option to create triggers so that any update, insert, or delete into the external table will update the
corresponding Clipboard information is provided.
As seen in the screen, the ORDImage objects appear as image files in the Clipboard folder
HOUSE_PIX. The image media data can be downloaded via the Clipboard URLs.
The Clipboard maintains a table of paths, each of which represents the path of a folder or file viewable
from the Clipboard. Therefore, each ORDImage has an associated path stored in the table.

Oracle interMedia New Features 5-8


Example: Exposing interMedia Objects

ORDImage objects located in table HOUSES, column


HOUSE_PIX in schema SCOTT

The screen shows the database table and column where the images in the HOUSE_PIX folder reside.
The HOUSES table is located in the SCOTT schema. The HOUSE_PIX column of ORDImage
objects in the HOUSES table has been exposed through the Clipboard as Clipboard image files.

Oracle interMedia New Features 5-9


Accessing Media Data via URLs

Every media file in the Clipboard has an associated URL which enables users to either download or
view the media object in the browser.
In this example, the file named “1002.jpg” has been clicked in the folder HOUSE_PIX. Its associated
URL is:

http://host.us.oracle.com:8014/oradav/SCOTT/HOUSES/HOUSE_PIX/100
2.jp
g
Using the URL enables users to view the media in the browser. In this case, the underlying data is
stored as an ORDImage object in the table described in previous slides. This URL can be copied and
pasted from the Location or Address toolbar in the browser to the desired web authoring tool.

Oracle interMedia New Features 5-10


Upload Functionality

This screen enables the user to upload any rich media file from the local file system. Selecting the
Browse button on the previous screen enables you to browse your file system for the appropriate
content. The Clipboard uses the OS filename for naming new files.
In the production release of the Clipboard, users will also be able to upload media from anywhere in
the Internet.
If the Annotator engine has been installed, users will be given the option to annotate the media file
transparently during the upload, by a call in the database to the Annotator engine at the end of the
upload. Depending on the configuration of the Clipboard, the annotations will be stored either as a
CLOB or parsed into name-value pairs and stored in the Clipboard properties table.
Currently, there is no support for creating new ORD objects in the database but support is being
planned for the future.
If the user would simply like to store the uploaded file as a BLOB and has not specified a table or
schema in which this file should be stored, a Clipboard table of BLOBs will be used and a new row
will be inserted into this default table. This default table will have been created at Clipboard
installation time.
Note: currently there is no limit on file size as long as the tablespace used for the Clipboard tables has
not been exceeded.

Oracle interMedia New Features 5-11


ACLs and Annotations

ACLs can be edited and viewed by clicking on the pencil icon for any file or folder.
Additionally, annotations and other properties, such as file size, last modified and creation dates, can
be viewed by first clicking on the pencil icon, then clicking on View Properties under the
Properties menu.

Oracle interMedia New Features 5-12


View Annotations

The screen shows the annotations for the file just uploaded: 1002.jpg. In this example, the
annotations have been stored as XML in a CLOB. Additional attributes, such as namespace, language,
and tag are automatically generated by the Clipboard at annotation time and stored in separate columns
in a default table in the database.
In later releases of the Clipboard, users will be able to edit annotations directly in the Clipboard
interface. Users will also be able to insert and maintain their own custom properties.

Oracle interMedia New Features 5-13


Add an ACL

Access control can be added to a specific file or folder.


There are four rights which can be granted or denied to a user:
• Read: download
• Write: upload, delete, move, or copy
• Read ACL
• Write ACL: Add, modify, or delete ACL
The admin user, by default, is granted all rights on all items in the Clipboard.
In this example, an Access Control Element (ACE ) is being added to the 1002.jpg uploaded a few
screen earlier. The ACE will deny all access to all users (*).
The Clipboard currently maintains two tables used for security: a table of users, and a table of ACLs.
The current security model is based on the current WebDAV ACL draft. Future releases of the
Clipboard will integrate with a more standardized authentication/authorization interface.

Oracle interMedia New Features 5-14


View an ACL

• Any user granted the Read ACL right on a


specific file or folder can view ACL on that item
• admin user can always view the ACL on any
item

The user in the screen has been logged in as admin, so ACLs on any item can be viewed.
As seen in the screen, all users (*) have been denied all rights on the file named 1002.jpg.

Oracle interMedia New Features 5-15


interMedia Clipboard: Denying Access

Since the 1002.jpg file has an ACL in which all users have been denied all access, anyone except
admin will be denied access to the file.
Therefore, clicking on 1002.jpg will force a username/password dialog box to appear. If you log in as
admin, you will be allowed to view the file. However, any other user will be shown a Not
Authorized page.

Oracle interMedia New Features 5-16


interMedia Clipboard: Delete ACL

• Any user granted the Write ACL right on an item


will be allowed to delete the ACE for that item
• The admin user can delete the ACE for any item

If the admin user is logged in, pressing the Delete button in the screen will delete the ACE on
1002.jpg. This means that the ACE from the previous example, in which all users have been
denied all rights, will be deleted. The admin user will be able to delete any ACE on any item, no
matter what the existing ACL on the item is.

Oracle interMedia New Features 5-17


Create Folders

You can use the Clipboard to organize your content by creating folders to organize interMedia content.
In the above example, a folder named other will be created within the HOUSE_PIX folder once the
Create folder button has been clicked.
A folder can correspond to a table; however, it is possible to have a folder contain items from various
tables. Folders are uniquely identified by their paths in the Clipboard. The path of a folder and its
content location in the database are separate.
The folder hierarchy is stored in a Clipboard table which maintains path information.

Oracle interMedia New Features 5-18


Move and Copy

This screen is used to move or copy multiple files and folders in a single operation.
The 1002.jpg can be moved or copied to any folder to which the current user has Write access.
Moving the file will simply change the Clipboard path of the file. For example, if 1002.jpg is
moved from /oradav/SCOTT/HOUSES/HOUSE_PIXto
/oradav/SCOTT/HOUSES/HOUSE_PIX/other, the corresponding path for the 1002.jpg will
be modified to reflect the new path. The actual ORDImage object, however, will stay in the same
table and column, HOUSES.HOUSE_PIX.
Since currently the Clipboard is unable to create new rows in external ORD object or BLOB tables,
any ORD objects copied in the Clipboard will be copied to a newly created BLOB in a default storage
table maintained by the Clipboard. The original ORD object being copied, however, will stay in the
same table.

Oracle interMedia New Features 5-19


User Administration

The ADMIN user can create, delete, modify and view Clipboard users via online
Administration page
The Clipboard provides an online User Administration page which provides forms
for adding, deleting, modifying, and viewing Clipboard users.
Only the user admin is allowed access to any of these pages. Any other users
attempting to access these pages will be shown a not authorized message.
The User Administration page can be accessed via the Clipboard entry page or by the
URL:
http://host:port/servlet/oracle.ord.im.clipboard.Nav
igator?op=admin
Clipboard users are in no way related to Oracle users. Clipboard user data is stored
in a Clipboard maintained table in the database. Clipboard user passwords are stored
in an encrypted format.

Oracle interMedia New Features 5-20


Summary

In this lesson you should have learned to:


• Describe new interMedia Clipboard capabilities
• Describe changes from previous release
• Navigate the new Clipboard User Interface

Oracle interMedia New Features 5-21


interMedia Annotation Services

Oracle interMedia New Features 6-1


Objectives
At the end of this lesson, the student should be able to:
• Describe the process to call interMedia Annotation
Services
• Describe the process to write a new parser for
interMedia Annotation Services

Oracle interMedia New Features 6-2


interMedia Annotation Services for Oracle9i

What’s new:
• Callable interMedia Annotation Services
• Sample code to modify existing Java parsers
• APIs to add new parsers to Annotation Services
• Pass-through parser
– describe a group of items as a real world
object
– manually annotate a format not currently
supported by existing parsers

Through its detailed understanding of media formats, the Oracle9i interMedia annotation
services can automatically parse and extract media format and application metadata, generate
indices based upon this data, and map the metadata into XML documents or database schema.
Use of application metadata makes it easy to locate media content, while mapping it into
database schema makes the query process highly efficient and tightly integrated into an
application’s existing schema. Mapping the application metadata into an XML document makes
it easy to interchange of this information. In either case, annotation services are aware of the
industry standard metadata and allow the user to add additional metadata to that found in the
media. Annotation services can also sample the media content to give sub samples such as a
simple video story board.
The interMedia annotation services are conveniently packaged as a Java Bean. Implemented in
Java, they will run on any platform with a JVM. These Java Bean APIs allow for programmatic
invocation of metadata services by any application or scripting language that can use Java APIs
including JavaScript, and AppleScript. Sample code for each of the existing Java parsers is
included to allow customization, reuse or a rewrite to meet specific parsing needs, and an API
allows new new parsers to be plugged into Annotation Services.
The Pass-through parser can be used to describe a group of items as a real world object - for
example the music clips, album graphic, liner notes and music video associated with a Music
CD. It can also be used to manually annotate and store in Oracle9i, a format not currently
supported by existing parsers.

Oracle interMedia New Features 6-3


interMedia Annotation Services Examples

Annotation Services examples included with


Oracle9i interMedia kit:
• SimpleAnnotator.java
– Example for a synchronous environment
• SimpleAnnotatorAsynch.java
– Example for an asynchronous environment
• ASAnnotator.java
– Example of various services in a client
application

The three examples in the slide can be found under the demo/examples/src/directory
in the kit. Refer to the Annotator.bat file for the CLASSPATH setup.
Java documentation for Annotation Services can be found under /docs/apidoc/. Also see
the package documentation for oracle.ord.media.annotator.
Annotation Services require the following:
• lib/Annotator.jar
• lib/xmlparserv2.jar
• Oracle JDBC driver
• QuickTime for Java library is needed if QuickTime For Java is used
Annotation Services reads a set of initialization files during startup. The default is the current
directory. It can be overwritten by adding ORACLE_HOME properties to your Java command
line:
-D ORACLE_HOME=/your/oracle/home
Annotation Services root directory is located at $ORACLE_HOME/ord/Annotator.

Oracle interMedia New Features 6-4


interMedia Annotation Services Classes

• Classes include methods for annotation operations


• oracle.ord.media.annotator classes:
– .listener.AnnListener: implemented by the
client application before using annotation
– .handlers.AnnotationHandler : represents
the Annotator engine
– .annotations.Annotation: represents
Annotations
– .handlers.db.OrdFileMapping:
– PL/SQL mapping of annotations to database
schema
– OFM files map annotations to table columns

Classes include methods to start various annotation operations, and to access and modify
annotations.
• oracle.ord.media.annotator.annotations.Annotation: Access or
modify an annotation through the methods provided in this class.
• addSubAnnotation()and getSubAnnotations()are methods to add and
retrieve subannotations.
• createAnnotationByName(String)has the AnnotationFactory method used to
create an instance of annotation.
• oracle.ord.media.annotator.handlers.db.OrdFileMapping:
– Is used to uploading an annotation into the database
– Each instance of OrdFileMapping should be created using the filename of the
PL/SQL template to be used
Oracle File Mapping (OFM), maps Annotator attributes to individual columns in a database.

Oracle interMedia New Features 6-5


Additional Annotation Services Classes

oracle.ord.media.annotator
• .utils.Preferences: retrieve and update
preferences
• .utils.Status: a helper class that generates
tracing messages.
• .handlers.AnnTaskMonitor: provides information
on the status of the current action
• .descriptors.AnnotationDesc: exposes
metadata for specific annotation types
• .descriptors.ParserDesc: provides metadata for
specific parsers

oracle.ord.media.annotator.utils.Preferences
• Retrieves and updates preferences from Annotator.prefs file
• Applications use this mechanism to serialize, or store, their application preferences which are
used in subsequent invocation of the annotation services
• Preferences are retrieved by the static method Preferences.getPrefs()from the
preference file located at:
<ANNOTATOR_HOME>/lib/conf/Annotator.prefs
oracle.ord.media.annotator.utils.Status
• A helper class with methods that generates trace information
• Initialize the Status class before initializing AnnotationHandler)
oracle.ord.media.annotator.listener.OutputListener. Optionally
implement to process status output, such as, printing trace into a log file.
oracle.ord.media.annotator.handlers.AnnTaskMonitor
• Provides information on the status of the current action to the end user
• Multi-threading issues exist with AnnotationHandler, so instantiate one instance. Refer
to the Javadoc, AnnotationHandler class for details.

Oracle interMedia New Features 6-6


Sample Annotator Client Code:
Implement Interfaces

public class SimpleAnnotator implements


AnnListener, OutputListener
{
private Status m_st;
private AnnotationHandler m_ah;
public static void main(String[] args)
. . .

The next several slides show code snippets from the SimpleAnnotator code example
program included in the kit. The program shows how to implement a synchronous client of the
annotator engine. The client can take any parsable URL and feed it to the engine for parsing
and uploading into the database.
This particular program operates synchronously. Parsable files are those whose format the
annotator engine recognizes. The code snippets are organized much the way a sample java
program would be, including main, init, and other methods. Much code has be stripped out to
format the slides. See the sample code for a complete code listing.
This section of the code implements the Annlistner and OutputListner interfaces

Oracle interMedia New Features 6-7


Sample Annotator Client Code:
Implement Main Routine

// Create an annotator client & initialize


SimpleAnnotator sa = new SimpleAnnotator();
sa.init();
// invoke parser
String szURL = args[0];
sa.parse(szURL);
// when done, Annotator engine will
// call parsePerformed method

Main creates a new annotator, initializes it, and then uses it to parse a media file.

Oracle interMedia New Features 6-8


Sample Annotator Client Code:
Initialize Engine
public void init() {
report (
"Initializing Annotator Engine..." );
// create an Annotator Status instance
// to obtain traces from engine
// this implements OutputListener
Status.initStatus( this );
m_st = Status.getStatus();
m_st.SetOutputMode (
Status.OUTPUT_MODE_VERBOSE );

This section of code initializes the annotator engine.

Oracle interMedia New Features 6-9


Sample Annotator Client Code:
Set Mode
try {
// operate in synchronous mode
m_ah = new
AnnotationHandler (
AnnotationHandler.OP_MODE_SYNCH );
}
catch(Exception e){...}
report (
"Initializing Annotator Engine. Done");
}

This section of code sets the operational mode to synchronous.

Oracle interMedia New Features 6-10


Sample Annotator Client Code:
Invoke Parser
public void parse (String szURL) {
AnnTaskMonitor atm =
m_ah.parseMedia(szURL, this );
}

public void parsePerformed (


Annotation ann )

This section of code invokes the parser.

Oracle interMedia New Features 6-11


Sample Annotator Client Code:
Access Attributes
// access annotation attributes
String szMimeType = (String)
ann.getAttribute (
"MEDIA_SOURCE_MIME_TYPE" );

// get all annotation attributes


Enumeration eAttrs = ann.getAttributes();
while(eAttrs.hasMoreElements()) {
Attribute attr =
(Attribute)eAttrs.nextElement();
Object oAttrValue = attr.getValue();
...

This section of code covers client manipulation of parsed data before database upload.
It shows how to access the attributes that may have been parsed out.

Oracle interMedia New Features 6-12


Sample Annotator Client Code:
Load Annotation in Database
// uploaded to an Oracle database, using
// instance of OrdFileMapping to map
// an annotation instance to specific
// rows in specific tables in database.

m_ah.insertMedia(ann, ofm, this);


conn.commit();

This section of code uploads the parsed data into the database. Note that it uses both the
parsed data, ann, and a file, ofm, that describes where to put the parsed data, that is, which
columns in which tables to insert the data into.

Oracle interMedia New Features 6-13


interMedia Annotation Services:
Steps to Write a new Parser
• Extend the Parser Class by implementing three
methods:
– Parse()
– saveToAnnotation()
– extractSamples()
• Register the new parser with annotator services
by creating a parser descriptor XML file
• Optionally associate the new parser with a
specific mimetype

Defining a new parser is a two or three step process:


1. Create a new Java class that inherits from
oracle.ord.media.annotator.parsers.Parserand implement three methods:
• Parse(): parse the content from InputStream m_madisResource
• SaveToAnnotation(): store the result in the annotation m_annInst
• extractSamples(): extract samples from the media content.
– Implement a pass-through parser if sample extraction is not supported.
– oracle.ord.media.annotator.Statuscan be used to output parsing
status
Example parsers can be found in the kit under /src/. AuParser is a good sample with
which to start.
2. Register the new parser with annotator services by creating a parser descriptor XML file and
placing it in <ANNOTATOR_HOME>/lib/descriptors/parsers
Refer to the parser descriptor in the kit for examples.
3. Optionally associate the new parser with a specific mimetype by modifying the file
ANNOTATOR_HOME>/lib/conf/Annotator.mime.

Oracle interMedia New Features 6-14


Summary

In this lesson, the student should have learned that


interMedia Annotation Services:
• Are packaged as a Java Bean to run on any platform
with a Java Virtual Machine
• Allow for programmatic invocation of metadata
services by any application or scripting language
that can use Java APIs
• Provide Sample code for Java parsers to allow
customization, reuse or a rewrite to meet specific
media data parsing needs

The interMedia annotation services are conveniently packaged as a Java Bean. Implemented in
Java, they will run on any platform with a JVM. These Java Bean APIs allow for programmatic
invocation of metadata services by any application or scripting language that can use Java APIs
including JavaScript, and AppleScript. Sample code for each of the existing Java parsers is
included to allow customization, reuse or a rewrite to meet specific parsing needs, and an API
allows new new parsers to be plugged into Annotation Services.
The Pass-through parser can be used to describe a group of items as a real world object - for
example the music clips, album graphic, liner notes and music video associated with a Music
CD. It can also be used to manually annotate and store in Oracle9i, a format not currently
supported by existing parsers.

Oracle interMedia New Features 6-15


interMedia Integration and Object
Enhancements

Oracle interMedia New Features 7-1


Objectives

After completing this lesson, you should be able to


describe the new integrations between
interMedia and other Oracle features and tools.

Oracle interMedia New Features 7-2


Oracle Portal Integration

interMedia has been integrated with the following


Oracle Portal components in Oracle Portal 3.0:
• Reports enables you to:
– Use either the wizard or QBE
– Select interMedia object columns and attributes
and display thumbnails
– Link to full image, audio, or video for display or
play
• Forms enables you to upload media into interMedia
columns
• Navigator DB Explorer enables you to browse tables
and display media in interMedia object columns

Oracle interMedia New Features 7-3


JDeveloper and BC4J Integration

• Business Components for Java (BC4J) simplifies


business logic coding, so that you can:
– Improve time-to-market
– Saves time
– Avoids bugs by eliminating hand-written
database code
• BC4J with multimedia support:
– Simplifies Java application development by
simplifying interMedia programming
– Simplifies Java Web Servlet and JSP
development by generating and interpreting URLs
for interMedia objects in the database

Oracle interMedia New Features 7-4


JDeveloper and BC4J Integration Features

• Multimedia support, including streaming media


support, has been added to BC4J framework in
JDeveloper 3.0.
• Previously, interMedia object columns were
ignored
• Now JSP pages that upload, download, and
display multimedia data are automatically
generated in JDeveloper through a set of wizard
pages

Oracle interMedia New Features 7-5


Replication Integration

• In previous versions, tables containing objects


could not be replicated
• In Oracle9i, tables containing objects such as
interMedia’s ORDAudio, ORDImage, ORDDoc, and
ORDVideo, may be replicated

Oracle interMedia New Features 7-6


SQL*Loader Integration

• Basic general support for objects, including


interMedia objects, is being added for direct path
loads in Oracle9i.
• New SQL*Loader object support includes
support for:
– Column objects
– Nested column objects
– Object tables

Oracle interMedia New Features 7-7


Oracle Internet File System Integration

• There should be integration


• Details were not available at publishing time

Oracle interMedia New Features 7-8


Summary

In this lesson, you should have learned how to


describe the new integrations between
interMedia and other Oracle features and tools

Oracle interMedia New Features 7-9

Вам также может понравиться