opencv+codeblocks +anaconda
study from :
https://www.jianshu.com/p/c16b7c870356
1 #include <cstdio> 2 #include <cstdlib> 3 #include <cmath> 4 #include <cstring> 5 #include <string> 6 #include <algorithm> 7 #include <set> 8 #include <map> 9 #include <queue> 10 #include <iostream> 11 #include <opencv2\core\core.hpp> 12 #include <opencv2\highgui\highgui.hpp> 13 #include <opencv2\imgproc\imgproc.hpp> 14 using namespace std; 15 using namespace cv; 16 17 #define ll long long 18 19 const int maxn=1e4+10; 20 const int inf=1e9; 21 const double eps=1e-8; 22 23 24 25 int main() 26 { 27 Mat img=imread("C:\\Users\\scientific\\Desktop\\test.jpg"); //两个'\' 28 imshow("test",img); 29 waitKey(0); 30 return 0; 31 } 32 /* 33 34 */
加入问价的路径要写对,否则运行程序,会出现
codeblocks error: ld returnd 1 exit status
即使你没用opencv也会出现这个问题,编译运行时会找那些内容,然后某个内容没有,就会报错。
图像一闪而过
waitKey (0);
waitKey()
①等待x ms,如果在此期间有按键按下,则立即结束并返回按键的ASCII码,否则返回-1;
②如果x=0,则无限等待下去,直到有按键按下;
【注】:在imshow之后,如果没有waitKey语句则不会显示图像。
(study from : https://jingyan.baidu.com/article/93f9803f522b5ce0e56f557c.html)
1 #include<opencv2/core/core.hpp> // 核心组件 2 #include<opencv2/highgui/highgui.hpp> // GUI 3 #include<opencv2/imgproc/imgproc.hpp> // 图像处理
(study from : https://blog.csdn.net/francislucien2017/article/details/80962830)
imwrite 要加后缀名
前后两张图片大小不一样
1 cv::Mat img=imread("test1.jpg"); 2 imwrite("test2.jpg",img);
无法使用imshow、cvtColor,不知道为什么
遇到控制台无法关闭,使用
study from : https://blog.csdn.net/huyaoyu/article/details/80796442
+ - * / 重载运算符 更快
1 #include <cstdio> 2 #include <cstdlib> 3 #include <cmath> 4 #include <cstring> 5 #include <string> 6 #include <algorithm> 7 #include <set> 8 #include <map> 9 #include <queue> 10 #include <iostream> 11 #include <opencv2/opencv.hpp> 12 #include <opencv2\core\core.hpp> 13 #include <opencv2\highgui\highgui.hpp> 14 #include <opencv2\imgproc\imgproc.hpp> 15 using namespace std; 16 using namespace cv; 17 18 #define ll long long 19 20 const int maxn=1e4+10; 21 const int inf=1e9; 22 const double eps=1e-8; 23 24 25 26 int main() 27 { 28 Mat img=imread("test1.jpg"); 29 // imwrite("test2.jpg",img); 30 31 ///3 32 Mat M(5,5, CV_8UC3, Scalar(0,0,255)); 33 cout << "M = " << endl << " " << M << endl << endl; 34 cout<<M.rows<<" "<<M.cols<<" "<<M.dims<<" "<<M.size()<<M.channels(); 35 imwrite("test3.jpg",M); 36 37 Mat gray_image; 38 cvtColor(M,gray_image,CV_BGR2GRAY); ///只有channels =3/4[4 透明度] 时才行 39 imwrite("test4.jpg",gray_image); 40 41 42 43 ///2 44 // Mat M1; 45 // M1.create(4,4, CV_8UC(2)); 46 // cout << "M1 = "<< endl << " " << M1 << endl << endl; 47 48 49 //求连通块,统计个数 opencv 读入图片,读出图片 50 ///选择使用的连通块用红点标注 51 52 return 0; 53 } 54 /* 55 56 */
opencv教程
背景 http://c.biancheng.net/opencv/
https://blog.csdn.net/w_k_l/article/details/74887145
https://blog.csdn.net/w_k_l/article/details/79644960
https://docs.opencv.org/master/d9/df8/tutorial_root.html
如mat : ttps://docs.opencv.org/master/d6/d6d/tutorial_mat_the_basic_image_container.html
github上的项目
opencv+anaconda
study from :
https://blog.csdn.net/iracer/article/details/80498732