الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

video surveillance

مغلق
بدأه souad في 29 مايو 2007 · 3 رد · 1,646 مشاهدة · في JavaEE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم, لدي مشكلة في كود جافا الذي يهدف إلى مراقبة مكان ما بالكامرا , توصلت إلى تشغيل كاميرا واحدة وبقي لي تشغيل الاربعة معا.هل بإمكانكم مساعدتي?

import java.awt.event.*;

import java.awt.*;

import javax.swing.*;

import javax.swing.Timer;

import javax.swing.event.*;

import java .sql.*;

import java.io.*;

import java.util.*;

import java.util.Date;

import java.awt.image.*;

import javax.imageio.*;

import javax.media.*;

import javax.media.control.*;

import javax.media.format.*;

import javax.media.util.*;

import java.net.*;

import java.io.IOException;

import java.awt.print.*;

import java.util.Vector;

import java.net.URL;

import javax.media.datasink.*;

import javax.media.protocol.*;

class menu extends JFrame implements ActionListener, Runnable ,ControllerListener

{

private static JPanel videoPanel;

public static Player player;

public static Player playerm;

public Image img = null;

int blue,green,red;

int rgb;

public static String lo="file://c:\\vidéos/The Microsoft Sound.wav";

public static MediaLocator loc = new MediaLocator (lo);

private Control[] videoConts;

public Image_Draw p;

public static int t=0;

Container cont;// donner le nom cont au container

//permet d'afficher le panneau du controle du camera

private ControllerListener video_subsys = new ControllerListener()

{public void controllerUpdate(ControllerEvent cevnt)

{if (player.getState()==Player.Started)

{

//getContentPane().add(player.getVisualComponent()).setBounds(274,106,244,183);

getContentPane().add(player.getControlPanelComponent()).setBounds(270,472,484,18);

getContentPane().add(player.getControlPanelComponent()).setBackground(Color.white);

Control[] contlist = player.getControls();

for (jj=0;jj<contlist.length;jj++)

{if (contlist[jj]!=null&&contlist[jj].getControlComponent()!=null)

{

getContentPane().add(contlist[jj].getControlComponent()).setBounds(755,500,240,180);

}

}

}

} //end if

}; // end ControllerListener

//********************************************************************************************

//********************************************************************************************

//********************************************************************************************

//********************************************************************************************

//********************************************************************************************

//********************************************************************************************

//********************************************************************************************

//********************************************************************************************

//********************************************************************************************

int jj;

boolean test=true;

JMenuBar menu=new JMenuBar();

JMenu fichier= new JMenu(" Fichier ");

JMenu help= new JMenu(" ? ");

JMenuItem aide = new JMenuItem(" Aide ");

JMenuItem quitter = new JMenuItem(" Quitter ");

JMenuItem session = new JMenuItem(" Fermer la Session ");

JMenuItem passwd = new JMenuItem(" Changer le mot de passe ");

JMenuItem propos = new JMenuItem(" A propos ");

JMenuItem imprimer = new JMenuItem("Imprimer un Rapport ");

JMenu cntr= new JMenu("Gestion");

JMenuItem historique = new JMenuItem("Gestion des Fichiers ");

JMenuItem email = new JMenuItem("Gestions des Locaux ");

JMenuItem util = new JMenuItem("Gestions des Utilisateurs ");

JMenuItem camera = new JMenuItem("Gestions des Caméras ");

JMenu psys= new JMenu("Parametre System");

JMenuItem detcam = new JMenuItem(" Detection des Cam WIN32");

JMenuItem cntrv = new JMenuItem("Controle Volume");

JMenuItem dbd = new JMenuItem("Declaration Base de Donné ");

//JMenuItem crx = new JMenuItem(" Configuration du Réseaux");

JMenuItem tstper = new JMenuItem("Test Perfermance du System");

JMenuItem infos = new JMenuItem("Information System");

JLabel pp = new JLabel("CopyRight ISSAT 2005-2006");

JLabel rap = new JLabel(" Rapport du Configuration ");

JLabel select = new JLabel(" Selection des Caméras ");

JLabel op = new JLabel(" Options de Visualisation ");

ImageIcon img1 = new ImageIcon("tn10.jpg");

JLabel ph1= new JLabel(img1);

ImageIcon img2 = new ImageIcon("application du surveillance.gif");

JLabel ph2= new JLabel(img2);

ImageIcon img3 = new ImageIcon("non.gif");

JLabel non= new JLabel(img3);

JLabel non2= new JLabel(img3);

JLabel non3= new JLabel(img3);

JButton configuration = new JButton("configuration");

JButton capti = new JButton("Capturer Image");

JButton visui= new JButton("Visualiser Image ");

JButton captv = new JButton("Enrgistrer vidéo");

JButton visuv = new JButton("Visualiser vidéo");

JButton demare = new JButton("Demarer");

JButton arret = new JButton("Arreter");

JButton ech = new JButton ("");

JButton ecb = new JButton("");

JButton ecg = new JButton("");

JButton ecd = new JButton("");

JButton rh = new JButton ("");

JButton rb = new JButton("");

JButton rg = new JButton("");

JButton rd = new JButton("");

JButton rh1 = new JButton ("");

JButton rb22 = new JButton("");

JButton rg3 = new JButton("");

JButton rd4 = new JButton("");

JButton oh = new JButton ("");

JButton ob = new JButton("");

JButton og = new JButton("");

JButton od = new JButton("");

JButton cr1 = new JButton ("");

JButton cr2 = new JButton("");

JLabel pc1 = new JLabel("-N° Caméra :");

JLabel pc2 = new JLabel("-Nom du Caméra :");

JLabel pc3 = new JLabel("-Type Camera :");

JLabel pc4 = new JLabel("-Locale :");

JLabel pc5 = new JLabel("-Sensibilité :");

JLabel pc6 = new JLabel("-Temps du Connexion :");

JLabel pc7 = new JLabel("-Adresse IP Lcal :");

JLabel pc8 = new JLabel("-Adresse IP du Serveur SMS :");

JLabel pc9 = new JLabel("-Adresse IP du Serveur E-mail :");

JLabel ppc1 = new JLabel("test");

JLabel ppc2 = new JLabel("test");

JLabel ppc3 = new JLabel("test");

JLabel ppc4 = new JLabel("test");

JLabel ppc5 = new JLabel("test");

JLabel ppc6 = new JLabel("test");

JLabel ppc7 = new JLabel("test");

JLabel ppc8 = new JLabel("test");

JLabel ppc9 = new JLabel("test");

public static JSlider sliderr = new JSlider(JSlider.HORIZONTAL, 1, 256, 256);

JSlider sliderv = new JSlider(JSlider.HORIZONTAL, 1, 256,256);

JSlider sliderb = new JSlider(JSlider.HORIZONTAL, 1, 256, 256);

JLabel r = new JLabel("R");

JLabel v = new JLabel("V");

JLabel b = new JLabel("B");

JLabel pr = new JLabel("");

JLabel pv = new JLabel("");

JLabel pb = new JLabel("");

JLabel cam1 = new JLabel("Cam1:");

JLabel cam2 = new JLabel("Cam2:");

JLabel cam3 = new JLabel("Cam3:");

JLabel cam4 = new JLabel("Cam4:");

JButton opvn= new JButton("Mode de Nuit");

JButton opvp= new JButton("Rénitialiser");

JButton opve= new JButton("Fenetre Entiere");

JButton tser= new JButton("Temps Du Surveillance");

ButtonGroup groupe = new ButtonGroup();

JRadioButton rb1=new JRadioButton("Cam1",true);

JRadioButton rb2=new JRadioButton("Cam2");

JRadioButton rb3=new JRadioButton("Cam3");

JRadioButton rb4=new JRadioButton("Cam4");

JButton trst = new JButton ("RTP Transmission");

public static JProgressBar pbm1 = new JProgressBar(0, 100);

public static JProgressBar pbm2 = new JProgressBar(0, 100);

public static JProgressBar pbm3 = new JProgressBar(0, 100);

public static JProgressBar pbm4 = new JProgressBar(0, 100);

//********************************************************************************************

//********************************************************************************************

//declaration des composant de detection du mouvement

Object waitSync = new Object();

static Processor pros;

boolean stateTransitionOK = true;

static MotionDetectionEffect mde = new MotionDetectionEffect();

private static JPanel videoPanel1;

//********************************************************************************************

//********************************************************************************************

//************************************************************************************

//************************************************************************************

public void run(){}

public menu()

{

this.setTitle("VIDEO-SURVEILLANCE PAR INTERNET: Application du Surveillance ");// nom de la fenetre

getContentPane().setBackground(SystemColor.black);

cont=this.getContentPane();//appel de la methode getContentPane()

cont.setLayout(null);

this.setSize(this.getToolkit().getScreenSize());

setJMenuBar(menu);//declaration de menu

cont.add(fichier);// ajout du l'elements partie au conteneur

cont.add(help);

cont.add(aide);

cont.add(psys);

psys.setBackground(Color.black);

psys.setForeground(Color.white);

cont.add(detcam);

detcam.setBackground(Color.black);

detcam.setForeground(Color.white);

cont.add(cntrv);

cntrv.setBackground(Color.black);

cntrv.setForeground(Color.white);

cont.add(dbd);

dbd.setBackground(Color.black);

dbd.setForeground(Color.white);

/* cont.add(crx);

crx.setBackground(Color.black);

crx.setForeground(Color.white);*/

/*cont.add(tstper);

tstper.setBackground(Color.black);

tstper.setForeground(Color.white);

*/

cont.add(infos);

infos.setBackground(Color.black);

infos.setForeground(Color.white);

cont.add(quitter);

cont.add(propos);

cont.add(session);

cont.add(passwd);

cont.add(cntr);

cont.add(historique);

cont.add(email);

menu.setBackground(Color.black);

menu.setForeground(Color.white);

fichier.setBackground(Color.black);

fichier.setForeground(Color.white);

help.setBackground(Color.black);

help.setForeground(Color.white);

session.setBackground(Color.black);

session.setForeground(Color.white);

passwd.setBackground(Color.black);

passwd.setForeground(Color.white);

quitter.setBackground(Color.black);

quitter.setForeground(Color.white);

propos.setBackground(Color.black);

propos.setForeground(Color.white);

aide.setBackground(Color.black);

aide.setForeground(Color.white);

imprimer.setBackground(Color.black);

imprimer.setForeground(Color.white);

historique.setBackground(Color.black);

historique.setForeground(Color.white);

email.setBackground(Color.black);

email.setForeground(Color.white);

cntr.setBackground(Color.black);

cntr.setForeground(Color.white);

menu.add(fichier);

menu.add(psys);

menu.add(cntr);

menu.add(help);

//fichier.addSeparator();

fichier.add(passwd);

fichier.addSeparator();

fichier.add(session);

fichier.addSeparator();

fichier.add(quitter);

fichier.addSeparator();

fichier.add(imprimer);

fichier.addSeparator();

psys.add(detcam);

psys.addSeparator();

psys.add(cntrv);

psys.addSeparator();

psys.add(dbd);

psys.addSeparator();

// psys.add(crx);

// psys.addSeparator();

// psys.add(tstper);

// psys.addSeparator();

psys.add(infos);

psys.addSeparator();

// psys.addSeparator();

// cntr.addSeparator();

cntr.add(historique);

cntr.addSeparator();

cntr.add(email);

cntr.addSeparator();

cntr.add(util);

cntr.addSeparator();

cntr.add(camera);

cntr.addSeparator();

// help.addSeparator();

help.add(aide);

help.addSeparator();

help.add(propos);

help.addSeparator();

pp.setBounds(790,700,180,20);// defenir le dimension du label

cont.add(pp);// ajout du label au conteneur

pp.setForeground(Color.red);

rap.setBounds(05,90,160,20);// defenir le dimension du label

cont.add(rap);// ajout du label au conteneur

rap.setForeground(Color.white);

op.setBounds(780,90,160,20);// defenir le dimension du label

cont.add(op);// ajout du label au conteneur

op.setForeground(Color.white);

ech.setBounds(270,100,480,3);// defenir le dimension du label

cont.add(ech);// ajout du label au conteneur

ech.setForeground(Color.white);

ecb.setBounds(270,470,480,3);// defenir le dimension du label

cont.add(ecb);// ajout du label au conteneur

ecb.setForeground(Color.white);

ecg.setBounds(270,100,3,374);// defenir le dimension du label

cont.add(ecg);// ajout du label au conteneur

ecg.setForeground(Color.white);

ecd.setBounds(750,100,3,374);// defenir le dimension du label

cont.add(ecd);// ajout du label au conteneur

ecd.setForeground(Color.white);

cr1.setBounds(521,100,3,374);// defenir le dimension du label

cont.add(cr1);// ajout du label au conteneur

cr1.setForeground(Color.white);

cr2.setBounds(270,290,480,3);// defenir le dimension du label

cont.add(cr2);// ajout du label au conteneur

cr2.setForeground(Color.white);

rh.setBounds(160,100,70,3);// defenir le dimension du label

cont.add(rh);// ajout du label au conteneur

rh.setForeground(Color.white);

rb.setBounds(05,480,225,3);// defenir le dimension du label

cont.add(rb);// ajout du label au conteneur

rb.setForeground(Color.white);

rg.setBounds(05,100,3,381);// defenir le dimension du label

cont.add(rg);// ajout du label au conteneur

rg.setForeground(Color.white);

rd.setBounds(230,100,3,383);// defenir le dimension du label

cont.add(rd);// ajout du label au conteneur

rd.setForeground(Color.white);

oh.setBounds(932,99,70,3);// defenir le dimension du label

cont.add(oh);// ajout du label au conteneur

rh.setForeground(Color.white);

ob.setBounds(780,480,225,3);// defenir le dimension du label

cont.add(ob);// ajout du label au conteneur

ob.setForeground(Color.white);

og.setBounds(780,100,3,381);// defenir le dimension du label

cont.add(og);// ajout du label au conteneur

og.setForeground(Color.white);

od.setBounds(1001,100,3,383);// defenir le dimension du label

cont.add(od);// ajout du label au conteneur

od.setForeground(Color.white);

rh1.setBounds(151,495,78,3);// defenir le dimension du label

cont.add(rh1);// ajout du label au conteneur

rh1.setForeground(Color.white);

rb22.setBounds(05,677,225,3);// defenir le dimension du label

cont.add(rb22);// ajout du label au conteneur

rb22.setForeground(Color.white);

rg3.setBounds(05,495,3,183);// defenir le dimension du label

cont.add(rg3);// ajout du label au conteneur

rg3.setForeground(Color.white);

rd4.setBounds(230,495,3,183);// defenir le dimension du label

cont.add(rd4);// ajout du label au conteneur

rd4.setForeground(Color.white);

select.setBounds(05,486,160,20);// defenir le dimension du label

cont.add(select);// ajout du label au conteneur

select.setForeground(Color.white);

//ph1.setBounds(430,535,180,200);

//cont.add(ph1);

ph2.setBounds(210,-30,600,130);

cont.add(ph2);

demare.setBounds(390,500,120,30);

cont.add(demare);

demare.addActionListener(this);

demare.setBackground(Color.black);

demare.setForeground(Color.white);

arret.setBounds(530,500,120,30);

cont.add(arret);

arret.addActionListener(this);

arret.setBackground(Color.black);

arret.setForeground(Color.white);

arret.setEnabled(false);

configuration.setBounds(460,540,120,30);

cont.add(configuration);

configuration.addActionListener(this);

configuration.setBackground(Color.black);

configuration.setForeground(Color.white);

capti.setBounds(295,580,140,30);

cont.add(capti);

capti.addActionListener(this);

capti.setBackground(Color.black);

capti.setForeground(Color.white);

visui.setBounds(295,640,140,30);

cont.add(visui);

visui.addActionListener(this);

visui.setBackground(Color.black);

visui.setForeground(Color.white);

captv.setBounds(605,580,140,30);

cont.add(captv);

captv.addActionListener(this);

captv.setBackground(Color.black);

captv.setForeground(Color.white);

visuv.setBounds(605,640,140,30);

cont.add(visuv);

visuv.addActionListener(this);

visuv.setBackground(Color.black);

visuv.setForeground(Color.white);

fichier.addActionListener(this);

quitter.addActionListener(this);

aide.addActionListener(this);

help.addActionListener(this);

propos.addActionListener(this);

session.addActionListener(this);

passwd.addActionListener(this);

imprimer.addActionListener(this);

email.addActionListener(this);

historique.addActionListener(this);

util.addActionListener(this);

camera.addActionListener(this);

psys.addActionListener(this);

detcam.addActionListener(this);

cntrv.addActionListener(this);

dbd.addActionListener(this);

//crx.addActionListener(this);

// tstper.addActionListener(this);

infos.addActionListener(this);

cont.setBackground(SystemColor.black);

//**********************************************************************************************

//**********************************************************************************************

//**********************************************************************************************

// permet la capture du camera

try {

player = Manager.createPlayer(new MediaLocator("vfw:Microsoft WDM Image Capture (Win32):2"));

player.addControllerListener(video_subsys);

} catch(Exception e){

System.out.println(e);

JOptionPane.showMessageDialog(null," Camera N°1 est Déconnecté","Erreur",JOptionPane.ERROR_MESSAGE);

}

new Timer(100, new ActionListener(){

public void actionPerformed(ActionEvent e){

grab_proc();

p.repaint();

}

}).start();

player.start();

//**********************************************************************************************

//permet l'affichage d'image de la classe draw_image et le mettre dans la frame

p=new Image_Draw(this);

p.setBounds(274,106,244,183);//274,106,244,183

cont.add(p);

//****************************************************************************************

//music de demarage

try {

playerm = Manager.createPlayer (loc);

}

catch (NoPlayerException em) {

System.err.println ("No player: " + em);

}

catch (IOException em) {

System.err.println (em);

}

playerm.start ();

//**********************************************************************************************************

//**********************************************************************************************************

//------------Les labels et les connection avec la base pour le rapport du configuration--------------------

cont.add(pc1);

pc1.setBounds(15,120,90,15);

pc1.setBackground(Color.black);

pc1.setForeground(Color.gray);

cont.add(ppc1);

ppc1.setBounds(100,120,180,15);

ppc1.setBackground(Color.black);

ppc1.setForeground(Color.LIGHT_GRAY);

cont.add(pc2);

pc2.setBounds(15,155,115,15);

pc2.setBackground(Color.black);

pc2.setForeground(Color.gray);

cont.add(ppc2);

ppc2.setBounds(130,155,110,15);

ppc2.setBackground(Color.black);

ppc2.setForeground(Color.LIGHT_GRAY);

cont.add(pc3);

pc3.setBounds(15,195,120,15);

pc3.setBackground(Color.black);

pc3.setForeground(Color.gray);

cont.add(ppc3);

ppc3.setBounds(140,195,120,15);

ppc3.setBackground(Color.black);

ppc3.setForeground(Color.LIGHT_GRAY);

cont.add(pc4);

pc4.setBounds(15,235,70,15);

pc4.setBackground(Color.black);

pc4.setForeground(Color.gray);

cont.add(ppc4);

ppc4.setBounds(90,235,90,15);

ppc4.setBackground(Color.black);

ppc4.setForeground(Color.LIGHT_GRAY);

cont.add(pc5);

pc5.setBounds(15,275,100,15);

pc5.setBackground(Color.black);

pc5.setForeground(Color.gray);

cont.add(ppc5);

ppc5.setBounds(120,275,100,15);

ppc5.setBackground(Color.black);

ppc5.setForeground(Color.LIGHT_GRAY);

cont.add(pc6);

pc6.setBounds(15,315,150,15);

pc6.setBackground(Color.black);

pc6.setForeground(Color.gray);

cont.add(ppc6);

ppc6.setBounds(170,315,150,15);

ppc6.setBackground(Color.black);

ppc6.setForeground(Color.LIGHT_GRAY);

cont.add(pc7);

pc7.setBounds(15,350,170,15);

pc7.setBackground(Color.black);

pc7.setForeground(Color.gray);

cont.add(ppc7);

ppc7.setBounds(40,365,170,15);

ppc7.setBackground(Color.black);

ppc7.setForeground(Color.LIGHT_GRAY);

cont.add(pc8);

pc8.setBounds(15,390,180,15);

pc8.setBackground(Color.black);

pc8.setForeground(Color.gray);

cont.add(ppc8);

ppc8.setBounds(40,405,180,15);

ppc8.setBackground(Color.black);

ppc8.setForeground(Color.LIGHT_GRAY);

cont.add(pc9);

pc9.setBounds(15,430,180,15);

pc9.setBackground(Color.black);

pc9.setForeground(Color.gray);

cont.add(ppc9);

ppc9.setBounds(40,445,180,15);

ppc9.setBackground(Color.black);

ppc9.setForeground(Color.LIGHT_GRAY);

cont.add(non);

non.setBounds(570,142,100,100);

cont.add(non2);

non2.setBounds(570,325,100,100);

cont.add(non3);

non3.setBounds(350,325,100,100);

//****************************************************************************************

//****************************************************************************************

//****************************************************************************************

//****************************************************************************************

//****************************************************************************************

//--------------------chargement du valeur du rapport du configuration de notre base de donné---------

//********************************************************************************************************************

//------------------- chargement d'adresse IP local---------------------------------------------

try

{

InetAddress adrLocale = InetAddress.getLocalHost();

System.out.println("Adresse locale = "+adrLocale.getHostAddress());

String ip=adrLocale.getHostAddress();

ppc7.setText(""+ip);

} catch (Exception e)

{

e.printStackTrace();

}

int hr,min,sec;

GregorianCalendar d = new GregorianCalendar();

hr = d.get(Calendar.HOUR);

min = d.get(Calendar.MINUTE);

sec = d.get(Calendar.SECOND);

ppc6.setText(""+hr+" : "+min+" : "+sec );

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection connex=DriverManager.getConnection("jdbc:odbc:vsi");

Statement req0=connex.createStatement();

Statement req1=connex.createStatement();

Statement req2=connex.createStatement();

String gh0="SELECT * FROM configuration where ncam=1";

String gh1="SELECT * FROM srvsms";

String gh2="SELECT * FROM srvmail";

ResultSet resultat0= req0.executeQuery(gh0);

while(resultat0.next())

{

ppc1.setText(String.valueOf(resultat0.getInt(1)));

ppc2.setText(resultat0.getString(3));

ppc3.setText(resultat0.getString(2));

ppc4.setText(resultat0.getString(4));

ppc5.setText(String.valueOf(resultat0.getInt(5))+" %");

}

ResultSet resultat1= req1.executeQuery(gh1);

while(resultat1.next())

{

ppc8.setText(resultat1.getString(2));

}

ResultSet resultat2= req2.executeQuery(gh2);

while(resultat2.next())

{

ppc9.setText(resultat2.getString(2));

}

}

catch(Exception et)

{ System.out.println(et);

}

//****************************************************************************************

//****************************************************************************************

//****************************************************************************************

//****************************************************************************************

//****************************************************************************************

//**************************************************************************************************************

//---------------------------------------------------------------------------------------------------------------

//-----------------Configuration des option du Visualisation------------------------------------------------------

cont.add(sliderr);

sliderr.setBounds(820,150,150,30);

sliderr.setBackground(Color.black);

sliderr.setForeground(Color.white);

sliderr.setMajorTickSpacing(48);

sliderr.setMinorTickSpacing(16);

sliderr.setPaintTicks(true);

cont.add(sliderv);

sliderv.setBounds(820,190,150,30);

sliderv.setBackground(Color.black);

sliderv.setForeground(Color.white);

sliderv.setMajorTickSpacing(48);

sliderv.setMinorTickSpacing(16);

sliderv.setPaintTicks(true);

cont.add(sliderb);

sliderb.setBounds(820,230,150,30);

sliderb.setBackground(Color.black);

sliderb.setForeground(Color.white);

sliderb.setMajorTickSpacing(48);

sliderb.setMinorTickSpacing(16);

sliderb.setPaintTicks(true);

cont.add®;

r.setBounds(973,153,30,15);

r.setBackground(Color.black);

r.setForeground(Color.LIGHT_GRAY);

cont.add(v);

v.setBounds(973,193,30,15);

v.setBackground(Color.black);

v.setForeground(Color.LIGHT_GRAY);

cont.add(B);

b.setBounds(973,233,30,15);

b.setBackground(Color.black);

b.setForeground(Color.LIGHT_GRAY);

cont.add(pr);

pr.setBounds(800,153,30,15);

pr.setBackground(Color.black);

pr.setForeground(Color.LIGHT_GRAY);

pr.setText("256");

cont.add(pv);

pv.setBounds(800,193,30,15);

pv.setBackground(Color.black);

pv.setForeground(Color.LIGHT_GRAY);

pv.setText("256");

cont.add(pb);

pb.setBounds(800,233,30,15);

pb.setBackground(Color.black);

pb.setForeground(Color.LIGHT_GRAY);

pb.setText("256");

//*************l'ecouter de slider************************

//****************************************************************************************

//****************************************************************************************

sliderr.addChangeListener(new ChangeListener( )

{

public void stateChanged(ChangeEvent er)

{

Image_Draw.aa= sliderr.getValue( );

pr.setText(""+ sliderr.getValue( ));

}

}

);

sliderv.addChangeListener(new ChangeListener( )

{

public void stateChanged(ChangeEvent ev)

{

Image_Draw.bb=sliderv.getValue( );

pv.setText(""+ sliderv.getValue( ));

}

}

);

sliderb.addChangeListener(new ChangeListener( )

{

public void stateChanged(ChangeEvent eb)

{

Image_Draw.cc=sliderb.getValue( );

pb.setText(""+ sliderb.getValue( ));

}

}

);

//**************************************************************

//****************************************************************************************

//****************************************************************************************

cont.add(opvn);

opvn.setBounds(803,283,180,20);

opvn.setBackground(Color.black);

opvn.setForeground(Color.white);

opvn.addActionListener(this);

cont.add(opvp);

opvp.setBounds(803,333,180,20);

opvp.setBackground(Color.black);

opvp.setForeground(Color.white);

opvp.addActionListener(this);

cont.add(opve);

opve.setBounds(803,383,180,20);

opve.setBackground(Color.black);

opve.setForeground(Color.white);

opve.addActionListener(this);

cont.add(tser);

tser.setBounds(803,433,180,20);

tser.setBackground(Color.black);

tser.setForeground(Color.white);

tser.addActionListener(this);

rb1.setBounds(20,505,60,15);

rb1.setBackground(Color.black);

rb1.setForeground(Color.white);

groupe.add(rb1);

cont.add(rb1);

rb1.addActionListener(this);

rb2.setBounds(120,505,60,15);

rb2.setBackground(Color.black);

rb2.setForeground(Color.white);

groupe.add(rb2);

cont.add(rb2);

rb2.addActionListener(this);

rb3.setBounds(20,530,60,15);

rb3.setBackground(Color.black);

rb3.setForeground(Color.white);

groupe.add(rb3);

cont.add(rb3);

rb3.addActionListener(this);

rb4.setBounds(120,530,60,15);

rb4.setBackground(Color.black);

rb4.setForeground(Color.white);

groupe.add(rb4);

cont.add(rb4);

rb4.addActionListener(this);

pbm1.setValue(0);

pbm1.setStringPainted(true);

cont.add(pbm1);

pbm1.setBounds(60,560,160,20);

pbm1.setBackground(Color.black);

pbm1.setForeground(Color.red);

cont.add(cam1);

cam1.setBounds(15,560,50,20);

cam1.setBackground(Color.black);

cam1.setForeground(Color.white);

pbm2.setValue(0);

pbm2.setStringPainted(true);

cont.add(pbm2);

pbm2.setBounds(60,590,160,20);

pbm2.setBackground(Color.black);

pbm2.setForeground(Color.red);

cont.add(cam2);

cam2.setBounds(15,590,50,20);

cam2.setBackground(Color.black);

cam2.setForeground(Color.white);

pbm3.setValue(0);

pbm3.setStringPainted(true);

cont.add(pbm3);

pbm3.setBounds(60,620,160,20);

pbm3.setBackground(Color.black);

pbm3.setForeground(Color.red);

cont.add(cam3);

cam3.setBounds(15,620,50,20);

cam3.setBackground(Color.black);

cam3.setForeground(Color.white);

pbm4.setValue(0);

pbm4.setStringPainted(true);

cont.add(pbm4);

pbm4.setBounds(60,650,160,20);

pbm4.setBackground(Color.black);

pbm4.setForeground(Color.red);

cont.add(cam4);

cam4.setBounds(15,650,50,20);

cam4.setBackground(Color.black);

cam4.setForeground(Color.white);

cont.add(trst);

trst.setBounds(447,645,150,20);

trst.setBackground(Color.black);

trst.setForeground(Color.white);

trst.addActionListener(this);

}

