Calculate the area of an object with OpenCV

前端 未结 1 914
一整个雨季
一整个雨季 2020-12-15 11:01

I need to calculate the area of a blob/an object in a grayscale picture (loading it as Mat, not as IplImage) using OpenCV. I thought it would be a good idea to get

1条回答
  •  北荒
    北荒 (楼主)
    2020-12-15 11:34

    contours is actually defined as

    vector > contours;
    

    And now I think it's clear how to access its points.

    The contour area is calculated by a function nicely called contourArea():

    for (unsigned int i = 0;  i < contours.size();  i++)
    {
         std::cout << "# of contour points: " << contours[i].size() << std::endl;
    
         for (unsigned int j=0;  j

    0 讨论(0)
提交回复
热议问题