2016-01-30 2 views
0

Я пытаюсь найти самый большой объект в своем двоичном образе. Я использовал код here в строке 52, но я получил ошибку на FindContours, как показано ниже.Невозможно использовать «FindContours» с EmguCV в C#

Что не так в моем коде? и Есть ли другой способ найти объект имеет большую площадь в двоичном образе?

enter image description here

ответ

0

ли обновление до 3.0? Это вызовет проблему, и это довольно распространенное явление (см. Мой ответ здесь: Emgu CV 3 findContours and hierarchy parameter of type Vec4i equivalent?). В основном, из того, что я видел, команда Emgu еще не перенесла все функциональные возможности в самые новые версии, поэтому некоторые вещи, которые работали в 2.X, нужно будет переделать.

Если вы хотите использовать эту функциональность, вы можете напрямую вызвать метод FindContours:

/// <summary> 
/// Find contours using the specific memory storage 
/// </summary> 
/// <param name="method">The type of approximation method</param> 
/// <param name="type">The retrieval type</param> 
/// <param name="stor">The storage used by the sequences</param> 
/// <returns> 
/// Contour if there is any; 
/// null if no contour is found 
/// </returns> 
public static VectorOfVectorOfPoint FindContours(this Image<Gray, byte> image, ChainApproxMethod method = ChainApproxMethod.ChainApproxSimple, 
    Emgu.CV.CvEnum.RetrType type = RetrType.List) { 
    // Check that all parameters are valid. 
    VectorOfVectorOfPoint result = new VectorOfVectorOfPoint(); 

    if (method == Emgu.CV.CvEnum.ChainApproxMethod.ChainCode) { 
     throw new ColsaNotImplementedException("Chain Code not implemented, sorry try again later"); 
    } 

    CvInvoke.FindContours(image, result, null, type, method); 
    return result; 
} 
Смежные вопросы