Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi! i am trying to create an application in java which will detect our faces through webcam. below is the code and error i am getting while running the code. kindly help.

package videocap;

import org.opencv.core.*; import org.opencv.highgui.Highgui;
import org.opencv.videoio.VideoCapture;

public class VideoCap {

public static void main(String[] args) {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    VideoCapture camera = new VideoCapture(0);

    if(!camera.isOpened()){
        System.out.println("Error");
    }
    else {
        Mat frame = new Mat();
        while(true){
            if (camera.read(frame)){
                System.out.println("Frame Obtained");
                System.out.println("Captured Frame Width " + 
                frame.width() + " Height " + frame.height());
                Highgui.imwrite("camera.jpg", frame);
                System.out.println("OK");
                break;
            }
        }   
    }
    camera.release();

}

}

ERROR: Frame Obtained Captured Frame Width 640 Height 480 Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: org.opencv.highgui.Highgui.imwrite at videocap.VideoCap.main(VideoCap.java:25)

click to hide/show revision 2
retagged

updated 2018-05-14 02:52:14 -0600

berak gravatar image

Hi! i am trying to create an application in java which will detect our faces through webcam. below is the code and error i am getting while running the code. kindly help.

package videocap;

import org.opencv.core.*; import org.opencv.highgui.Highgui;
import org.opencv.videoio.VideoCapture;

public class VideoCap {

public static void main(String[] args) {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    VideoCapture camera = new VideoCapture(0);

    if(!camera.isOpened()){
        System.out.println("Error");
    }
    else {
        Mat frame = new Mat();
        while(true){
            if (camera.read(frame)){
                System.out.println("Frame Obtained");
                System.out.println("Captured Frame Width " + 
                frame.width() + " Height " + frame.height());
                Highgui.imwrite("camera.jpg", frame);
                System.out.println("OK");
                break;
            }
        }   
    }
    camera.release();

}

}

ERROR: Frame Obtained Captured Frame Width 640 Height 480 Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: org.opencv.highgui.Highgui.imwrite at videocap.VideoCap.main(VideoCap.java:25)