image processing - Java -OpenCV Error: Assertion failed while running FaceRecognition Program -
this question has answer here:
- opencv 3.0.0 facedetect sample fails 6 answers
i new opencv. link got java sample program face detection . encountered problems installed opencv 3.0 version , code 2.4.6 version. anyway errors solved changed code as
system.loadlibrary(core.native_library_name); system.out.println("\nrunning facedetector"); cascadeclassifier facedetector = new cascadeclassifier(facedetection.class.getresource("/resources/xmls/haarcascade_frontalface_alt.xml").getpath()); mat image = imgcodecs.imread(facedetection.class.getresource("/resources/testimages/facetest.jpg").getpath()); matofrect facedetections = new matofrect(); facedetector.detectmultiscale(image, facedetections); system.out.println(string.format("detected %s faces", facedetections.toarray().length)); (rect rect : facedetections.toarray()) { imgproc.rectangle(image, new point(rect.x, rect.y), new point(rect.x + rect.width, rect.y + rect.height), new scalar(0, 255, 0)); } string filename = "/resources/testimages/facerecognised.jpg"; system.out.println(string.format("writing %s", filename)); imgcodecs.imwrite(filename, image);
but unfortunately there occuring exception while running. stacktrace below:
running facedetector opencv error: assertion failed (!empty()) in cv::cascadeclassifier::detectmultiscale, file c:\builds\master_packslaveaddon-win64-vc12-static\opencv\modules\objdetect\src\cascadedetect.cpp, line 1595 exception in thread "main" cvexception [org.opencv.core.cvexception: cv::exception: c:\builds\master_packslaveaddon-win64-vc12-static\opencv\modules\objdetect\src\cascadedetect.cpp:1595: error: (-215) !empty() in function cv::cascadeclassifier::detectmultiscale ] @ org.opencv.objdetect.cascadeclassifier.detectmultiscale_1(native method) @ org.opencv.objdetect.cascadeclassifier.detectmultiscale(cascadeclassifier.java:103) @ com.bq.opencv.facedetection.main(facedetection.java:31)
please help.
hi corrected tried giving absolute path , removing xml files , images classpath.
cascadeclassifier facedetector = new cascadeclassifier("c:/opencv/opencv/sources/data/haarcascades/haarcascade_frontalface_alt.xml");
instead of
cascadeclassifier facedetector = new cascadeclassifier(facedetection.class.getresource("/resources/xmls/haarcascade_frontalface_alt.xml").getpath());
and : mat image = imgcodecs.imread("c:/xyz/pqr/facetest.jpg");
Comments
Post a Comment