标签:iostream include names could not gray read ... alt mes
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
Mat img1, img2, img3, img4, img5, img6, img_result, img_gray1, img_gray2, img_gray3, img_canny1, img_binary1, img_dist1, img_dist2, kernel_1, kernel_2, img_laplance, img_sharp;
char win1[] = "window1";
char win2[] = "window2";
char win3[] = "window3";
char win4[] = "window4";
char win5[] = "window5";
char win6[] = "window6";
char win7[] = "window7";
int thread_value = 100;
int max_value = 255;
RNG rng1(12345);
RNG rng2(1235);
int Demo_Harris();
void Demo_1(int, void*);
//Harris角点检测
int Demo_Harris()
{
namedWindow(win1, CV_WINDOW_AUTOSIZE);
//namedWindow(win2, CV_WINDOW_AUTOSIZE);
//namedWindow(win3, CV_WINDOW_AUTOSIZE);
img1 = imread("D://images//4//3.jpg");
//img2 = imread("D://images//1//p5_1.jpg");
if (img1.empty())
{
cout << "could not load image..." << endl;
return 0;
}
imshow(win1, img1);
cvtColor(img1, img2, CV_BGR2GRAY);
imshow(win2, img2);
createTrackbar("Track", win1, &thread_value, max_value, Demo_1);
Demo_1(0, 0);
return 0;
}
void Demo_1(int, void*)
{
img3 = Mat::zeros(img2.size(), CV_32FC1);
int blockSize = 2;
int kSize = 3;
double k = 0.04;
cornerHarris(img2, img3, blockSize, kSize, k, BORDER_DEFAULT);
//归一化处理
normalize(img3, img_dist1, 0, 255, NORM_MINMAX, CV_32FC1, Mat());
//
convertScaleAbs(img_dist1, img_dist2);
img4 = img1.clone();
for (size_t row = 0; row<img4.rows; row++)
{
uchar* now_row = img_dist2.ptr(row);//获取当前行
for (size_t col = 0; col<img4.cols; col++)
{
int value = (int)*now_row;
if (value>thread_value)
{
circle(img4, Point(col, row), 2, Scalar(rng1.uniform(0, 255), rng1.uniform(0, 255), rng1.uniform(0, 255)), 2, 8, 0);
}
now_row++;
}
}
imshow(win4, img4);
}
int main()
{
Demo_Harris();
waitKey(0);
return 0;
}
标签:iostream include names could not gray read ... alt mes
原文地址:https://www.cnblogs.com/herd/p/9740770.html