JMF 미디어 라이브러리가있는 Java에서 웹캠을 사용하는 개발중인 응용 프로그램에서 발생한 문제로 누군가 도와 주시면 좋겠습니다.Java Webcam GUI 응용 프로그램
오전 데 문제는 내가 원하는 곳에 내 GUI 응용 프로그램에 넣어 때 내가 그러나 여기이 클래스
import java.awt.BorderLayout;
import java.util.Vector;
import javax.media.CaptureDeviceInfo;
import javax.media.CaptureDeviceManager;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.media.control.FormatControl;
import javax.swing.JFrame;
import javax.swing.JButton;
public class WebcamClass{
CaptureDeviceInfo cam;
MediaLocator locator;
Player player;
FormatControl formatControl;
public WebcamClass(){
try{
// List out available Devices to Capture Video.
Vector<CaptureDeviceInfo> list = CaptureDeviceManager.getDeviceList (null);
System.out.println(list);
// Iterating list
for(CaptureDeviceInfo temp : list){
// Checking whether the current device supports VfW
// VfW = Video for Windows
if(temp.getName().startsWith("vfw:"))
{
System.out.println("Found : "+temp.getName().substring(4));
// Selecting the very first device that supports VfW
cam = temp;
System.out.println("Selected : "+cam.getName().substring(4));
break;
}
}
System.out.println("Put it on work!...");
// Getting the MediaLocator for Selected device.
// MediaLocator describes the location of media content
locator = cam.getLocator();
if(locator != null){
// Create a Player for Media Located by MediaLocator
player = Manager.createRealizedPlayer(locator);
if(player != null){
// Starting the player
player.start();
// Creating a Frame to display Video
JFrame f = new JFrame();
f.setTitle("Test Webcam");
f.setLayout(new BorderLayout());
// Adding the Visual Component to display Video captured by Player
// from URL provided by MediaLocator
f.add(player.getVisualComponent(), BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
}
}catch(Exception e){
System.out.println(e);
}
}
}
자체에 의해 응용 프로그램에서 웹캠 확인을 실행할 수있다 그것을 실행하려면 "스레드에서 예외"계속 AWT-EventQueue-0 "java.lang.NullPointerException"단추를 눌러 카메라를 켭니다.
웹캠 장치를 사용하지 않고 있지만 내 GUI에 포함시키지 않는 이유를 이해할 수 없다는 것을 알고 있습니다.
내 라이브러리 폴더에도 JMF.jar가 있습니다.
도움을 주시면 감사하겠습니다.