I am trying to executing OpenCV application executable in riscv linux but i am getting error "terminate called after throwing an instance of 'cv::Exception'"
I have cross complied OpenCV library statically for riscv architecture and successfully compiled OpenCV application (redEyeRemoval).After that i have added compiled object file and images to riscv-linux root file system.now i am trying to executing output object file from root file system.now i am getting error.
Command for cross compiling OpenCV library statically :--
$ cmake -DCMAKE_TOOLCHAIN_FILE=../riscv.toolchain.cmake ../../.. -DWITH_PNG=OFF -DWITH_OPENEXR=OFF -DBUILD_OPENEXR=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_EXE_LINKER_FLAGS="-static"
Makefile for cross compiling OpenCV appliction (redEyeRemoval) :--
CXX =riscv64-unknown-linux-gnu-g++
CXXFLAGS += -c -Wall $(shell pkg-config --cflags --libs --static /home/billa/Downloads/opencv-3.4.2/platforms/linux/riscv_build/install/lib/pkgconfig/opencv.pc) LDFLAGS += $(shell pkg-config --cflags --libs --static /home/billa/Downloads/opencv-3.4.2/platforms/linux/riscv_build/install/lib/pkgconfig/opencv.pc)
all:removeRedEyes
removeRedEyes: removeRedEyes.o; $(CXX) $< -o $@ $(LDFLAGS) -static
%.o: %.cpp; $(CXX) $< -o $@ $(CXXFLAGS) -static
clean: ; rm -f removeRedEyes.o removeRedEyes
Error :--
# /opencv/red/removeRedEyes
/opencv/red/removeRedEyes
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(3.4.2) /home/billa/Downloads/opencv-3.4.2/modules/objdetect/src/cascadedetect.cpp:1698: error: (-215:Assertion failed) !empty() in function 'detectMultiScale'
Aborted
RedEyeRemoval.cpp code :
enter code here
/* Copyright 2017 by Satya Mallick ( Big Vision LLC ) http://www.learnopencv.com */
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
void fillHoles(Mat &mask)
{
/*
This hole filling algorithm is decribed in this post
https://www.learnopencv.com/filling-holes-in-an-image-using-opencv-python-c/
*/
Mat maskFloodfill = mask.clone();
floodFill(maskFloodfill, cv::Point(0,0), Scalar(255));
Mat mask2;
bitwise_not(maskFloodfill, mask2);
mask = (mask2 | mask);
}
int main(int argc, char** argv )
{
// Read image
Mat img = imread("red_eyes2.jpg",CV_LOAD_IMAGE_COLOR);
// Output image
Mat imgOut = img.clone();
// Load HAAR cascade
CascadeClassifier eyesCascade("haarcascade_eye.xml");
// Detect eyes
std::vector<Rect> eyes;
eyesCascade.detectMultiScale( img, eyes, 1.3, 4, 0 |CASCADE_SCALE_IMAGE, Size(100, 100) );
// For every detected eye
for( size_t i = 0; i < eyes.size(); i++ )
{
// Extract eye from the image.
Mat eye = img(eyes[i]);
// Split eye image into 3 channels.
vector<Mat>bgr(3);
split(eye,bgr);
// Simple red eye detector
Mat mask = (bgr[2] > 150) & (bgr[2] > ( bgr[1] + bgr[0] ));
// Clean mask -- 1) File holes 2) Dilate (expand) mask
fillHoles(mask);
dilate(mask, mask, Mat(), Point(-1, -1), 3, 1, 1);
// Calculate the mean channel by averaging
// the green and blue channels
Mat mean = (bgr[0]+bgr[1])/2;
mean.copyTo(bgr[2], mask);
mean.copyTo(bgr[0], mask);
mean.copyTo(bgr[1], mask);
// Merge channels
Mat eyeOut;
cv::merge(bgr,eyeOut);
// Copy the fixed eye to the output image.
eyeOut.copyTo(imgOut(eyes[i]));
}
// Display Result
imshow("Red Eyes", img);
imshow("Red Eyes Removed", imgOut);
waitKey(0);
}
It seems that your cascade file is empty. Have you use this code to load cascade file ?
no i didn't used.can u tell me how to use and where.
Thanks for reply
Can you post your code in your question (use edit button)?
please go through my code once i have posted code