//********************************************************************************************

//********************************************************************************************

//********************************************************************************************

//********************************************************************************************

//********************************************************************************************

//********************************************************************************************

//********************************************************************************************

//********************************************************************************************

//********************************************************************************************

//===========================la methode de actionperofrmed qui nous permet d'exectuer les action des boutons

//**************************************************************************************

////////////////////////////////////////////////////////////////////////////////////////

//***************************************************************************************

//****************************************************************************************

public void mDec() {

// DataSource ds = null;

pros=camera();

initComponents();

pros.addControllerListener(this);

pros.configure();

if (!waitForState(pros.Configured)) {

System.err.println("VSI ERReur lors du Configuration du processor.");

}

pros.setContentDescriptor(null);

TrackControl tc[] = pros.getTrackControls();

if (tc == null) {

System.err.println("ERREUR lors du chargement du Trac de processor.");

System.exit(0);

}

// Search for the track control for the video track.

TrackControl videoTrack = null;

for (int i = 0; i < tc.length; i++) {

if (tc.getFormat() instanceof VideoFormat) {

videoTrack = tc;

break;

}

}

if (videoTrack == null) {

System.err.println("VSI Le media d'entere ne contient pas de Video.");

System.exit(0);

}

try {

Codec codec[] = {mde};

videoTrack.setCodecChain(codec);

} catch (UnsupportedPlugInException e) {

System.err.println("le processor ne support pas des effects.");

}

pros.realize();

if (!waitForState(pros.Realized)) {

System.err.println("ERREUR lors du configuration du player");

System.exit(0);

}

pros.prefetch();

if(!waitForState(pros.Prefetched)){

System.err.println("ERREUR lors de prefetch player");

}

}

