如何排序从顶部到底部的轮廓:opencv的,Android的 [英] How to sort contours from top to bottom : Opencv , Android

查看:1887
本文介绍了如何排序从顶部到底部的轮廓:opencv的,Android的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经发现了轮廓,但问题是该findcontours()返回轮廓以随机顺序像在轮廓(0)它显示从页面的中间部分sontour。我怎么可以垂直对它们进行排序?从上到下,然后从左向右?下面给出我水平连接的组件连接着各个MCQ与他们的选择,然后应用findcontours(图像),现在我想他们,他们应该按顺序检索的进行排序

I have found the contour but the problem is that the findcontours() returns contours in random order like at contour(0) it shows some sontour from middle of the page. How can I sort them vertically? From top to bottom and then left to right? Given the image below I connected the components horizontally and connected every MCQ with their choices and then applied findcontours() and Now I want to sort them in an order that they should be retrieved sequentially

推荐答案

您具备的功能<一个href=\"http://docs.opencv.org/java/org/opencv/imgproc/Imgproc.html#boundingRect%28org.opencv.core.MatOfPoint%29\"相对=nofollow> boundingRect :有了,你可以找到的点周围的矩形边框的左上点。然后,你可以定义一个排序功能,基于这点对于每个轮廓的位置定购轮廓。

You have the function boundingRect: With that you can find the topleft point of a bounding rectangle around the points. Then you can define a sorting function that orders the contours based on the location of this point for each contour.

这篇关于如何排序从顶部到底部的轮廓:opencv的,Android的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