Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

Object detection and splitting, clustering?

$
0
0
I'm currently working on an application that will split a scanned image (that contains multiple receipts) into individual receipt images. Below is the sample image: ![image description](http://i.stack.imgur.com/zB7lw.jpg) I was able to detect the edges of each receipts in the scanned image using canny function. Below is the sample image with detected edges: ![image description](http://i.stack.imgur.com/nP3w0.jpg) ... while my sample code is Mat src = Highgui.imread(filename); Mat gray = new Mat(); int threshold = 12; Imgproc.cvtColor(src, gray, Imgproc.COLOR_BGR2GRAY); Imgproc.blur(gray, gray, new Size(3, 3)); Imgproc.Canny(gray, gray, threshold, threshold * 3, 3, true); List contours = new ArrayList<>(); Mat hierarchy = new Mat(); Imgproc.findContours(gray, contours, hierarchy, Imgproc.RETR_CCOMP, Imgproc.CHAIN_APPROX_SIMPLE); if (hierarchy.size().height > 0 && hierarchy.size().width > 0) { for (int idx = 0; idx >= 0; idx = (int) hierarchy.get(0, idx)[0]) { Rect rect = Imgproc.boundingRect(contours.get(idx)); Core.rectangle(src, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(255, 0, 0)); } } Now my problem is, I don't know how am I going to identify the 3rd receipt since unlike with the first 2 it is not enclosed in one rectangular shape which I will use as the basis for splitting the image. I've heard that for me to extract the 3rd image, I must use a clustering algorithm like DBSCAN, unfortunately I can't find one. Anyone knows how am I going to identify the 3rd image? Thank you in advance!

Viewing all articles
Browse latest Browse all 41027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>