The Java Media Framework: javax.media

Slides:



Advertisements
Similar presentations
Chapter 18 Building the user interface. This chapter discusses n Javas graphical user interface. n Swing: an enhancement of a library called the Abstract.
Advertisements

Digital Images in Java Java’s imaging classes. Java imaging library  Java has good support for image processing  Must master a handful of classes and.
Using Multimedia on the Web Enhancing a Web Site with Sound, Video, and Applets.
CNIT 132 – Week 9 Multimedia. Working with Multimedia Bandwidth is a measure of the amount of data that can be sent through a communication pipeline each.
It provides a framework for embedded multimedia facilities in java enabled mobile devices.
1 RTL Example: Video Compression – Sum of Absolute Differences Video is a series of frames (e.g., 30 per second) Most frames similar to previous frame.
Java Media Framework The Java Media Framework (JMF) is an application programming interface (API) for incorporating time- based media into Java applications.
UNDERSTANDING JAVA APIS FOR MOBILE DEVICES v0.01.
Object-Oriented Analysis and Design
Lecture13 Java Media Framework II - Java Media Framework II - Processing and Controlling Media with JMF.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Prepared By E. Musa Alyaman1 URLs, InetAddresses, and URLConnections Chapter 9.
1 L45 Multimedia: Applets and Applications. 2 OBJECTIVES  How to get and display images.  To create animations from sequences of images.  To create.
Quicktime Howell Istance School of Computing De Montfort University.
Lecture15 Java Media Framework IV. Processing Individual Frames The JMF’s BufferToImage and ImageToBuffer classes can be used to obtain frame images from.
SWE 423: Multimedia Systems Chapter 7: Data Compression (1)
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 16 Applets.
Java Audio.
OUTLINE WHAT ? HOW ? WHY ? BLUEPOST Poster and Message Content Specified by the User Displaying the Poster Content on a Monitor Sending Messages to.
 Pearson Education, Inc. All rights reserved Multimedia: Applets and Applications.
Lecture14 Java Media Framework III – Some JMF Applications.
First Bytes - LabVIEW. Today’s Session Introduction to LabVIEW Colors and computers Lab to create a color picker Lab to manipulate an image Visual ProgrammingImage.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L05 (Chapter 16) Applets.
Introduction to Computer Graphics
Gursharan Singh Tatla Transport Layer 16-May
1 Java Media Framework Multimedia Systems: Module 3 Lesson 1 Summary: r JMF Core Model m Architecture m Models: time, event, data r JMF Core Functionality.
USB host for web camera connection
© 2009 Research In Motion Limited Advanced Java Application Development for the BlackBerry Smartphone Trainer name Date.
Computer Science [3] Java Programming II - Laboratory Course Lab 7: Multimedia: Applets and Applications Faculty of Engineering & IT Software Engineering.
Lab 2: Capturing and Displaying Digital Image
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
ACM/JETT Workshop - August 4-5, ExceptionHandling and User Interfaces (Event Delegation, Inner classes) using Swing.
Java: Chapter 1 Computer Systems Computer Programming II.
THE OSI MODEL AND THE TCP/IP PROTOCOL SUITE CS 1202 Lectur3 part2.
Video Conferencing-introduction --- IT Acumens. COM --- IT Acumens. COMIT Acumens. COMIT Acumens. COM.
 2005 Pearson Education, Inc. All rights reserved Multimedia: Applets and Applications.