private Processor camera(){

Processor process;

Vector v = CaptureDeviceManager.getDeviceList(new VideoFormat(

VideoFormat.YUV));

try{

MediaLocator ml = ((CaptureDeviceInfo) v.get(0)).getLocator();

System.out.println(ml.toString());

process = Manager.createProcessor(ml);

return process;

}catch(Exception e){

System.err.println("VSI ERRRRRREUR");

e.printStackTrace();

System.exit(0);

}

return null;

}

private Processor file(String mediaFile){

Processor process;

String url = mediaFile;

if (url.indexOf(":") < 0) {

System.exit(0);

}

MediaLocator ml;

if ((ml = new MediaLocator(url)) == null) {

System.err.println("On ne peut pas charger le player de " + url);

System.exit(0);

}

try {

System.out.println("creation du processor");

process = Manager.createProcessor(ml);

return process;

}

catch (Exception e) {

System.err.println("EXCEPTION.....");

System.exit(0);

}

return null;

}

boolean waitForState(int state) {

synchronized (waitSync) {

try {

while (pros.getState() != state && stateTransitionOK)

waitSync.wait();

} catch (Exception e) {}

}

return stateTransitionOK;

}

public void controllerUpdate(ControllerEvent evt) {

System.out.println(this.getClass().getName()+evt);

if (evt instanceof ConfigureCompleteEvent ||

evt instanceof RealizeCompleteEvent ||

evt instanceof PrefetchCompleteEvent) {

synchronized (waitSync) {

stateTransitionOK = true;

waitSync.notifyAll();

}

} else if (evt instanceof ResourceUnavailableEvent) {

synchronized (waitSync) {

System.out.println("ResourceUnavailable");

stateTransitionOK = false;

waitSync.notifyAll();

}

} else if (evt instanceof EndOfMediaEvent) {

pros.close();

System.exit(0);

}

}

