Opencv
http://docs.opencv.org/trunk/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.html
cmake
http://www.wakayama-u.ac.jp/~chen/cmake/cmakecv.html
そのままですが前提.
gcc,OpenCV,CMakeインストール済み。
ステップ
1.MyLine.cpp
2.CMake file CMakeLists.txt
3.cmake make
4.Run
Using OpenCV with gcc and CMake
Note We assume that you have successfully installed OpenCV in your workstation.
The easiest way of using OpenCV in your code is to use CMake. A few advantages (taken from the Wiki):
No need to change anything when porting between Linux and Windows
Can easily be combined with other tools by CMake( i.e. Qt, ITK and VTK )
If you are not familiar with CMake, checkout the tutorial on its website.
Steps
Create a program using OpenCV
Let’s use a simple program such as DisplayImage.cpp shown below.
参考:http://opencv.jp/cookbook/opencv_drawing.html
少々、追加、変更しています。
//MyLine.cpp
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
int
main(int argc, char *argv[])
{
Mat img = Mat::zeros(800, 900, CV_8UC3);
// Red,太さ3,4近傍連結
line(img, Point(100, 100), Point(400, 105), Scalar(0,0,200), 3, 4);
// Green,太さ5,8近傍連結
line(img, Point(100, 200), Point(400, 205), Scalar(0,200,0), 5, 8);
// Blue,太さ10,アンチエイリアス
line(img, Point(100, 300), Point(400, 305), Scalar(200,0,0), 10, CV_AA);
//add by ggggnonaka start
//White Line 1,4
line(img, Point(100, 400), Point(800, 400), Scalar(255,255,255), 1, 4);
//Red Line 1,4
line(img, Point(100, 500), Point(800, 500), Scalar(0,0,255), 1, 4);
//Blue,Line 10,AA
line(img, Point(100, 600), Point(800, 600), Scalar(200,0,0), 10, CV_AA);
//add by ggggnonaka end
namedWindow("drawing", CV_WINDOW_AUTOSIZE|CV_WINDOW_FREERATIO);
imshow("drawing", img);
waitKey(0);
}
//end MyLine.cpp
Create a CMake file
Now you have to create your CMakeLists.txt file. It should look like this:
cmake_minimum_required (VERSION 2.6)
project( MyLine )
find_package( OpenCV REQUIRED )
add_executable( MyLine MyLine.cpp )
target_link_libraries( MyLine ${OpenCV_LIBS} )
Generate the executable
This part is easy, just proceed as with any other project using CMake:
cd <DisplayImage_directory>
cmake .
make
Run
./MyLine