如何删除此错误“opencv_core.IplImage类型未定义方法getBufferedImage()”

时间:2016-07-31 13:09:23

标签: java opencv javacv face-recognition 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);
}

1 个答案:

答案 0 :(得分:0)

当我试图检测手时,我也遇到了同样的问题。我发现新的openCV版本没有org.bytedeco.opencv_core.IplImage类的方法getBufferedImage()。我发现这种方法可以帮我完成工作。

@Entity
@Getter
@NoArgsConstructor
public class Telemetry {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long pk;
    private String id;
    private String organizationId;
    private String baseType;
    private String name;
    private Double lat;
    private Double lon;
    private Instant updateTimestamp;
}

我希望这种方法可以帮助您解决问题。