Applets Chapter 17.  Java’s big splash onto the scene came in the mid 90’s. The people at Sun Microsystems had managed to work java programs into Web.
Foundations of Computer Science Computing …it is all about Data Representation, Storage, Processing, and Communication of Data 10/4/20151CS 112 – Foundations.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 5 Working with Images Starting Out with Games & Graphics in.
ImageJ EE4H, M.Sc Computer Vision Dr. Mike Spann
Minor Project By: Pasang Gurung Pramod Nepal Rajendra Bdr. Thapa.
Using the JImageViewer classes. JImageViewer classes JImageViewer class JImageViewer class ImagePanel class ImagePanel class Image class Image class.
Introduction to Biometrics Dr. Bhavani Thuraisingham The University of Texas at Dallas Lecture #23 Biometrics Standards - II November 14, 2005.
JMF Introduction Yuqiang Liao Content What can JMF do What can JMF do Handling Time-Based Media Handling Time-Based Media JMF Architecture.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
Pravin Yannawar, DOCS, NMU Jalgaon Basic Java : Applets 2 Objectives of This Session Identify the need for Applets Distinguish between Applets and Applications.
Introduction to Flash Animation CS 318. Topics Introduction to Flash and animation The Flash development environment Creating Flash animations  Layers.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
© 2009 Research In Motion Limited Advanced Java Application Development for the BlackBerry Smartphone Trainer name Date.
INTRODUCTION.  Upon completing this topic, you should be able to: Illustrate a basic elements of digital computer system and their functions, Depicts.
Chapter 14 Applets and Advanced GUI  The Applet Class  The HTML Tag F Passing Parameters to Applets F Conversions Between Applications and Applets F.
12/5/2015 EEC492/693/793 - iPhone Application Development 1 EEC-693/793 Applied Computer Vision with Depth Cameras Lecture 4 Wenbing Zhao
Class 9 LBSC 690 Information Technology Multimedia.
12/16/  List the elements of 8255A Programmable Peripheral Interface (PPI)  Explain its various operating modes  Develop a simple program to.
Object Serialization.  When the data was output to disk, certain information was lost, such as the type of each value.  If the value "3" is read from.
1 Java Servlets l Servlets : programs that run within the context of a server, analogous to applets that run within the context of a browser. l Used to.
A brief introduction to doxygen. What does a compiler do?  A compiler ignores comments and processes the code.  What does doxygen do? –It ignores the.
Data Representation. What is data? Data is information that has been translated into a form that is more convenient to process As information take different.
Internet Applications (Cont’d) Basic Internet Applications – World Wide Web (WWW) Browser Architecture Static Documents Dynamic Documents Active Documents.
CS 180 Problem Solving and Object Oriented Programming Fall 2011 Notes for Week 14: Nov 21-25, 2011 Aditya Mathur Department of Computer Science Purdue.
Chapter 5: MULTIMEDIA DATABASE MANAGEMENT SYSTEM ARCHITECTURE BIT 3193 MULTIMEDIA DATABASE.
2/16/2016 EEC492/693/793 - iPhone Application Development 1 EEC-693/793 Applied Computer Vision with Depth Cameras Lecture 4 Wenbing Zhao
1 Sections 5.1 – 5.2 Digital Image Processing Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
1 Network Communications A Brief Introduction. 2 Network Communications.
MPEG-4 Binary Information for Scenes (BIFS)
VIDEO.
Video Conferencing-introduction
Multidimensional Arrays
Presentation transcript:

The Java Media Framework: javax.media Access to devices & media files Resources Sun JMF web site http://java.sun.com/products/java-media/jmf/index.jsp http://java.sun.com/products/java-media/jmf/2.1.1/apidocs/ Sample chapter from book, “Essential JMF - Java Media Framework” Gordon & Talley, 1998 Terrazas et al. (2002). Java Media API’s. SAMS Pub. This material only needs about 1.5 lecture sessions. Next time: Video camera access from the Java Quicktime API also?

Topics General contents of JMF Digital video primer Classes java.awt.image.BufferedImage Abstract Window Toolkit class java.awt.image.ColorModel javax.media.format.RGBFormat Pixel representation javax.media.Format; javax.media.MediaLocator; javax.media.protocol.DataSource; javax.media.CaptureDeviceManager;

Digital Video Primer Cameras return “frames” of visual information Each frame is a 2D matrix Components of these arrays are pixels Usually integers Dimensions: height by width E.g., 160 x 120 pixels Frames are returned from the camera at a certain rate I.e., the frame rate E.g., 15 frames per second Frames are often represented in programs as one-dimensional arrays int[] frame; // in Java

Frames as 1D Arrays int [] frame = null; // code to get frame from camera… int x = 10, y = 20; // get some pixel // 0 <= x <= width-1; 0 <= y <= height-1 // (0, 0)-- upper left of image int pixel = frame[y * width + x]; // assumes a row oriented representation

Class java.awt.image.BufferedImage An Image comprised of a data buffer for image, plus color model information Represents color or grayscale images in various formats E.g., TYPE_BYTE_GRAY, TYPE_USHORT_GRAY, TYPE_USHORT_565_RGB, TYPE_INT_RGB Methods include public ColorModel getColorModel() ColorModel (java.awt.image.ColorModel) describes the format of the image public BufferedImage getSubimage(int x, int y, int w, int h) public int[] getRGB(parameter list…)

Class java.awt.image.ColorModel Abstract class used to construct representations of colors (color models) for images Methods include public abstract int getRed(int pixel) public abstract int getGreen(int pixel) public abstract int getBlue(int pixel)

