Java Webcam Auflösung ändern

$name

Grünschnabel
Hallo,
ich wollte die Auflösung der Webcam ändern mit

Code:
CaptureDeviceInfo camDeviceInfo = CaptureDeviceManager.getDevice("vfw:Microsoft WDM Image Capture (Win32):0"); 
					 
if(camDeviceInfo == null)
{
  System.out.println("Keine Kamera gefunden");
}

try
{  	        	    	
  Player player = Manager.createRealizedPlayer(camDeviceInfo.getLocator ());
  	    
  Format[] formats = camDeviceInfo.getFormats();  	    		
  	    	
  FormatControl fc = (FormatControl)player.getControl( "javax.media.control.FormatControl" );

  fc.setFormat((VideoFormat)formats[4]);
  	    	  	     	    	
  player.start();
  	        
  try
    {
      Thread.sleep(5000);
    }
   catch(Exception e1)
    {     	
    }

  FrameGrabbingControl frameGrabber = (FrameGrabbingControl)player.getControl("javax.media.control.FrameGrabbingControl");             
  	      
  buf = frameGrabber.grabFrame();    	
  Image img = (new BufferToImage((VideoFormat)buf.getFormat()).createImage(buf));



Webcam Details:
Code:
Name = vfw:Microsoft WDM Image Capture (Win32):0

Locator = vfw://0

Output Formats---->

0. javax.media.format.RGBFormat
  RGB, 320x240, Length=230400, 24-bit, Masks=3:2:1, PixelStride=3, LineStride=960, Flipped
1. javax.media.format.RGBFormat
  RGB, 160x120, Length=57600, 24-bit, Masks=3:2:1, PixelStride=3, LineStride=480, Flipped
2. javax.media.format.RGBFormat
  RGB, 176x144, Length=76032, 24-bit, Masks=3:2:1, PixelStride=3, LineStride=528, Flipped
3. javax.media.format.RGBFormat
  RGB, 352x288, Length=304128, 24-bit, Masks=3:2:1, PixelStride=3, LineStride=1056, Flipped
4. javax.media.format.RGBFormat
  RGB, 640x480, Length=921600, 24-bit, Masks=3:2:1, PixelStride=3, LineStride=1920, Flipped
5. javax.media.format.YUVFormat
  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


Als Format wollte ich 640x480p. Das Problem ist das img immer null ist.
Ich hoffe ihr könnt mir helfen den Fehler zu finden

MfG $name
 
Zuletzt bearbeitet:

Neue Beiträge

Zurück