Sunday, January 2, 2011

Blaze Row Seating In The Rose Garden

VIDEO CAPTURE FROM A WEB CAMERA WITH JAVA (2nd part)

PRETESTING
We will perform preliminary tests in order to create a more easily understood. For this it is necessary to consider the recommendations of the first part of this issue. Let's create a Java application that displays different capture devices for video and audio formats installed on your computer. In my case I will use NetBeans 6.9, however it is not necessary to have it installed, you can even use any other development environment for our example, taking into consideration that we must add to our classpath (classpath ) the jmf.jar file to make use of classes of the package. So if you're using NetBeans to create the example we can add the file to our classpath as follows: taking the project created right click on the Library folder that is displayed on the left of the folder tree and select the option " Add JAR / Folder " as shown in the figure below:

In the dialog that appears navigate to the file jmf. jar, as default location should be " / Program Files/JMF2.1.1e/lib/jmf.jar . Seleccionanos the file and click on the Open button. Then we'll be in a position to make use of Media Framework classes. As mentioned above, the following example loads the video capture devices installed and audio formats in the system. Remember to know what kind of format is necessary to manage your device check in the file "JMF Registry.

 import java.io.BufferedReader; 
import java.io.IOException;
import java. io.InputStreamReader;
import java.util.Vector;
javax.media.CaptureDeviceInfo import, import
javax.media.CaptureDeviceManager;

/ / FORMATS
javax.media.format.AudioFormat import; Import
javax.media.format.JPEGFormat;
javax.media.format.RGBFormat import, import
javax.media.format.VideoFormat;


{public class
private Devices Devices () {

bl = new BufferedReader ( new InputStreamReader (System.in));
FORMATO_AUDIO = new AudioFormat (AudioFormat.LINEAR)
JPEGFormat FORMATO_JPEG = new ();
FORMATO_VIDEO = new videoformat (VideoFormat.CINEPAK)
RGBFormat FORMATO_RGB = new ();}


private static int menu ()

{int opt \u200b\u200b= 0, index;
System.out.println ("\\ t-*- MENU OPTIONS -*- \\ n ");
for (index = 0; index < opciones.length; indice ++ )
System.out.println ((index + 1) +" .- "+ options [index]);
System.out.print (" Which option you choose? ");

try
{opc = Integer.parseInt (bl.readLine ());

} catch (NumberFormatException exc) {

opt = menu ();

} catch (IOException exc) {

opt = menu ();}

System.out.println ();
return opt;


} public static void main ( String args []) {

ban boolean = false;
int opt;
new Device ();
devices = new Vector ();
do
{
opt = menu ();
dispositivos.setSize (0) ;
switch (opt)

{case 1:
devices = CaptureDeviceManager.getDeviceList (FORMATO_AUDIO)
break;
case 2:
devices = CaptureDeviceManager.getDeviceList (FORMATO_JPEG)
break;
case 3:
dispositivos = CaptureDeviceManager.getDeviceList( FORMATO_VIDEO );
break;
case 4:
dispositivos = CaptureDeviceManager.getDeviceList( FORMATO_RGB );
break;
}
if( opc != opciones.length )
if( dispositivos.size() > 0 )
for( CaptureDeviceInfo d : dispositivos )
System.out.println( "UBICACIÓN:\t" + d.getLocator() + "\nNOMBRE:\t"
+ d.getName() + "\n" );
else
System.out.println ("\\ nThe format is specified devices"
+ "installed on the computer!");}

while (opt! = Opciones.length)


} private static String options [] = {"FORMATO_AUDIO", "FORMATO_JPEG"
"FORMATO_VIDEO", "FORMATO_RGB", "EXIT"} private static BufferedReader

bl;

< CaptureDeviceInfo > private static Vector devices;
AudioFormat FORMATO_AUDIO private static;
JPEGFormat private static FORMATO_JPEG ;
videoformat FORMATO_VIDEO private static;
FORMATO_RGB RGBFormat private static;}

Patricia Menterola Wedding

CAPTURE VIDEO FROM A WEB CAMERA WITH JAVA (1st part)

JAVA MEDIA FRAMEWORK
E oday applications that interact with external devices are increasingly common. We can meet user authentication systems from something as simple as introducing a security key or a more complex process such as fingerprint recognition. Java provides a multimedia-based mechanism for making applications more friendly to users. Thus, we can create an application that reads a key and display the image of the person we are looking for. This technology known as Java Media Framework (JMF Java and Multimedia Environment). Allows the integration of audio and video (playback and capture) and a set of tools for developing cross-platform technology. This API is available from its official website in the downloads section. Once you've downloaded the program is installed in the traditional way.

JMF already installed on your system do we have to recognize the external multimedia devices with which we have cameras, capture cards, sound cards, microphones, etc.., We to run "JMF Registry "which is inside the folder" \\ JMF2.1.1e \\ bin . " NOTE: If using JMF in Windows Vista / 7 you have to run this program with Administrator permissions.

