camara ip online echa en java

Technology

camara ip online echa en java



bueno aqui les dejo el codigo de camara ip en java el cual puedes ver en tiempo real lo que pasa en el mundo, tiene diferentes ips y a la cual ustedes pueden añadir extras para ver la camarita , tambien pueden ingresar el tiempo en que va a refrescar la camara, y ademas comoe xtra acomodar el tamaño de la imagen de la camara si mas ancho ó mas alto.

bueno vamos para el codigo primero obvio creamos un proyecto y luego creamos un pakete yo lo voy a llamar camaraonline dentro de ese pakete creamos una clase llamada  dibujartodo y en esa clase ponemos el siguiente codigo:



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package camaraonline;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JPanel;

/**
 *
 * @author andres2288
 */
public class dibujartodo extends JComponent{
   
      
       private Dimension d = new Dimension(640,480);//352,240//640,480//[352, 286]
       JPanel pa=null;
       private int x1=400;
       private int y1=400;
       
       private int posx=0;
       private int posy=0;
       private int tiempo=2000;
       private String mundo="http://123.220.250.252/";
      
       private  Image snap= new ImageIcon( getClass().getResource("/livecam/snap.jpg") ).getImage() ;  

    private String Axis="axis-cgi/jpg/image.cgi?resolution="+d.width+"x"+d.height+""; 
   public dibujartodo(JComponent contenedor,JPanel p){
       super();
       this.setBounds(0, 0,contenedor.getWidth() , contenedor.getHeight());
       contenedor.add(this);
  /*  d.width=358;
    d.height=500;*/
 this.pa=p;
               }
   
      @Override
    public void paint(Graphics g){
        super.paint(g);
      //  getGrafo().paint(g);
      
            try {
            //libera lo que se halla almacenado en el buffer
            snap.flush();
            //carga la nueva imagen
            /* ----------------- */
            //Odate street
            //snap = new ImageIcon(new URL("http://www.odate-houjinkai.or.jp/snap.jpg")).getImage();
            //tienda japon
            //snap = new ImageIcon(new URL("http://www.hifido.co.jp/camera/osu.jpg")).getImage();
            //barberia japon
            //snap = new ImageIcon(new URL("http://www.salon-net.org/realtime100.jpg")).getImage();
            //Camaras AXIS
            //aeropuerto de rochester
            //snap = new ImageIcon(new URL("http://84.92.80.192:8081/axis-cgi/jpg/image.cgi?resolution=352x240")).getImage();
            //snap = new ImageIcon(new URL("http://206.127.116.63/axis-cgi/jpg/image.cgi?resolution=352x240")).getImage();
            //snap = new ImageIcon(new URL("http://62.42.19.194/axis-cgi/jpg/image.cgi?resolution=352x240")).getImage();
            //tokio
            //snap = new ImageIcon(new URL("http://221.255.120.171/axis-cgi/jpg/image.cgi?resolution=352x240")).getImage();
            //restorant
            //snap = new ImageIcon(new URL( "http://80.25.78.169/" + this.Axis )).getImage();
            //calle
            System.out.println(""+x1+"-->"+y1+"\n"+"pox"+getPosx()+"posy"+getPosy()+"\n"+pa.getY()); 
            if(mundo.indexOf("jpg")!=-1){
             
         snap = new ImageIcon(new URL(mundo)).getImage();
            }
            else{
            snap = new ImageIcon(new URL( mundo + this.Axis )).getImage();
            }
            /* ----------------- */
       
        } catch (MalformedURLException ex) {
        }
         g.drawImage(snap, 0, 0, x1, y1,   null); 
          
             
    }
      
