Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
46a6f70d
Commit
46a6f70d
authored
Apr 17, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3934 from mshabunin:add-cpp-sample-project
parents
81c5d580
b80142be
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
2 deletions
+80
-2
linux_gcc_cmake.markdown
...als/introduction/linux_gcc_cmake/linux_gcc_cmake.markdown
+2
-2
CMakeLists.txt
samples/cpp/example_cmake/CMakeLists.txt
+28
-0
example.cpp
samples/cpp/example_cmake/example.cpp
+50
-0
No files found.
doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.markdown
View file @
46a6f70d
...
...
@@ -53,9 +53,9 @@ Now you have to create your CMakeLists.txt file. It should look like this:
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
include_directories(
\f
${OpenCV_INCLUDE_DIRS} )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage
\f
${OpenCV_LIBS} )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
@endcode
### Generate the executable
...
...
samples/cpp/example_cmake/CMakeLists.txt
0 → 100644
View file @
46a6f70d
# cmake needs this line
cmake_minimum_required
(
VERSION 2.8
)
# Define project name
project
(
opencv_example_project
)
# Find OpenCV, you may need to set OpenCV_DIR variable
# to the absolute path to the directory containing OpenCVConfig.cmake file
# via the command line or GUI
find_package
(
OpenCV REQUIRED
)
# If the package has been found, several variables will
# be set, you can find the full list with descriptions
# in the OpenCVConfig.cmake file.
# Print some message showing some of them
message
(
STATUS
"OpenCV library status:"
)
message
(
STATUS
" version:
${
OpenCV_VERSION
}
"
)
message
(
STATUS
" libraries:
${
OpenCV_LIBS
}
"
)
message
(
STATUS
" include path:
${
OpenCV_INCLUDE_DIRS
}
"
)
# Add OpenCV headers location to your include paths
include_directories
(
${
OpenCV_INCLUDE_DIRS
}
)
# Declare the executable target built from your sources
add_executable
(
opencv_example example.cpp
)
# Link your application with OpenCV libraries
target_link_libraries
(
opencv_example
${
OpenCV_LIBS
}
)
samples/cpp/example_cmake/example.cpp
0 → 100644
View file @
46a6f70d
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/videoio.hpp"
#include <iostream>
using
namespace
cv
;
using
namespace
std
;
void
drawText
(
Mat
&
image
);
int
main
()
{
cout
<<
"Built with OpenCV "
<<
CV_VERSION
<<
endl
;
Mat
image
;
VideoCapture
capture
;
capture
.
open
(
0
);
if
(
capture
.
isOpened
())
{
cout
<<
"Capture is opened"
<<
endl
;
for
(;;)
{
capture
>>
image
;
if
(
image
.
empty
())
break
;
drawText
(
image
);
imshow
(
"Sample"
,
image
);
if
(
waitKey
(
10
)
>=
0
)
break
;
}
}
else
{
cout
<<
"No capture"
<<
endl
;
image
=
Mat
::
zeros
(
480
,
640
,
CV_8UC1
);
drawText
(
image
);
imshow
(
"Sample"
,
image
);
waitKey
(
0
);
}
return
0
;
}
void
drawText
(
Mat
&
image
)
{
putText
(
image
,
"Hello OpenCV"
,
Point
(
20
,
50
),
FONT_HERSHEY_COMPLEX
,
1
,
// font face and scale
Scalar
(
255
,
255
,
255
),
// white
1
,
LINE_AA
);
// line thickness and type
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment