![](/img/trans.png)
[英]Exception In C# Code In Capturing Video From WebCam using Emgu CV 3.1 In Visual Studio 2015
[英]Error with Open CV v3.1 in Visual Studio C#
我正在做一個學校項目,需要使用OpenCV。
我嘗試使用OpenCV提供的“ findcontours”功能。 但是,當我調用該函數時,系統地出現錯誤,程序結束。 沒有給我任何建議或錯誤消息。
我把那部分會出錯的代碼放在那兒。 問我是否需要查看我的代碼中的其他內容。
/// <summary>
/// Detect the contour of the image.
/// </summary>
/// <param name="imgCannyEdges_loc">Image made with Canny.</param>
/// <returns>VectorOfVectorOfPointF</returns>
public VectorOfVectorOfPointF detectContourInImage(Image<Gray, byte> imgCannyEdges_loc)
{
VectorOfVectorOfPointF vvpfListOfPoints = new VectorOfVectorOfPointF();
CvInvoke.FindContours(imgCannyEdges_loc, vvpfListOfPoints, null, RetrType.List, ChainApproxMethod.ChainApproxNone);
return vvpfListOfPoints;
}
在這里,我將代碼的一部分放到我創建和更改圖像的位置。 我剛剛在上面給您提供的功能中將使用相同的圖像。
/// <summary>
/// Analysis with contour and with OpenCV.
/// </summary>
/// <param name="btmImage_loc">The bitmap of the image that the user wants to analys</param>
/// <param name="dblThreshold_loc">The threshold defined by the user.</param>
/// <param name="bReverse_loc">If the image needs to be reversed (black and white).</param>
/// <param name="bPreview_loc">If we are asking for a preview or not.</param>
/// <param name="iAnalysisPrecision_loc">The precision of the analysis.</param>
/// <returns>The image, resized, and with the different change.</returns>
public Image<Gray, Byte> thresholdingOpenCV(Bitmap btmImage_loc, double dblThreshold_loc,
bool bReverse_loc, bool bPreview_loc, int iAnalysisPrecision_loc)
{
Image<Bgr, Byte> imgResized_loc;
if (bPreview_loc == true)
{
imgResized_loc = new Image<Bgr, byte>(btmImage_loc).Resize(297, 210, Inter.Linear, true);
}
else
{
imgResized_loc = new Image<Bgr, byte>(btmImage_loc).Resize(297 * iAnalysisPrecision_loc,
210 * iAnalysisPrecision_loc, Inter.Linear, true);
}
Image<Gray, Byte> imgCannyEdges_loc =
(imgResized_loc.Convert<Gray, Byte>()).Canny(Math.Pow(dblThreshold_loc, 1.3), Math.Pow(dblThreshold_loc, 1.3));
imgCannyEdges_loc.SmoothGaussian(3);
if (bReverse_loc)
return imgCannyEdges_loc;
else
return imgCannyEdges_loc.Not();
}
在此先感謝您的幫助,如果有一些不清楚的地方,別忘了問我問題。
亞歷山大·沃爾法特
我發現了問題。 這與VectorOfVectorOf PointF有關 。 findcontours,不要搜索PointF而是Point 。 因此,請使用VectorOfVectorOf Point (而不是VectorOfVectorOf PointF )
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.