         //metodo que descarga una imagen de internet y la coloca en el JLabel
     private void Cargar_Imagen(){        
        try {
            //libera lo que se halla almacenado en el buffer
            snap.flush();
            //carga la nueva imagen
            /* ----------------- */
            //Odate street
            //snap = new ImageIcon(new URL("http://www.odate-houjinkai.or.jp/snap.jpg")).getImage();
            //tienda japon
            //snap = new ImageIcon(new URL("http://www.hifido.co.jp/camera/osu.jpg")).getImage();
            //barberia japon
            //snap = new ImageIcon(new URL("http://www.salon-net.org/realtime100.jpg")).getImage();
            //Camaras AXIS
            //aeropuerto de rochester
            //snap = new ImageIcon(new URL("http://84.92.80.192:8081/axis-cgi/jpg/image.cgi?resolution=352x240")).getImage();
            //snap = new ImageIcon(new URL("http://206.127.116.63/axis-cgi/jpg/image.cgi?resolution=352x240")).getImage();
            //snap = new ImageIcon(new URL("http://62.42.19.194/axis-cgi/jpg/image.cgi?resolution=352x240")).getImage();
            //tokio
            //snap = new ImageIcon(new URL("http://221.255.120.171/axis-cgi/jpg/image.cgi?resolution=352x240")).getImage();
            //restorant
            //snap = new ImageIcon(new URL( "http://80.25.78.169/" + this.Axis )).getImage();
            //calle
            snap = new ImageIcon(new URL( "http://123.220.250.252/" + this.Axis )).getImage();
            
            /* ----------------- */
        } catch (MalformedURLException ex) {
        }
        
         
          
    }
     
        
           private Thread hilo1 = new Thread()
    {
        
       
        @Override
        public void run()
        {
            try
            {
                while(true)
                {
              
                   
                 
                   
                     //aumentamos dependiendo

             pa.repaint();       
                 
                    hilo1.sleep(getTiempo());
                   
                    System.out.println(""+tiempo);    
                     
                }
            } catch (java.lang.InterruptedException ie) { System.out.println(ie.getMessage()); }
        }
    };

           
           public void aumentay(){
         y1+=+15;  
           }
    /**
     * @return the hilo1
     */
    public Thread getHilo1() {
        return hilo1;
    }

    /**
     * @param hilo1 the hilo1 to set
     */
    public void setHilo1(Thread hilo1) {
        this.hilo1 = hilo1;
    }

    /**
     * @return the tiempo
     */
    public int getTiempo() {
        return tiempo;
    }

    /**
     * @param tiempo the tiempo to set
     */
    public void setTiempo(int tiempo) {
        this.tiempo = tiempo;
    }

    /**
     * @return the mundo
     */
    public String getMundo() {
        return mundo;
    }

    /**
     * @param mundo the mundo to set
     */
    public void setMundo(String mundo) {
        this.mundo = mundo;
    }

    /**
     * @return the x1
     */
    public int getX1() {
        return x1;
    }

    /**
     * @param x1 the x1 to set
     */
    public void setX1(int x1) {
        this.x1 = x1;
    }



    /**
     * @return the posx
     */
    public int getPosx() {
        return posx;
    }

    /**
     * @param posx the posx to set
     */
    public void setPosx(int posx) {
        this.posx = posx;
    }

    /**
     * @return the posy
     */
    public int getPosy() {
        return posy;
    }

    /**
     * @param posy the posy to set
     */
    public void setPosy(int posy) {
        this.posy = posy;
    }

    /**
     * @return the y1
     */
    public int getY1() {
        return y1;
    }

    /**
     * @param y1 the y1 to set
     */
    public void setY1(int y1) {
        this.y1 = y1;
    }
}

 




luego creamos un formulario ó Jframe como lo entiendan llamado visual ponemos las siguientes variables en ese formulario.


  DefaultComboBoxModel dc1 = new DefaultComboBoxModel();
 private dibujartodo contenedor;
 int sleep=2000;

luego en el construtor ponemos el siguiente codigo:



   super("por andres2288");
        initComponents();
          contenedor= new dibujartodo(panel1,panel1);
          dc1.addElement("http://123.220.250.252/");
          dc1.addElement("http://www.odate-houjinkai.or.jp/snap.jpg");
          dc1.addElement("http://www.hifido.co.jp/camera/osu.jpg");
          dc1.addElement("http://www.salon-net.org/realtime100.jpg");
          dc1.addElement("http://84.92.80.192:8081/axis-cgi/jpg/image.cgi?resolution=352x240");
          dc1.addElement("http://206.127.116.63/axis-cgi/jpg/image.cgi?resolution=352x240");
          dc1.addElement("http://62.42.19.194/axis-cgi/jpg/image.cgi?resolution=352x240");
          dc1.addElement("http://221.255.120.171/axis-cgi/jpg/image.cgi?resolution=352x240");
        dc1.addElement("http://128.97.43.214/");

creamos un boton llamado play y cuando le den click va a ejecutar el siguiente codigo




   if(!contenedor.getHilo1().isAlive()){
       contenedor.getHilo1().start();
        }
        else{
      contenedor.getHilo1().resume();   
        }
bueno ustedes le agregan lo otro ya que es facil y eso es todo.
aqui les dejo el .jar   descarga

Post a Comment

1 Comments

  1. Antes pensar en CCTV en Bogotá es necesario un estudio de seguridad previo al diseño. De esta forma se podrá definir cuál es sistema CCTV más adecuado a sus necesidades inmediatas, pero siempre teniendo en cuenta la escalabilidad a futuro.

    ReplyDelete