//*/****************************************************************

//Intialisation du graphique

private void initComponents()

{

GridBagConstraints gridBagConstraints;

videoPanel = new JPanel();

getContentPane().setLayout(null);

videoPanel.setBounds(274,106,244,183);

videoPanel.setLayout(null);

videoPanel.setPreferredSize(new Dimension(244, 183));

videoPanel.setAlignmentY(0.0F);

videoPanel.setAlignmentX(0.0F);

gridBagConstraints = new GridBagConstraints();

gridBagConstraints.gridx = 0;

gridBagConstraints.gridy = 0;

getContentPane().add(videoPanel, gridBagConstraints);

videoPanel.setBounds(274,106,244,183);

pack();

}

//*************************************************************************

//*************************************************************************

public void actionPerformed(ActionEvent e)

{

//*****************************************************************************

//*****************************************************************************

//++++++++++++++++++++++ action de la bouton demarer ++++++++++++++++++++++++++

//++++++++++++++++++ sert la demarage de la surveillance +++++++++++++++++++++

if (e.getSource()==demare )

{

player.close();

player.deallocate();

mDec ();

arret.setEnabled(true);

videoPanel.add(pros.getVisualComponent()).setBounds(0,0,244,183);

this.pack();

this.setSize(this.getToolkit().getScreenSize());

this.setVisible(true);

this.show();

System.out.println("DEBUT DE PLAYER");

pros.start();

}

//*****************************************************************************

//*****************************************************************************

//++++++++++++++ fin de l'action du bouton

//*****************************************************************************

//*****************************************************************************

//++++++++++++++ l'action du bouton du demarage du surveillance++++++++++++++++++

if (e.getSource()==arret )

{

if (JOptionPane.showConfirmDialog(quitter," Voulez vous arrêter la surveillance ? \n ","Quitter", JOptionPane.YES_NO_OPTION)==0)

{

pros.close();

pros.deallocate();

///**************************

//***************************

//.............................

/// permet la capture du camera

try {

player = Manager.createPlayer(new MediaLocator("vfw:Microsoft WDM Image Capture (Win32):2"));

player.addControllerListener(video_subsys);

} catch(Exception emm){

System.out.println(emm);

JOptionPane.showMessageDialog(null," Camera N°1 est Déconnecté","Erreur",JOptionPane.ERROR_MESSAGE);

}

new Timer(100, new ActionListener(){

public void actionPerformed(ActionEvent e){

grab_proc();

p.repaint();

}

}).start();

player.start();

//**********************************************************************************************

//permet l'affichage d'image de la classe draw_image et le mettre dans la frame

p=new Image_Draw(this);

p.setBounds(274,106,244,183);//274,106,244,183

cont.add(p);

//**************************************************************

//--------------------------------------------------------------**

}

else

{

}

}

//*****************************************************************************

//*****************************************************************************

//++++++++++++++ fin de l'action du bouton arret

//*bouton quitter-----------------------------------------------------------------------------

if (e.getSource()==quitter)

{

if (JOptionPane.showConfirmDialog(quitter," Voulez vous QUITTER ? \n ","Quitter", JOptionPane.YES_NO_OPTION)==0)

{

player.close();

player.deallocate();

System.exit(-1);//fermer la fenetre

}

else

{

}

}//quitter

if (e.getSource()==session)

{

player.close();

player.deallocate();

this.setVisible(false);

passwd ps = new passwd();

ps.setVisible(true);

}

//****************************************************************************************

//---------------Changement du mot de passe---------------------------

if (e.getSource()==passwd)

{

chpasswd cmp = new chpasswd();

cmp.setVisible(true);

}

//****************************************************************************************

//----------------le menu help------------------

if (e.getSource()==aide)

{

JOptionPane.showMessageDialog(null,"en travaille","Erreur",JOptionPane.ERROR_MESSAGE);

}

if (e.getSource()==propos)

{

try {

Runtime.getRuntime().exec("video.exe");

} catch (IOException pro) {

pro.printStackTrace();

}

}

//****************************************************************************************

//----------------------nous permet d'imprimer un rapport du configuration------------

if (e.getSource()==imprimer)

{

PrinterJob rapport = PrinterJob.getPrinterJob();

rapport.setPrintable(new imprimer22());

if (rapport.printDialog())

{

try

{

rapport.print();

}

catch (PrinterException ep)

{}

}

}

//****************************************************************************************

//-------------------nous permet d'afficher la framme du configuration---------------------

if (e.getSource()==configuration)

{

configuration mn=new configuration();

mn.setVisible(true);

}

//****************************************************************************************

//-------------------nous permet de capturer un image -----------------------------------

if (e.getSource()==capti)

{

try

{

Thread.sleep(1000);

// permet de capturer un image d'un flux vidéo

FrameGrabbingControl frameGrabber = (FrameGrabbingControl)player.getControl("javax.media.control.FrameGrabbingControl");

Buffer buf = frameGrabber.grabFrame();

// capturer l'image et le converte en BufferToImage et le sauvgarde

Image img = (new BufferToImage((VideoFormat)buf.getFormat()).createImage(buf));

BufferedImage buffImg = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB);

Graphics2D g = buffImg.createGraphics();

g.drawImage(img, null, null);

// Insertion du temps et la date

g.setColor(Color.RED);

g.setFont(new Font("Verdana", Font.BOLD, 16));

g.drawString((new Date()).toString(), 10, 25);

/* le procedure genrale de cette partie et de savgarde des images et mettre leurs noms dans fichier

"image.proprite" ou on peut apres les lire et gardans l'historique des images precedent*/

// defenir l'emplacement de sauvgarde de l'image et Faire Remplire les fichiers du configuration des images

//permet de lire la vlaeur max des images pour q'on attribue au nouvel image un nom différent

FileReader nr =new FileReader(new File("nb.txt"));

BufferedReader nrr = new BufferedReader(nr);

String i= nrr.readLine();

int k = Integer.parseInt(i); //conversion en entier

int j=k+1;//doner un nom didifferent k+1

ImageIO.write(buffImg, "png", new File("C://images/webcam"+j+".png"));//sauvgarde des images

FileWriter fichimg = new FileWriter(new File("imagenames.properties"),true);//ouverture d'un fichier en mode ecriture

PrintWriter fi=new PrintWriter(fichimg);

fi.print("webcam"+j+".png ");//sauvgarde du nom de l'image en gardant les autre nom

fi.close();

FileWriter nmb = new FileWriter(new File("nb.txt"));//mode ecriture de nb.txt

PrintWriter inb=new PrintWriter(nmb);//mise a jour du nb.txt

inb.println(+j);

inb.close();

}

catch(Exception tyui){

}

}

