原文链接:https://blog.csdn.net/qq_42318305/article/details/82047845
1.安装前的准备(安装OpenCV的依赖库)
sudo apt-get install git libgtk2.0-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
1
2
参考链接:
(https://blog.csdn.net/chang_shuang/article/details/78239660)
注:一定要装,不然后面会报错。
2.正式安装
跳转链接:
(https://blog.csdn.net/Mmagic1/article/details/79761824)
3. 配置及测试
(1)新建一个C++项目;
(2)在.pro文件中加入如下路径:
INCLUDEPATH += /usr/local/include \
/usr/local/include/opencv \
/usr/local/include/opencv2
LIBS += /usr/local/lib/libopencv_highgui.so \
/usr/local/lib/libopencv_core.so \
/usr/local/lib/libopencv_imgproc.so \
/usr/local/lib/libopencv_imgcodecs.so\
(3)main.cpp代码如下(读取图片+腐蚀+模糊+canny边缘检测):
#include
#include
#include
using namespace cv;
using namespace std;
int main()
{
Mat Image=imread("lena.jpg");
imshow("view",Image);
Mat element=getStructuringElement(MORPH_RECT,Size(15,15));
Mat dstImage;
erode(Image,dstImage,element);
imshow("view1",dstImage);
Mat dstImage1;
blur(Image,dstImage1,Size(7,7));
imshow("view2",dstImage1);
Mat dstImage2,edge,grayImage;
dstImage2.create(Image.size(),Image.type());
cvtColor(Image,grayImage,COLOR_BGR2GRAY);
blur(grayImage,edge,Size(3,3));
Canny(edge,edge,3,9,3);
imshow("canny",edge);
waitKey(0);
return 0;
}
1.安装前的准备(安装OpenCV的依赖库)
sudo apt-get install git libgtk2.0-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
参考链接:
(https://blog.csdn.net/chang_shuang/article/details/78239660)
注:一定要装,不然后面会报错。
2.正式安装
跳转链接:
(https://blog.csdn.net/Mmagic1/article/details/79761824)
3. 配置及测试
(1)新建一个C++项目;
(2)在.pro文件中加入如下路径:
INCLUDEPATH += /usr/local/include \
/usr/local/include/opencv \
/usr/local/include/opencv2
LIBS += /usr/local/lib/libopencv_highgui.so \
/usr/local/lib/libopencv_core.so \
/usr/local/lib/libopencv_imgproc.so \
/usr/local/lib/libopencv_imgcodecs.so\
(3)main.cpp代码如下(读取图片+腐蚀+模糊+canny边缘检测):
#include
#include
#include
using namespace cv;
using namespace std;
int main()
{
Mat Image=imread("lena.jpg");
imshow("view",Image);
Mat element=getStructuringElement(MORPH_RECT,Size(15,15));
Mat dstImage;
erode(Image,dstImage,element);
imshow("view1",dstImage);
Mat dstImage1;
blur(Image,dstImage1,Size(7,7));
imshow("view2",dstImage1);
Mat dstImage2,edge,grayImage;
dstImage2.create(Image.size(),Image.type());
cvtColor(Image,grayImage,COLOR_BGR2GRAY);
blur(grayImage,edge,Size(3,3));
Canny(edge,edge,3,9,3);
imshow("canny",edge);
waitKey(0);
return 0;
}
注:图片放在release或debug文件夹下。
4.运行效果图
1.安装前的准备(安装OpenCV的依赖库)
sudo apt-get install git libgtk2.0-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
参考链接:
(https://blog.csdn.net/chang_shuang/article/details/78239660)
注:一定要装,不然后面会报错。
2.正式安装
跳转链接:
(https://blog.csdn.net/Mmagic1/article/details/79761824)
3. 配置及测试
(1)新建一个C++项目;
(2)在.pro文件中加入如下路径:
INCLUDEPATH += /usr/local/include \
/usr/local/include/opencv \
/usr/local/include/opencv2
LIBS += /usr/local/lib/libopencv_highgui.so \
/usr/local/lib/libopencv_core.so \
/usr/local/lib/libopencv_imgproc.so \
/usr/local/lib/libopencv_imgcodecs.so\
(3)main.cpp代码如下(读取图片+腐蚀+模糊+canny边缘检测):
#include
#include
#include
using namespace cv;
using namespace std;
int main()
{
Mat Image=imread("lena.jpg");
imshow("view",Image);
Mat element=getStructuringElement(MORPH_RECT,Size(15,15));
Mat dstImage;
erode(Image,dstImage,element);
imshow("view1",dstImage);
Mat dstImage1;
blur(Image,dstImage1,Size(7,7));
imshow("view2",dstImage1);
Mat dstImage2,edge,grayImage;
dstImage2.create(Image.size(),Image.type());
cvtColor(Image,grayImage,COLOR_BGR2GRAY);
blur(grayImage,edge,Size(3,3));
Canny(edge,edge,3,9,3);
imshow("canny",edge);
waitKey(0);
return 0;
}
注:图片放在release或debug文件夹下。
注:图片放在release或debug文件夹下。
4.运行效果图
这里写图片描述
---------------------
作者:易水向西
来源:CSDN
原文:https://blog.csdn.net/qq_42318305/article/details/82047845
版权声明:本文为博主原创文章,转载请附上博文链接!