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. [closed]

asked 2018-05-14 01:32:42 -0600

nikshita gravatar image

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

berak gravatar image

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)

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by berak
close date 2018-05-15 03:48:55.827026

Comments

which opencv version did you try with ?

are you using some weird ide, like netbeans ? (try to ggl the error !)

berak gravatar imageberak ( 2018-05-14 01:52:00 -0600 )edit

OpenCV 3.4.1 and is it something wrong with using Netbeans? btw i am using Netbeans8.2

nikshita gravatar imagenikshita ( 2018-05-14 04:31:02 -0600 )edit

then you have to use Imgcodecs.imwrite() instead.

please also look at the SO answers above to fix your netbeans problem

berak gravatar imageberak ( 2018-05-14 05:40:19 -0600 )edit

hey! Thanks a lot. it worked.

nikshita gravatar imagenikshita ( 2018-05-15 03:44:09 -0600 )edit