//****************************************************************************************

//----------------nous permet de visualiser une image capturer----------------------------

if (e.getSource()== visui)

{

JFrame frame = new JFrame("Visualisation des Images Capturés");

lectureimg lg = new lectureimg();

frame.getContentPane().add(lg.getSplitPane());

frame.pack();

frame.setVisible(true);

frame.setBackground(SystemColor.black);

}

//****************************************************************************************

//--------------------nous permet de capturer un video selon un temps preconfigurer

if (e.getSource()== captv)

{

//deallocation des resources

player.close();

player.deallocate();

TestCam bn = new TestCam();

bn.test();

}

//****************************************************************************************

//-------------------------visualiser un vidéo----------------------------------------

if (e.getSource()== visuv)

{

lectvideo lctv = new lectvideo();

lctv.setVisible(true);

}

//****************************************************************************************

//boutton du mode de nuit

if (e.getSource()==opvn)

{

Image_Draw.mdn=true;

}

//****************************************************************************************

//Bouton de renitialiser

if (e.getSource()==opvp)

{

player.start();

Image_Draw.mdn=false;

sliderr.setValue( 256);

sliderv.setValue( 256);

sliderb.setValue( 256);

}

//****************************************************************************************

//bouton du fenetre entiere

if (e.getSource()==opve)

