pagina web captura y almacena foto
Buenas.
Tengo una clase que utilizo para tomar fotos desde una webcam, hasta ahora la aplicación solo la corro en escritorio, no necesitaba mas, el problema nace cuando tengo que colocar el capturador de imagen como un elemento en una Pág Web.
La ayuda que necesito consiste en poner este objeto o algo parecido en un formulario Web, tomar la imagen y almacenar el string en una tabla mysql, todo esto desde el usuario remoto.
Mas nada, ese es mi pequeño dolor de cabeza desde hace tres dias.
A todo el que me quiera ayudar mil gracias por adelantadoÂ…Â…Â…Â…..
Tengo una clase que utilizo para tomar fotos desde una webcam, hasta ahora la aplicación solo la corro en escritorio, no necesitaba mas, el problema nace cuando tengo que colocar el capturador de imagen como un elemento en una Pág Web.
La ayuda que necesito consiste en poner este objeto o algo parecido en un formulario Web, tomar la imagen y almacenar el string en una tabla mysql, todo esto desde el usuario remoto.
Mas nada, ese es mi pequeño dolor de cabeza desde hace tres dias.
A todo el que me quiera ayudar mil gracias por adelantadoÂ…Â…Â…Â…..
El problema cambio de forma. Ya tengo hecho un applets que activa una webcam y muestra en una pagina web. Esto como primera fase.
Lo que no he podido lograr es que cuando un usuario remoto llama la pagina el applets corre pero no activa la webcam.
Aquà dejo el codigo para el que quiera ayudar, gracias de antemano….
pd. Yo utilizo netbeans 6.1
/*
* fotoCaptura.java
*
* Created on 30 de enero de 2009, 07:22 PM
*/
package org.me.foto;
import java.applet.Applet;
import java.awt.*;
import java.awt.Graphics;
import javax.media.Buffer;
import javax.media.CaptureDeviceInfo;
import javax.media.CaptureDeviceManager;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.media.format.VideoFormat;
import javax.media.util.BufferToImage;
/**
*
* @author JGregPerezE
*/
public class fotoCaptura extends javax.swing.JApplet {
/** Initializes the applet fotoCaptura */
public void init() {
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
initComponents();
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
/** This method is called from within the init() method to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
btn_camara = new java.awt.Button();
button1 = new java.awt.Button();
button2 = new java.awt.Button();
btn_camara.setLabel("Camara");
btn_camara.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_camaraActionPerformed(evt);
}
});
button1.setLabel("button1");
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button1ActionPerformed(evt);
}
});
button2.setLabel("button2");
button2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button2ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(btn_camara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 224, Short.MAX_VALUE)
.addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btn_camara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(384, Short.MAX_VALUE))
);
}// </editor-fold>
private void btn_camaraActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String str2 = "vfw:Microsoft WDM Image Capture (Win32):0";
di = CaptureDeviceManager.getDevice(str2);
ml = new MediaLocator("vfw://0");
//Component comp;
try {
player = Manager.createRealizedPlayer(ml);
player.start();
Component comp = player.getVisualComponent();
if (comp != null) {
getContentPane().add(comp);//, BorderLayout.NORTH
}
comp.setBounds(60, 110, 160, 120);
} catch (Exception e) {
e.printStackTrace();
}
}
private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
btn_salir2 = new java.awt.Button();
btn_salir2.setLabel("Salir");
btn_salir2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_salir2ActionPerformed(evt);
}
});
getContentPane().add(btn_salir2);
btn_salir2.setBounds(40, 40, 200, 40);
}
private void button2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//player.getControlPanelComponent();
//player.getGainControl();
}
private void btn_salir2ActionPerformed(java.awt.event.ActionEvent evt){
System.out.println("Metodo btn Salir");
player.close();
player.deallocate();
System.exit(0);
}
// Variables declaration - do not modify
private java.awt.Button btn_camara;
private java.awt.Button button1;
private java.awt.Button button2;
// End of variables declaration
public static Player player = null;
public CaptureDeviceInfo di = null;
public MediaLocator ml = null;
public Buffer buf = null;
public Image img = null;
public VideoFormat vf = null;
public BufferToImage btoi = null;
public java.awt.Button btn_salir2 = null;
}
Lo que no he podido lograr es que cuando un usuario remoto llama la pagina el applets corre pero no activa la webcam.
Aquà dejo el codigo para el que quiera ayudar, gracias de antemano….
pd. Yo utilizo netbeans 6.1
/*
* fotoCaptura.java
*
* Created on 30 de enero de 2009, 07:22 PM
*/
package org.me.foto;
import java.applet.Applet;
import java.awt.*;
import java.awt.Graphics;
import javax.media.Buffer;
import javax.media.CaptureDeviceInfo;
import javax.media.CaptureDeviceManager;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.media.format.VideoFormat;
import javax.media.util.BufferToImage;
/**
*
* @author JGregPerezE
*/
public class fotoCaptura extends javax.swing.JApplet {
/** Initializes the applet fotoCaptura */
public void init() {
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
initComponents();
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
/** This method is called from within the init() method to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
btn_camara = new java.awt.Button();
button1 = new java.awt.Button();
button2 = new java.awt.Button();
btn_camara.setLabel("Camara");
btn_camara.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_camaraActionPerformed(evt);
}
});
button1.setLabel("button1");
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button1ActionPerformed(evt);
}
});
button2.setLabel("button2");
button2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button2ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(btn_camara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 224, Short.MAX_VALUE)
.addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btn_camara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(384, Short.MAX_VALUE))
);
}// </editor-fold>
private void btn_camaraActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String str2 = "vfw:Microsoft WDM Image Capture (Win32):0";
di = CaptureDeviceManager.getDevice(str2);
ml = new MediaLocator("vfw://0");
//Component comp;
try {
player = Manager.createRealizedPlayer(ml);
player.start();
Component comp = player.getVisualComponent();
if (comp != null) {
getContentPane().add(comp);//, BorderLayout.NORTH
}
comp.setBounds(60, 110, 160, 120);
} catch (Exception e) {
e.printStackTrace();
}
}
private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
btn_salir2 = new java.awt.Button();
btn_salir2.setLabel("Salir");
btn_salir2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_salir2ActionPerformed(evt);
}
});
getContentPane().add(btn_salir2);
btn_salir2.setBounds(40, 40, 200, 40);
}
private void button2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//player.getControlPanelComponent();
//player.getGainControl();
}
private void btn_salir2ActionPerformed(java.awt.event.ActionEvent evt){
System.out.println("Metodo btn Salir");
player.close();
player.deallocate();
System.exit(0);
}
// Variables declaration - do not modify
private java.awt.Button btn_camara;
private java.awt.Button button1;
private java.awt.Button button2;
// End of variables declaration
public static Player player = null;
public CaptureDeviceInfo di = null;
public MediaLocator ml = null;
public Buffer buf = null;
public Image img = null;
public VideoFormat vf = null;
public BufferToImage btoi = null;
public java.awt.Button btn_salir2 = null;
}
viejo es que tengo el mismo problema, necesito tomar una foto desde la webcam, ya tengo reproduciendo el video proveniente de la cam pero no he logrado tomar la foto, lo he intentado asi:
img = video.getVisualComponent().createImage(200, 200);
img = comp.createImage(190, 200);
pero cuando muestro la supuesta imagen que creo me sale un rectangulo negro... alguien me puede ayudar plsss es super urgente
img = video.getVisualComponent().createImage(200, 200);
img = comp.createImage(190, 200);
pero cuando muestro la supuesta imagen que creo me sale un rectangulo negro... alguien me puede ayudar plsss es super urgente
