糟糕的操作数类型 - Java

时间:2013-09-30 11:58:41

标签: java operand

Project: HERE link to the project

我正在尝试使用此开源代码,但我收到以下错误:

error: bad operand type for binary operator '!='

在此背景下:

if (img != null) {
    cvFlip(img, img, 1);// l-r = 90_degrees_steps_anti_clockwise
    cvSaveImage((i++) + "-capture.jpg", img);
    // show image on window
    canvas.showImage(img);
}

以下是整个班级:

package pdlwebcam;

import com.googlecode.javacv.CanvasFrame;
import com.googlecode.javacv.FrameGrabber;
import com.googlecode.javacv.VideoInputFrameGrabber;
import com.googlecode.javacv.cpp.opencv_core.IplImage;

public class PDLWebcam implements Runnable {
    //final int INTERVAL=1000;///you may use interval

    IplImage image;
    CanvasFrame canvas = new CanvasFrame("Web Cam");

    public PDLWebcam() {
        canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
    }

    @Override
    public void run() {
        FrameGrabber grabber = new VideoInputFrameGrabber(0);
        int i = 0;
        try {
            grabber.start();
            IplImage img;
            while (true) {
                img = grabber.grab();
                if (img != null) {
                    cvFlip(img, img, 1);// l-r = 90_degrees_steps_anti_clockwise
                    cvSaveImage((i++) + "-capture.jpg", img);
                    // show image on window
                    canvas.showImage(img);
                }
                //Thread.sleep(INTERVAL);
            }
        } catch (Exception e) {
        }
    }
}

1 个答案:

答案 0 :(得分:1)

我为cvFlipcvSaveImage方法创建了存根实现,并且编译时没有任何错误。不过,Netbeans无论如何都会显示Bad operand错误消息。它看起来像IDE本身的一个错误。

解决方法:我注意到IplImage类来自com.googlecode.javacpp.Pointer,这对Netbeans是不可见的。将javacpp添加到项目库有助于删除错误消息。