0
JMF를 사용하여 USB 연결 웹캠 (Logitech Quickcam Pro 9000)에 연결하고 있습니다. 이 카메라는 최대 2MP의 비디오를 전송할 수 있지만 비디오 포맷을 320x240 이상으로 설정하는 데 문제가 있습니다.Java (JMF)로 웹캠 해상도 설정
MJPG, 320x240, Length=230400 0 extra bytes
YUV Video Format: Size = java.awt.Dimension[width=160,height=120] MaxDataLength = 38400 DataType = class [B yuvType = 32 StrideY = 320 StrideUV = 320 OffsetY = 0 OffsetU = 1 OffsetV = 3
YUV Video Format: Size = java.awt.Dimension[width=176,height=144] MaxDataLength = 50688 DataType = class [B yuvType = 32 StrideY = 352 StrideUV = 352 OffsetY = 0 OffsetU = 1 OffsetV = 3
YUV Video Format: Size = java.awt.Dimension[width=320,height=240] MaxDataLength = 153600 DataType = class [B yuvType = 32 StrideY = 640 StrideUV = 640 OffsetY = 0 OffsetU = 1 OffsetV = 3
YUV Video Format: Size = java.awt.Dimension[width=352,height=288] MaxDataLength = 202752 DataType = class [B yuvType = 32 StrideY = 704 StrideUV = 704 OffsetY = 0 OffsetU = 1 OffsetV = 3
YUV Video Format: Size = java.awt.Dimension[width=640,height=480] MaxDataLength = 614400 DataType = class [B yuvType = 32 StrideY = 1280 StrideUV = 1280 OffsetY = 0 OffsetU = 1 OffsetV = 3
MJPG, 160x120, Length=57600 0 extra bytes
MJPG, 176x144, Length=76032 0 extra bytes
MJPG, 352x288, Length=304128 0 extra bytes
MJPG, 640x480, Length=921600 0 extra bytes
이 내가 적어도 640 × 480의 캡처를 얻을 수있을 것입니다,하지만 난 심지어 작동시킬 수 없음을 알려줍니다 : 사용 가능한 형식을 인쇄하는 것은 나에게이 결과를 제공합니다. JMF에게 사용하고자하는 해상도를 어떻게 알려야합니까?
captureDeviceInfo = CaptureDeviceManager.getDevice(DEVICE_NAME);
Format[] formats = captureDeviceInfo.getFormats();
Format selectedFormat = null;
for(Format f : formats) {
if(f.toString().contains("width=640,height=480")) {
selectedFormat = f;
break;
}
}
try {
mediaLocator = captureDeviceInfo.getLocator();
DataSource videoDataSource = Manager.createDataSource(mediaLocator);
player = Manager.createRealizedPlayer(videoDataSource);
FormatControl fc = (FormatControl)player.getControl("javax.media.control.FormatControl");
fc.setFormat(selectedFormat);
player.start();