{

JFrame fry =new JFrame();

fry.setBounds(400,400,400,400);

fry.setVisible(true);

fry.getContentPane().add(player.getVisualComponent()).setBounds(0,0,400,400);

}

//****************************************************************************************

//bouton du temps de surveillance

if (e.getSource()==tser)

{

try {

Runtime.getRuntime().exec("ShutdownTimer.exe");

} catch (IOException eserv) {

eserv.printStackTrace();

}

}

//**************************************************************************************

// menu de parametre system:---------------------detection du camera de win32

if (e.getSource()==detcam)

{

try {

Runtime.getRuntime().exec("wiaacmgr.exe");

} catch (IOException ecam1) {

ecam1.printStackTrace();

}

}

//**************************************************************************************

// menu de parametre system:---------------------controle de volume

if (e.getSource()==cntrv)

{

try {

Runtime.getRuntime().exec("sndvol32.exe");

} catch (IOException esnd) {

esnd.printStackTrace();

}

}

//**************************************************************************************

// menu de parametre system:---------------------declaration du base de donné

if (e.getSource()==dbd)

{

try {

Runtime.getRuntime().exec("odbcad32.exe");

} catch (IOException edbd) {

edbd.printStackTrace();

}

}

//**************************************************************************************

// menu de parametre system:---------------------configuration du rx

