在学习的过程中,借鉴了很多的网上大牛的知识成果。今天终于自己写成功了一个简单的程序,算是对自己学习的小小的总结,也算是与大家分享一下成果。
其中,在opencv向pc linux和arm linux移植的过程中,主要学习了这两位大牛写的过程。链接是:
http://hi.baidu.com/guzhou_diaoke/item/4ea3e431fcb2e0b2633afff7#713670-baidu-1-12972-a19db458d50b3e9d45067067b6ce7d52
http://blog.chinaunix.net/uid-28613314-id-3627661.html
在详细的阅读和理解的基础上,实现了这个过程。
然后,自己编写了一段非常简单的程序。测试了一下。
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
int main()
{
IplImage* inputimage=NULL;
IplImage* outputimage=NULL;
CvPoint point1;
CvPoint point2;
CvScalar color=CV_RGB(0,0,255);
point1.x=50;
point1.y=50;
point2.x=400;
point2.y=400;
inputimage=cvLoadImage("image_bmp.bmp",0);
outputimage=cvCreateImage(cvGetSize(inputimage),IPL_DEPTH_8U,1);
cvLine(outputimage,point1,point2,color,50,8,0);
cvSaveImage("outputimage.bmp",outputimage);
return 0;
}
程序的编译在pc linux执行的,arm-linux-g++ -I/usr/local/opencv-arm/include -L/usr/local/opencv-arm/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann -lpthread -lrt cannytest.cpp -o cannytest
生成的执行文件cannytest复制到arm linux当中,执行./cannytest.(其中,image_bmp.bmp是事先存在arm linux当中的,程序会生成一个outputimage.bmp的图片,将这个图片传回到windows电脑上,可以看到结果。)
上面这张图片就是image_bmp.bmp
这一张图片就是outputimage.bmp。