我已经发现了轮廓,但问题是该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
推荐答案
您具备的功能 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的
发布评论