linux下编译opencv库所用的命令(main.cpp为源文件,main为生成文件)
gcc main.cpp -o main -ggdb `pkg-config opencv --cflags --libs` -lm -lstdc++
linux下编译opencv与串口通信库所用的命令(det.cpp为源文件,det为生成文件)
gcc -ggdb `pkg-config opencv --cflags --libs` det.cpp rs232.cpp -o det -lm -lstdc++
linux安装opencv所需安装的库
sudo apt-get install opencv-doc libcv4 libhighgui4 libcvaux4 libcv-dev libcvaux-dev libhighgui-dev libgtk2.0-dev
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev cmake libswscale-dev libjasper-dev
sudo apt-get install libopencv-dev
test code
#include "opencv2/opencv.hpp" #include<iostream> using namespace cv; using namespace std; int main(){ Mat img; img=imread("src.bmp"); imshow("show",img); //imwrite("imgthres.jpg",img); waitKey(0); return 0; }