I'm having the following error with the OpenCV library in Java:
OpenCV Error: Assertion failed (ssize.area ()> 0) in cv :: resize, file ........ \ opencv \ modules \ imgproc \ src \ imgwarp.cpp, line 1834 p>Code:
Mat img = new Mat();
// capturar primeiro frame do video
VideoCapture cap = new VideoCapture(Options.videoAtual);
cap.read(img);
// passar a imagem para tons de cinza
Mat grayImg = new Mat();
Imgproc.cvtColor(img, grayImg, Imgproc.COLOR_BGR2GRAY);
// aplicar filtro da media para reduzir os ruidos
Imgproc.medianBlur(grayImg, grayImg, 7);
Highgui.imwrite("tmp/img1.jpg", grayImg);
// aplicar transformada circular de hough
Mat circles = new Mat();
Imgproc.HoughCircles(grayImg, circles, Imgproc.CV_HOUGH_GRADIENT,1,20,
180,18,minRaio,maxRaio);
for (int x = 0; x < circles.cols(); x++) {
double vCircle[] = circles.get(0, x);
Point center = new Point(Math.round(vCircle[0]), Math.round(vCircle[1]));
int radius = (int) Math.round(vCircle[2]);
Centro = center;
Raio = radius;
// draw the circle outline
Core.circle(img, center, radius, new Scalar(0, 0, 255), 3, 8, 0);
}
Highgui.imwrite("houghcircles.jpg", img);