After running the program select the tab "Capture Devices" and click on the button "Detect Capture Devices" and wait until the program ends to scanning. When finished we will have a window similar to the following:



This window is important to note the capture device name, location and format that enables. In my case I have the following:

Device Name: "vfw: Microsoft WDM Image Capture (Win32): 0"
Location: "vfw: / / 0 "

These values \u200b\u200bare then use to refer to the device from the program. Finally press the "Commit" to apply the changes and close the window, so we registered with the JMF video capture device.

Entering programming, classes that use it to develop example is the following, all found in the package file javax.media JMF.jar found in "\\ JMF2.1.1e \\ lib".

CaptureDeviceInfo
Contains information about the capture device deployed.

CaptureDeviceManager
class that provides information from different capture devices that are available in the system.

Manager
This class provides access to system resources through JFM.

MediaLocator
This
class allows us to identify the location of a multimedia content source device through its URL (Uniform Resource Locator).

Player (Interface)
A Player is an object used to control and process multimedia data a content type specific data, eg audio or video .


videoformat (Javax.media.format package)
Encapsulates format information for video data. attributes of a videoformat include the encoding type, size, frame rate and type of data. For other video formats see the reference page .

Saturday, January 1, 2011

Pleurodiaphragmatic Adhesion Left

abstract table model (AbstractTableModel)

A convenient way to represent information about a particular topic using model life tables is easy to program our own style and convenience. Java offers component called abstract table model (class AbstractTableModel javax.swing.table package) that implements the TableModel interface whose methods to implement are:

public int getRowCount () - Returns the number of rows that contains the table.
public int getColumnCount () - Returns the number of columns table.
public Object getValueAt ( int row, int column) - Returns the element / value at the position (row, column) of the table.

Then, to illustrate the example of using AbstractTableModel class will have the following sample code to the methods mentioned above:


 AbstractTableModel 
class MyTable extends {

@ Override public int getRowCount () {
return
10;


} @ Override public int
getColumnCount ()

{return 10;}


@ Override public Object
getValueAt (int row, int column)

{return "# VALUE #";}

}
addition to these methods we can override other four AbstractTableModel own class. These methods are:


public getColumnClass Class ( int column) - Returns the class type of a particular column, that is the type of object that is hosting this column in the table.
public String getColumnName ( int column) - Returns the name of the column.
public boolean isCellEditable ( int row, int column) - Returns true if the cell specified by the position (row, column) has enabled the edit mode, otherwise returns false.
public void setValueAt (Object value, int row int column) Sets a value (object) within the table at the position specified by row, column. The description of other methods can be found in the documentation page AbstractTableModel.

worth mentioning that this type of tables they can apply custom styles to make them more pleasing to the eye of the user, such as changing the color of the rows and columns, text font and even add Swing components as part data. Below is an example of the implementation of the above methods. To this end incorporates a table in a form containing key, name and address of users from a fictitious company. We will use the Person class that defines the necessary methods to insert and collect these values, its structure is as follows:

 
final class Person {public
Person () {

this (0, "", "");


} public Person (int key, String name, String address)
{
setClave (key);
setNombre (name);
setDireccion (address);
;} public void

setClave (int key) {

this.clave = key;
;}

&nbsp;public void setNombre( String nombre )
&nbsp;&nbsp; &nbsp;{
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;this.nombre = nombre;
&nbsp;&nbsp; &nbsp;}

&nbsp;&nbsp; &nbsp;public void setDireccion( String direccion )
&nbsp;&nbsp; &nbsp;{
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;this.direccion = direccion;
&nbsp;&nbsp; &nbsp;}

&nbsp;&nbsp; &nbsp;public void setPersona( Persona persona )
&nbsp;&nbsp; {
this.persona = person;}


getClave public int () {

return key;}


public String getName () {

; return name;
} Public String

getDireccion ()

{return address;}


GetPerson public Person ()

{return this;}


key private int ;
private String name;
private String address;
private Person person;}


Once we have the Person class can write the Table class that defines the behavior of the table.

class Table extends AbstractTableModel
 

{public Table () {

names = new String [] {"KEY" "NAME", "ADDRESS"};
data = new Vector (0);}


@ Override public Class
getColumnClass (int column)
; {return
getValueAt (0, column). getClass ();}



@ Override getColumnName public String (int column)

{return names [column];}


@ Override public
int getRowCount () {

datos.size return ();}



@ Override ; public int getColumnCount ()
{return
nombres.length;


} @ Override public
getValueAt Object (int row, int column)

{if (datos.size ()> 0)
switch (column)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case 0:
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return datos.get( fila ).getClave();
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case 1:
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; datos.get return (row). getNombre ();
case 2:
; datos.get return (row). getDireccion ();}

return "";}
Public void

agregarRegistro (Person person) {

datos.add (person);
fireTableStructureChanged ();}


private Vector data;
private String names [];}