C#项目断点调试时提示:当前不会命中断点,还没有为该文档加载任何符号
有时候编译C#项目的时候,会遇到断电无法进行调试的情况,提示“当前不会命中断点,还没有为该文档加载任何符号”,如下图所示:
这种情况下,一般都是在调用第三方类库时出现的,需要重新编译此类文件,具体操作如下:
1、打开此断点的类文件,例如我此时的类文件名称是OpencvSharpPoints;
2、点击菜单:生成,在下面依次点击清理OpencvSharpForm、重新生成OpencvSharpForm,如下图所示:
3、然后重新编译项目即可。
4、调试的代码如下:
public List<ShootPoint> PicConventPoint(Mat img)
{
List<ShootPoint> shootpointList = new List<ShootPoint>();
try
{
//var img = Cv2.ImRead(imgPath);
//var img = Cv2.ImRead(@"F\point.jpg");
//var img = Cv2.ImRead(@"F:\point.jpg");
//Mat img = BitmapConverter.ToMat(Byte2Bitmap(picByte));
//Mat img = new Mat(720,1280, MatType.CV_8UC3, picByte); // make a copy
//Cv2.ImShow("ThresholdTypes1", img);
//转化为灰度
Mat gray = img.CvtColor(ColorConversionCodes.BGR2GRAY);
//阀值操作(二值化)
Mat ThresholdImg = gray.Threshold(200, 255, ThresholdTypes.Binary);
// Cv2.ImShow("ThresholdTypes", ThresholdImg);
//Cv2.GaussianBlur(gray, ThresholdImg, new Size(7, 7), 0);
//高斯滤波 降噪
//Cv2.ImShow("高斯滤波", ThresholdImg);
//寻找图像轮廓
OpenCvSharp.Point[][] contours;
HierarchyIndex[] hierachy;
Cv2.FindContours(ThresholdImg, out contours, out hierachy, RetrievalModes.List, ContourApproximationModes.ApproxTC89KCOS);
根据找到的轮廓点,拟合椭圆
for (int i = 0; i < contours.Length; i++)
{
double AreaSize = Cv2.ContourArea(contours[i]);
if (AreaSize < 100)//面积太小 则忽略
{
continue;
}
//拟合函数必须至少5个点,少于则不拟合
if (contours[i].Length < 5) continue;
//椭圆拟合
var rrt = Cv2.FitEllipse(contours[i]);
//ROI复原
rrt.Center.X += 0;
rrt.Center.Y += 0;
ShootPoint pt = new ShootPoint();
pt.px = (int)(rrt.Center.X);
pt.py = (int)(rrt.Center.Y);
pt.size = (int)AreaSize;
pt.time = DateTime.Now;
画椭圆
//Cv2.Ellipse(img, rrt, new Scalar(0, 0, 255), 2, LineTypes.AntiAlias);
画圆心
//Cv2.Circle(img, (int)(rrt.Center.X), (int)(rrt.Center.Y), 4, new Scalar(255, 0, 0), -1, LineTypes.Link8, 0);
if (Config.g_blCalibration == true)
{
shootpointList.Add(CameraToTarget.SetCalibrationTargetPoint(pt));
}
else
{
shootpointList.Add(CameraToTarget.GetTargetPoint(pt));
}
break;
}
if(shootpointList.Count <= 0)
{
ShootPoint pt = new ShootPoint
{
px = 0,
py = 0,
size = 0,
};
shootpointList.Add(pt);
}
//Cv2.ImShow("Fit Circle", img);
//Cv2.WaitKey(30);
//shootpointList = shootpointList.OrderByDescending(ShootPoint => ShootPoint.size).ToList();
}
catch (Exception e)
{
MessageBox.Show(e.Message.ToString() + " " + e.ToString());
img.Release();
}
img.Release();
return shootpointList;
}
}