/* if (e.getSource()==crx)

{

try {

Runtime.getRuntime().exec("netsetup.exe");

} catch (IOException ecrx) {

ecrx.printStackTrace();

}

}

*/

//**************************************************************************************

// menu de parametre system:---------------------tester perfermance

/* if (e.getSource()==tstper)

{

try {

Runtime.getRuntime().exec("perfmon.exe");

} catch (IOException etstper) {

etstper.printStackTrace();

}

}

*/

//**************************************************************************************

// menu de parametre system:---------------------information system

if (e.getSource()==infos)

{

try {

Runtime.getRuntime().exec("winmsd.exe");

} catch (IOException einfos) {

einfos.printStackTrace();

}

}

//**************************************************************************************

if (e.getSource()==email)

{

configuration2 cmp4 = new configuration2();

cmp4.setVisible(true);

}

if (e.getSource()==util)

{

configuration1 cmp1 = new configuration1();

cmp1.setVisible(true);

}

if (e.getSource()==camera)

{

configuration4 cmp4 = new configuration4();

cmp4.setVisible(true);

}

if (e.getSource()==historique)

{

configuration3 cmp3 = new configuration3();

cmp3.setVisible(true);

}

//***********************************************************************************

//**********************************************************************************

//------------Activation du bouton de selection RADIOB>UTTON------------------------