Class javax.media.format.RGBFormat The RGBFormat class of the javax.media.format package Subclass of VideoFormat (javax.media.format.VideoFormat) “32-bit packed RGB stored as 32-bit integers would have the following masks: redMask = 0x00FF0000, greenMask = 0x0000FF00, blueMask = 0x000000FF.” (From JMF API)

Pixel Representation Pixels as returned from the BufferedImage class getRGB method Represented using lower 24 bits of int’s High order byte: Red Middle byte: Green Low-order byte: Blue This format because the Java programs we are using set up the image formats this way RGBFormat (javax.media.format.RGBFormat) image formats were obtained from the camera

Example 1) Given a pixel in RGBFormat as described, use bit manipulation operations to extract out the R, G, and B components 2) Use bit manipulation operations to create a new RGBFormat pixel given 8 bit R, G, and B components

Outline of Using JMF to Access USB Camera Devices Determine available camera devices CaptureDeviceManager.getDeviceList Obtain a DataSource Use Manager to create this DataSource, based on a MediaLocator Obtain a Processor From Manager based on the DataSource Obtain a PushBufferDataSource From the Processor

Class javax.media.CaptureDeviceManager Methods public static CaptureDeviceInfo getDevice(java.lang.String deviceName) Get a device by name public static java.util.Vector getDeviceList(Format format) Returns a Vector containing a list of CaptureDeviceInfo descriptions of devices available on the computer of the format given Formats returned may be more than that specified E.g., if a given device supports YUV and RGB formats, then all formats (including both YUV and RGB) will be returned in the result of the getDeviceList call If Format is null, returns the list of all available devices on the system

Class javax.media.CaptureDeviceInfo Methods include public Format[] getFormats() Returns an array of Format objects Specific Format’s available for the video device public MediaLocator getLocator()

Class javax.media.Format Format class of javax.media package Constructor Format(java.lang.String encoding) Device/media specific description of a media format E.g., for a video (visual) device "RGB, 160x120, Length=38400, 16-bit, Masks=31744:992:31, PixelStride=2, LineStride=320, Flipped” E.g., for an a audio device "PCM, 44.1 KHz, Stereo, Signed"

Class javax.media.MediaLocator Constructor MediaLocator(java.lang.String locatorString) Locator strings are similar to URLs Example locatorString “vfw://0” This is for my USB web camera MediaLocator’s can describe files e.g., MediaLocator m = new MediaLocator(“file://media/example.mov”);

Class javax.media.Manager - 1 Access point for obtaining system dependent resources Player’s, DataSource’s, Processor’s, DataSink’s, TimeBase DataSource Object used to deliver time-based multimedia data that is specific to a delivery protocol. Examples of protocols: http, ftp, file Once you have a “usable” (formatted) DataSource, you can display the media (via a Player), or manipulate the information (via a Processor)

Class javax.media.Manager - 2 Manager methods include public static DataSource createDataSource(MediaLocator sourceLocator) Returns a data source for the protocol specified by the MediaLocator. When you call createDataSource on the media locator of a video capture device (obtained from the CaptureDeviceManager), the returned DataSource will implement the CaptureDevice interface public static DataSource createCloneableDataSource(DataSource source) - create a DataSource that can be cloned; this enables DataSource to be processed by different tasks public static Processor createProcessor(DataSource source) - Processors are used in controlling the processing of media

Class javax.media.protocol.DataSource An abstraction for media protocol-handlers. DataSource manages the life-cycle of the media source by providing a simple connection protocol. Methods include DataSource(MediaLocator source) connect start, stop Start and stop data transfer

Interface CaptureDevice A capture device is a DataSource of type PullDataSource, PullBufferDataSource, PushDataSource or PushBufferDataSource. It also implements the CaptureDevice interface… A CaptureDevice DataSource contains an array of SourceStream's. These SourceStreams provide the interface for the captured data streams to be read. (From JMF API) Methods include public FormatControl[] getFormatControls()

Interface FormatControl Objects implementing the FormatControl interface can be used to set the Format of the CaptureDevice to the Format desired Methods public Format setFormat(Format format) Returns null if the format is not supported. Otherwise, it (typically) returns the format that's actually set.

Interface javax.media.Processor Processes and controls time-based media data. Extends the Player interface. Unlike a Player, which processes data as a "black box" and only renders data to preset destinations, a Processor supports a programmatic interface enabling control over media data processing and access to output data streams. Processing performed by a Processor is split into three stages: Demultiplexing - into separate tracks of data Data transcoding - of each track into other formats Multiplexing - to form an interleaved stream Data transcoding and multiplexing processes are programmable.

