编译opencv2.4.9
来源:互联网 发布:天尚网络机顶盒 编辑:程序博客网 时间:2024/06/05 15:17
终于,在填了不少坑后,编译通过了。
编译命令
mkdir buildcd buildcmake .. -DENABLE_PRECOMPILED_HEADERS=OFFmake -j32
然而
cmake配置文件
cmake_minimum_required(VERSION 3.7)project(study_opencv)set(CMAKE_CXX_STANDARD 14)set(CMAKE_MODULE_PATH /home/pikachu/dev/opencv-2.4.9/build)set(CMAKE_PREFIX_PATH /home/pikachu/dev/opencv-2.4.9/build)FIND_PACKAGE(OpenCV REQUIRED)include_directories(include)aux_source_directory(src DIRSRCS)set(SOURCE_FILES main.cpp)add_executable(study_opencv ${SOURCE_FILES} ${DIRSRCS})target_link_libraries(study_opencv ${OpenCV_LIBS})
cpp代码
#include <stdio.h>#include <iostream>#include <cvaux.h>#include "opencv2/core/core.hpp"//因为在属性中已经配置了opencv等目录,所以把其当成了本地目录一样#include "opencv2/features2d/features2d.hpp"#include "opencv2/highgui/highgui.hpp"#include "opencv2/nonfree/features2d.hpp"using namespace cv;using namespace std;void readme();int main(int argc,char* argv[]){ Mat img_1=imread("/home/pikachu/Desktop/1.png",CV_LOAD_IMAGE_GRAYSCALE);//宏定义时CV_LOAD_IMAGE_GRAYSCALE=0,也就是读取灰度图像 Mat img_2=imread("/home/pikachu/Desktop/2.png",CV_LOAD_IMAGE_GRAYSCALE);//一定要记得这里路径的斜线方向,这与Matlab里面是相反的 if(!img_1.data || !img_2.data)//如果数据为空 { cout<<"opencv error"<<endl; return -1; } cout<<"open right"<<endl;//第一步,用SURF算子检测关键点 int minHessian=400; SurfFeatureDetector detector(minHessian); std::vector<KeyPoint> keypoints_1,keypoints_2;//构造2个专门由点组成的点向量用来存储特征点 detector.detect(img_1,keypoints_1);//将img_1图像中检测到的特征点存储起来放在keypoints_1中 detector.detect(img_2,keypoints_2);//同理//在图像中画出特征点 Mat img_keypoints_1,img_keypoints_2; drawKeypoints(img_1,keypoints_1,img_keypoints_1,Scalar::all(-1),DrawMatchesFlags::DEFAULT); drawKeypoints(img_2,keypoints_2,img_keypoints_2,Scalar::all(-1),DrawMatchesFlags::DEFAULT); imshow("surf_keypoints_1",img_keypoints_1); imshow("surf_keypoints_2",img_keypoints_2);//计算特征向量 SurfDescriptorExtractor extractor;//定义描述子对象 Mat descriptors_1,descriptors_2;//存放特征向量的矩阵 extractor.compute(img_1,keypoints_1,descriptors_1); extractor.compute(img_2,keypoints_2,descriptors_2);//用burte force进行匹配特征向量 BruteForceMatcher<L2<float>>matcher;//定义一个burte force matcher对象 vector<DMatch>matches; matcher.match(descriptors_1,descriptors_2,matches);//绘制匹配线段 Mat img_matches; drawMatches(img_1,keypoints_1,img_2,keypoints_2,matches,img_matches);//将匹配出来的结果放入内存img_matches中//显示匹配线段 imshow("surf_Matches",img_matches);//显示的标题为Matches waitKey(0); return 0;}
然后报错
/home/pikachu/src/c++/test/study_opencv/cmake-build-debug/study_opencvopen rightOpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file /home/pikachu/dev/opencv-2.4.9/modules/highgui/src/window.cpp, line 501terminate called after throwing an instance of 'cv::Exception' what(): /home/pikachu/dev/opencv-2.4.9/modules/highgui/src/window.cpp:501: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvShowImageProcess finished with exit code 6
安装依赖
sudo apt install libgtk2.0-devsudo apt install pkg-config
重新编译
然后就可以了
阅读全文
0 0
- Opencv2.4.9交叉编译
- opencv2.4.9交叉编译
- Opencv2.4.9交叉编译
- 交叉编译OpenCV2.4.9
- 编译opencv2.4.9
- VS2010编译配置opencv2.4.9
- Opencv2.4.9交叉编译+拍照
- ubuntu14.04编译opencv2.4.9
- 解决VS2012编译OpenCV2.4.9,error C3859
- Ubuntu13.10下编译安装opencv2.4.9
- Ubuntu14.04 下 OpenCV2.4.9 编译
- opencv2.4.9安装编译及调试
- VS2010重编译OpenCV2.4.9调试源代码
- Ubuntu14.04 Opencv2.4.9交叉编译
- Qt5.4.2Mingw编译配置opencv2.4.9
- 海思3515,交叉编译opencv2.4.9
- VS2010 + CUDA7.5 + GPU编译OpenCV2.4.9
- 交叉编译Opencv2.4.9完全实录
- App开放接口api安全性—Token签名sign的设计与实现
- Mycat之——读写分离+垂直切分+水平切分+er分片+全局表 测试
- win7下DOS环境下安装MYSQL(有改动)
- 面向对象基础
- Github的使用
- 编译opencv2.4.9
- Kotlin数据类型
- String和StringBuffer的区别
- html的下拉列表和表格
- Android 手势
- R语言数据清洗与规整-回归模型为例
- 设计模式(十四)Singleton
- 2017-07-10(JS)
- 选择框的样式,