2012-03-08 3 views
1

캡처 한 video에서 LWUITImage을 생성하려고합니다. "CameraCanvas"에서비디오 캡처 문제

private void showCamera() // called when clicking the "open camera" command 
    { 
     try 
     { 
      Player mPlayer; 
      VideoControl mVideoControl; 
      mPlayer = Manager.createPlayer("capture://video"); 
      mPlayer.realize(); 
      mVideoControl = (VideoControl) mPlayer.getControl("VideoControl"); 
      Canvas canvas = new CameraCanvas(this, mVideoControl, mPlayer, getFirstAvailableRoot(), "ADC"+adcId); // adcId is "1" 
      isFromPositionnement = true; // static variable 
      javax.microedition.lcdui.Display.getDisplay(controler).setCurrent(canvas); 
      mPlayer.start(); 
     } catch (IOException ex) { 
      handleException(); 
     } catch (MediaException ex) { 
      handleException(); 
     } 
    } 

private String getFirstAvailableRoot() 
    { 
     short iter; 
     String root = "Phone:/"; 
     iter = 0; 
     Enumeration drives = FileSystemRegistry.listRoots(); 
     while(drives.hasMoreElements() && iter < 1) { 
      root = String.valueOf(drives.nextElement()); 
      iter++; 
     } 
     return root; 
    } 

코드 :

public class CameraCanvas extends Canvas implements CommandListener 
    { 
     ... 
     public CameraCanvas(Ecran form, VideoControl videoControl, Player pPlayer, String pRoot, String dossierPhoto) 
     { 
      ... 
      mCaptureCommand = new Command("Capturer", Command.SCREEN, 1); 
      addCommand(mCaptureCommand); 
      setCommandListener(this); 
      ... 
      videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this); 
      try 
      { 
       videoControl.setDisplayLocation(2, 2); 
       videoControl.setDisplaySize(width - 4, height - 4); 
      } 
      catch (MediaException me) 
      { 
       try 
       { 
        videoControl.setDisplayFullScreen(true); 
       } 
       catch (MediaException me2) 
       {} 
      } 
      videoControl.setVisible(true); 
     } 
     private void capture() // called when clicking the mCaptureCommand command 
     { 
      try 
      { 
       isPhotoCaptured = true; 
       rawImg = vidCtrl.getSnapshot(null); // this throws the exception 
       vidCtrl.setVisible(false); 
       vidCtrl = null; 
       mPlayer.close(); 
       mPlayer = null; 
       repaint(); 
      } 
      catch (MediaException me) 
      { 
       isPhotoCaptured = false; 
       rawImg = null; 
       vidCtrl.setVisible(false); 
       vidCtrl = null; 
       mPlayer.close(); 
       mPlayer = null; 
       handleException("capture "); 
      } 
     } 
    } 

가 그래서 문제의 원인이 될 수를 getSnapshot()를 호출 할 때 문제는 MediaException가 발생한다는 것입니다?

+0

Canvas/LCDUI에 대해 많이 알지 못합니다. ¿ LWUIT UI 요소를 사용할 수 있습니까? – frayab

+0

LWUIT로 변환하는 것이 어려울 것입니다! – pheromix

+0

나는 너와 같은 문제를 겪고있다. LWUIT에서 이미지를 캡처하는 방법에 대한 예제를 본다.이 도움이 되었길 바란다. http://stackoverflow.com/questions/7742397/how-to-capture-images-using-lwuit-videocomponent/7796680 # 7796680 – frayab

답변

1

MMAPI는 이미지를 만드는 기능을 가지고 있으며 LWUIT 이미지 (개체를 허용하는 만들기 이미지가 있음)로 쉽게 전환 할 수 있습니다. 그러나 어떤 이유로이 API를 생각해 낸 "천재"가 이미지 캡처를 통해 사용자의 개인 정보를 보호하는 제한된 API를 만들었습니다. 따라서 연산자/제조업체 서명없이이 API를 효과적으로 호출 할 수는 없습니다.