opencv+codeblocks +anaconda

时间:2022-03-17 03:53:26

study from :

https://www.jianshu.com/p/c16b7c870356

 #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <opencv2\core\core.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>
using namespace std;
using namespace cv; #define ll long long const int maxn=1e4+;
const int inf=1e9;
const double eps=1e-; int main()
{
Mat img=imread("C:\\Users\\scientific\\Desktop\\test.jpg"); //两个'\'
imshow("test",img);
waitKey();
return ;
}
/* */

加入问价的路径要写对,否则运行程序,会出现

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)

 #include<opencv2/core/core.hpp>        // 核心组件
#include<opencv2/highgui/highgui.hpp> // GUI
#include<opencv2/imgproc/imgproc.hpp> // 图像处理

(study from : https://blog.csdn.net/francislucien2017/article/details/80962830)

imwrite  要加后缀名

前后两张图片大小不一样

cv::Mat img=imread("test1.jpg"); imwrite("test2.jpg",img);

无法使用imshow、cvtColor,不知道为什么

遇到控制台无法关闭,使用

opencv+codeblocks +anaconda

study from : https://blog.csdn.net/huyaoyu/article/details/80796442

+ - * / 重载运算符 更快

 #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2\core\core.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>
using namespace std;
using namespace cv; #define ll long long const int maxn=1e4+;
const int inf=1e9;
const double eps=1e-; int main()
{
Mat img=imread("test1.jpg");
// imwrite("test2.jpg",img); ///
Mat M(,, CV_8UC3, Scalar(,,));
cout << "M = " << endl << " " << M << endl << endl;
cout<<M.rows<<" "<<M.cols<<" "<<M.dims<<" "<<M.size()<<M.channels();
imwrite("test3.jpg",M); Mat gray_image;
cvtColor(M,gray_image,CV_BGR2GRAY); ///只有channels =3/4[4 透明度] 时才行
imwrite("test4.jpg",gray_image); ///
// Mat M1;
// M1.create(4,4, CV_8UC(2));
// cout << "M1 = "<< endl << " " << M1 << endl << endl; //求连通块,统计个数 opencv 读入图片,读出图片
///选择使用的连通块用红点标注 return ;
}
/* */

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