返回信息流VS2015+opencv3.2
解决方案配置里选release,程序可以正常运行,显示图像
但是选debug,程序运行直接闪退,也没有报错,就是本应该显示图像的对话框出现以下又马上消失,程序闪退
问题应该出现在程序靠后的一句:findContours(out, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
将这句注释掉,debug模式也会正常运行,就是图像正常显示
代码如下:
```
#include <opencv2\opencv.hpp>
#include <vector>
#include <math.h>
using namespace cv;
using namespace std;
int main()
{
Mat img = imread("1.jpg");
imshow("单灯", img);
int imgWidth = img.cols;
int imgHeight = img.rows;
double midWidth = imgWidth*0.5;
double midHeight = imgHeight*0.5;
int CutHeight = (int)((img.rows)*0.4);
Mat gray;
cvtColor(img, gray, CV_RGB2GRAY);
imshow("灰度化", gray);
Mat binary;
threshold(gray, binary, 50, 255, CV_THRESH_OTSU);
threshold(gray, binary, 50, 255, CV_THRESH_OTSU);
threshold(gray, binary, 50, 255, CV_THRESH_OTSU);
threshold(gray, binary, getThreshVal_Otsu(gray, binary), 255, CV_THRESH_BINARY);
threshold(gray, binary, getThreshVal_Otsu(gray, binary), 255, CV_THRESH_BINARY);
threshold(gray, binary, getThreshVal_Otsu(gray, binary), 255, CV_THRESH_BINARY);
imshow("二值", binary);
Mat element = getStructuringElement(MORPH_RECT, Size(5, 5));
Mat out;
erode(binary, out, element);
dilate(out, out, element);
imshow("开运算", out);
vector<vector<Point>> contours;
findContours(out, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
waitKey(0);
return 0;
}
```
这是一条镜像帖。来源:北邮人论坛 / cpp / #94348同步于 2017/1/8
CPP机器人发帖
解决方案配置里选release正常运行但选debug闪退是怎么回事?
singingwheat
2017/1/8镜像同步0 回复
订阅后,新回复会通过你的通知中心匿名送达。
0 条回复
暂无回复 · 你可以订阅本帖等待新回复。