//***********************************************************************************

//RADIO BUTTON

if (e.getSource()==rb1)

{

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection connex=DriverManager.getConnection("jdbc:odbc:vsi");

Statement req0=connex.createStatement();

String gh0="SELECT * FROM configuration where ncam=1";

ResultSet resultat0= req0.executeQuery(gh0);

while(resultat0.next())

{

ppc1.setText(String.valueOf(resultat0.getInt(1)));

ppc2.setText(resultat0.getString(3));

ppc3.setText(resultat0.getString(2));

ppc4.setText(resultat0.getString(4));

ppc5.setText(String.valueOf(resultat0.getInt(5))+" %");

}

}

catch(Exception etrb1)

{ System.out.println(etrb1);

}

}

//***********************************************************************************

//RADIO BUTTON

if (e.getSource()==rb2)

{

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection connex=DriverManager.getConnection("jdbc:odbc:vsi");

Statement req0=connex.createStatement();

String gh0="SELECT * FROM configuration where ncam=2";

ResultSet resultat0= req0.executeQuery(gh0);

while(resultat0.next())

{

ppc1.setText(String.valueOf(resultat0.getInt(1)));

ppc2.setText(resultat0.getString(3));

ppc3.setText(resultat0.getString(2));

ppc4.setText(resultat0.getString(4));

ppc5.setText(String.valueOf(resultat0.getInt(5))+" %");

}

}

catch(Exception etrb2)

{ System.out.println(etrb2);

}

}

//***********************************************************************************

//RADIO BUTTON

if (e.getSource()==rb3)

{

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection connex=DriverManager.getConnection("jdbc:odbc:vsi");

Statement req0=connex.createStatement();

String gh0="SELECT * FROM configuration where ncam=3";

ResultSet resultat0= req0.executeQuery(gh0);

while(resultat0.next())

{

ppc1.setText(String.valueOf(resultat0.getInt(1)));

ppc2.setText(resultat0.getString(3));

ppc3.setText(resultat0.getString(2));

ppc4.setText(resultat0.getString(4));

ppc5.setText(String.valueOf(resultat0.getInt(5))+" %");

}

}

catch(Exception etrb3)

{ System.out.println(etrb3);

}

}

//***********************************************************************************

//RADIO BUTTON 4

if (e.getSource()==rb4)

{

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection connex=DriverManager.getConnection("jdbc:odbc:vsi");

Statement req0=connex.createStatement();

String gh0="SELECT * FROM configuration where ncam=4";

ResultSet resultat0= req0.executeQuery(gh0);

while(resultat0.next())

{

ppc1.setText(String.valueOf(resultat0.getInt(1)));

ppc2.setText(resultat0.getString(3));

ppc3.setText(resultat0.getString(2));

ppc4.setText(resultat0.getString(4));

ppc5.setText(String.valueOf(resultat0.getInt(5))+" %");

}

}

catch(Exception etrb4)

{ System.out.println(etrb4);

}

}

if (e.getSource()==trst)

{

player.close();

player.deallocate();

RTPServerTest serverTest = new RTPServerTest();

serverTest.setSize( 350, 70 );

serverTest.setLocation( 300, 300 );

serverTest.setDefaultCloseOperation( EXIT_ON_CLOSE );

serverTest.setVisible( true );

}

}

//--------------------------fin de actionperformed---------------------------------------

//****************************************************************************************

//****************************************************************************************

//****************************************************************************************

void grab_proc(){

FrameGrabbingControl frameGrabber

=(FrameGrabbingControl)player.getControl("javax.media.control.FrameGrabbingControl");

Buffer buf = frameGrabber.grabFrame();

BufferToImage b2i = new BufferToImage((VideoFormat)buf.getFormat());

img = b2i.createImage(buf);

// System.out.println(img);

}

public static void main(String[] args) {

menu mn = new menu();

mn.setVisible(true);

}

}

class Image_Draw extends JApplet

{

menu F;

int i=0;

public static int aa=256;

public static int bb=256;

public static int cc=256;

public static boolean mdn=false;

Image_Draw (menu f)

{

F=f;

}

public void paint(Graphics g){

i++;

if(null == F.img) return;

else

{

BufferedImage orig = new BufferedImage(F.img.getWidth(null), F.img.getHeight(null), BufferedImage.TYPE_INT_RGB);

Graphics2D g2 = orig.createGraphics();

g2.drawImage(F.img, null, null);

for(int i = 0; orig.getHeight() > i; i++){

for(int j = 0; orig.getWidth() > j; j++){

F.rgb = orig.getRGB(j, i);

F.blue = F.rgb % aa;

F.rgb >>= 8;

F.green = F.rgb % bb;

F.rgb >>= 8;

F.red = F.rgb % cc;

F.red = 255 - F.red;

F.green = 255 - F.green;

F.blue =255 - F.blue;

if(mdn==true)

{

orig.setRGB(j, i,(F.red << 16)|(F.green << 8)| F.blue);

}

}

}

Graphics2D g2x =(Graphics2D)(F.img.getGraphics());

g2x.drawImage(orig, null, 0, 0);

g.drawImage(F.img, 0,0, 244, 183, null);

}

}

}

#2

دا open source :P

#3

هل تريد تشغيل اربع كاميرات على نفس الجهاز ؟؟

منقطع من حين لاخر

#4

yes, lazem achaghel 3al a9al 2 cameras,

i must use threads

هذا الموضوع مغلق.

مواضيع مشابهة