1.文件名:opencvshowpicture
#include "opencv2/objdetect.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include <iostream>
using namespace std;
using namespace cv;
int main(int argc,char** argv)
{
char *inputName = argv[1];
cout << "name = " << inputName << endl;
Mat image = imread( inputName, 1 );//加载
imshow( inputName, image );//显示图片
waitKey(0);//等待
return 0;
}
2.Makefile
CXX ?= g++
CXXFLAGS += -c -Wall $(shell pkg-config --cflags opencv)
LDFLAGS += $(shell pkg-config --libs --static opencv)
name:=opencvshowpicture
all: $(name)
$(name): $(name).o; $(CXX) $< -o $@ $(LDFLAGS)
%.o: %.cpp; $(CXX) $< -o $@ $(CXXFLAGS)
clean: ; rm -f $(name).o $(name)
3.操作步骤
first ∗ ∗ m a k e ; . / o p e n c v s h o w p i c t u r e l e n a . p n g m a k e : N o t h i n g t o b e d o n e f o r ′ a l l ′ . n a m e = l e n a . p n g ∗ ∗ f i r s t ** make;./opencvshowpicture lena.png make: Nothing to be done for 'all'. name = lena.png **first ∗∗make;./opencvshowpicturelena.pngmake:Nothingtobedonefor′all′.name=lena.png∗∗first