Interface javax.media.Processor Processor is a Player is a Controller Methods include DataSource getDataOutput() get the output DataSource from the Processor public void addControllerListener(ControllerListener listener) From Controller interface Events get posted to the listener, I.e., the public void controllerUpdate(ControllerEvent event) method gets called for that listener public void realize() Constructs media dependent portions of Controller. public void prefetch() public void start() public int getState() States: Unrealized, Configuring, Configured, Realizing, Realized, Prefetching, Prefetched, and Started.

Controller Life Cycle Controller’s have five resource-allocation states: Unrealized, Realizing, Realized, Prefetching, and Prefetched. These states provide programmatic control over potentially time-consuming operations. For example, when a Controller is first constructed, it's in the Unrealized state. While Realizing, the Controller performs the communication necessary to locate all of the resources it needs to function (such as communicating with a server, other controllers, or a file system). The realize method allows an application to initiate this potentially time-consuming process (Realizing) at an appropriate time.

Class javax.media.protocol.PushBufferDataSource A data source that manages data in the form of push streams. The streams from this DataSource are PushBufferStream’s and contain Buffer objects We we use getDataOutput to get a DataSource from our Processor, and this DataSource is actually a PushBufferDataSource Methods public abstract PushBufferStream[] getStreams() Return streams that this source manages. The collection of streams is entirely content dependent. The ContentDescriptor of this DataSource provides the only indication of what streams can be available on this connection. For our USB camera capture device, there is only one PushBufferStream PushBufferDataSource is a subclass of DataSource

Interface javax.media.protocol.PushBufferStream A read interface that pushes data in the form of Buffer objects. Allows a source stream to transfer data in the form of a media object. The media object transferred is the Buffer object as defined in javax.media.Buffer. The user of the stream will allocate an empty Buffer object and pass this to the source stream in the read() method. The source stream allocates the Buffer object's data and header, sets them on the Buffer and sends them to the user.

Interface javax.media.protocol.PushBufferStream Methods include public Format getFormat() public void setTransferHandler(BufferTransferHandler transferHandler) Register an object to service data transfers to this stream. public void read(Buffer buffer) Read from the stream without blocking. (Not documented regarding what happens if you read and there is no data available-- Is the buffer empty or is an IOException raised).

Interface javax.media.protocol.BufferTransferHandler Implements a callback from a PushBufferStream. A PushBufferStream needs to notify the data handler when data is available to be pushed. Methods include public void transferData(PushBufferStream stream) Notification from the PushBufferStream to the handler that data is available to be read from stream. The data can be read by this handler in the same thread or can be read later.

Class javax.media.Buffer A media-data container that carries media data from one processing stage to the next inside of a Player or Processor. Buffer objects are also used to carry data between a buffer stream and its handler. Maintains information including the time stamp, length, and Format of the data it carries, as well as any header information that might be required to process the media data.

Class javax.media.util.BufferToImage A utility class to convert a video Buffer object to an AWT Image object you can then render the Image to the user display with AWT methods. Methods include public BufferToImage(VideoFormat format) public java.awt.Image createImage(Buffer buffer) Converts the input Buffer to a standard AWT image and returns the image.

Class java.awt.image.BufferedImage (From Above) Class java.awt.image.BufferedImage An Image comprised of a data buffer for image, plus color model information A subclass of java.awt.Image Represents color or grayscale images in various formats E.g., TYPE_BYTE_GRAY, TYPE_USHORT_GRAY, TYPE_USHORT_565_RGB, TYPE_INT_RGB Methods include public ColorModel getColorModel() ColorModel (java.awt.image.ColorModel) describes the format of the image public BufferedImage getSubimage(int x, int y, int w, int h) public int[] getRGB(parameter list…)

Capturing the Webcam Images PushBufferStream PushBuffer; // created above Buffer ImageBuffer = new Buffer(); BufferToImage ImageConverter = new BufferToImage((VideoFormat) (PushBuffer.getFormat())); // assume a new frame is ready PushBuffer.read(ImageBuffer); BufferedImage InputImage = ((BufferedImage) (ImageConverter.createImage(ImageBuffer))); int[] CurrentFrame = InputImage.getRGB(0, 0, VideoWidth, VideoHeight, null, 0, VideoWidth); From ImageProcessingThread.java (Lab1)