2016-07-31 65 views
0

這是我的代碼。它繼續顯示此消息「方法getBufferedImage()未定義類型opencv_core.IplImage」。我怎樣才能擺脫它?有沒有其他的方式獲得緩衝圖像?如果有人有任何想法,請儘快告訴我如何清除此錯誤「方法getBufferedImage()未定義類型opencv_core.IplImage」

public IplImage snapIm = null; 
public Rectangle faceRect; 
public void paintComponent(Graphics g){ 
     super.paintComponent(g); 
     Graphics2D g2 = (Graphics2D) g; 

     if (snapIm != null) 
      g2.drawImage(snapIm.getBufferedImage(), 0, 0, this); //This Line is causing problem 

     drawRect(g2); 
     writeStats(g2); 
     writeName(g2); 
} 
public void recogFace(IplImage img) 
{ 
    BufferedImage clipIm = null; 
    synchronized(faceRect) { 
     if (faceRect.width == 0) { 
      System.out.println("No face selected"); 
      return; 
     } 
     clipIm = ImageUtils.clipToRectangle(img.getBufferedImage(),faceRect.x, faceRect.y, faceRect.width, faceRect.height); //This Line is causing problem 
    } 
    if (clipIm != null) 
    matchClip(clipIm); 
} 

回答

0

我也有同樣的問題,當我試圖檢測手。我發現新的openCV版本沒有org.bytedeco.opencv_core.IplImage類的getBufferedImage()方法。我發現這種方法爲我做了工作。

public static BufferedImage IplImageToBufferedImage(IplImage src) { 
    OpenCVFrameConverter.ToIplImage grabberConverter = new OpenCVFrameConverter.ToIplImage(); 
    Java2DFrameConverter paintConverter = new Java2DFrameConverter(); 
    Frame frame = grabberConverter.convert(src); 
    return paintConverter.getBufferedImage(frame,1); 
} 

我希望這種方法能幫助你解決你的問題。

相關問題