Bonjour,
J'ai un petit soucis avec l'ide netbeans.
En fait à la fac on nous a fait travailler sur un projet java, où on traite des images capturées avec la webcam.
Le soucis c'est que ni à la fac(linux) ni sur mon ordinateur(windows) je n'arrive à détecter la webcam.
A la fac on a compilé dans le terminal et on a exécuté dans le terminal et cela marche sans problème.
voici mon code.CaptureDeviceInfo periphCaptureVideo=null;
VideoFormat formatCaptureVideo=null;
MediaLocator maVideo=null;
DataSource videoDataSource=null;
Vector listePeriph=CaptureDeviceManager.getDeviceList(null);
for(int i=0;i<listePeriph.size();i++){
CaptureDeviceInfo infoPeriph = (CaptureDeviceInfo) listePeriph.elementAt(i);
String nomPeriph = infoPeriph.getName();
System.out.println(nomPeriph);
Format formatPeriph[] = infoPeriph.getFormats();
for(int j=0;j<formatPeriph.length;j++){
if(formatPeriph[j] instanceof VideoFormat){
periphCaptureVideo = infoPeriph;
formatCaptureVideo = (VideoFormat) formatPeriph[j];
}
}
}
maVideo = periphCaptureVideo.getLocator();
et voici l'erreur. Et quand je clique sur l'erreur cela me ramène a ma dernière ligne de code : maVideo = periphCaptureVideo.getLocator();.Exception in thread "main" java.lang.NullPointerException
at TPM2.<init>(TPM2.java:56)
at TPM2.main(TPM2.java:125)
Java Result: 1
Comme vous pouvez le voir sous Netbeans je compile sans problème le code mais c'est son exécution qui marche pas.
Alors j'ai compris que je n'arrivé pas a détecter ma wencam dans mon code mais je ne comprend pas pourquoi il ne la détecte pas alors qu'elle est branché.
C'est le même problème sous windows et sous linux.
Si je ne suis pas assez clair, dites le moi.
Merci pour l'aide que vous pourrez m'apporter.
Partager