簡體   English   中英

創建一個矩形數組:Opencv,Android

[英]Create an array of Rectangles : Opencv , Android

我有從findcontours()中提取的輪廓,現在我想創建一個所有輪廓邊界的數組。

int area,total=0;

for(int i=0; i<contours.size(); i++)
{
    area = (int) Imgproc.contourArea(contours.get(i));

    if(area>4600 && area<5100)
    {
        Rect abc = Imgproc.boundingRect(contours.get(i));                          
    }
}

這里它在Rect中只保存了一個輪廓,我想要一個所有輪廓的Rect數組。

那應該更好:

int area,total=0;
List<Rect> contourRects = new ArrayList();

for(int i=0; i<contours.size(); i++)
{
    area = (int) Imgproc.contourArea(contours.get(i));

    if(area>4600 && area<5100)
    {
        contourRects.add(Imgproc.boundingRect(contours.get(i)));                          
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM