commit
dc1eb583b4
80
.gitattributes
vendored
80
.gitattributes
vendored
@ -1,42 +1,58 @@
|
||||
.git* export-ignore
|
||||
|
||||
* text=auto whitespace=trailing-space,space-before-tab,-indent-with-non-tab,tab-in-indent,tabwidth=4
|
||||
|
||||
*.py text
|
||||
*.cpp text
|
||||
*.hpp text
|
||||
*.cxx text
|
||||
*.hxx text
|
||||
*.mm text
|
||||
*.c text
|
||||
*.h text
|
||||
*.i text
|
||||
*.js text
|
||||
*.java text
|
||||
*.scala text
|
||||
*.cu text
|
||||
*.cl text
|
||||
*.css_t text
|
||||
*.qrc text
|
||||
*.qss text
|
||||
*.S text
|
||||
*.rst text
|
||||
*.tex text
|
||||
*.sty text
|
||||
.git* text export-ignore
|
||||
|
||||
*.aidl text
|
||||
*.mk text
|
||||
*.aidl text
|
||||
*.appxmanifest text
|
||||
*.bib text
|
||||
*.c text
|
||||
*.cl text
|
||||
*.conf text
|
||||
*.cpp text
|
||||
*.css_t text
|
||||
*.cu text
|
||||
*.cxx text
|
||||
*.def text
|
||||
*.filelist text
|
||||
*.h text
|
||||
*.hpp text
|
||||
*.htm text
|
||||
*.html text
|
||||
*.hxx text
|
||||
*.i text
|
||||
*.idl text
|
||||
*.java text
|
||||
*.js text
|
||||
*.mk text
|
||||
*.mm text
|
||||
*.plist text
|
||||
*.properties text
|
||||
*.py text
|
||||
*.qrc text
|
||||
*.qss text
|
||||
*.S text
|
||||
*.sbt text
|
||||
*.scala text
|
||||
*.sty text
|
||||
*.tex text
|
||||
*.txt text
|
||||
*.xaml text
|
||||
|
||||
# reST underlines/overlines can look like conflict markers
|
||||
*.rst text conflict-marker-size=80
|
||||
|
||||
*.cmake text whitespace=tabwidth=2
|
||||
*.cmakein text whitespace=tabwidth=2
|
||||
*.in text whitespace=tabwidth=2
|
||||
CMakeLists.txt text whitespace=tabwidth=2
|
||||
|
||||
*.png binary
|
||||
*.jpeg binary
|
||||
*.jpg binary
|
||||
*.avi binary
|
||||
*.bmp binary
|
||||
*.exr binary
|
||||
*.ico binary
|
||||
*.jpeg binary
|
||||
*.jpg binary
|
||||
*.png binary
|
||||
|
||||
*.a binary
|
||||
*.so binary
|
||||
@ -47,6 +63,7 @@ CMakeLists.txt text whitespace=tabwidth=2
|
||||
*.pbxproj binary
|
||||
*.vec binary
|
||||
*.doc binary
|
||||
*.dia binary
|
||||
|
||||
*.xml -text whitespace=cr-at-eol
|
||||
*.yml -text whitespace=cr-at-eol
|
||||
@ -55,9 +72,12 @@ CMakeLists.txt text whitespace=tabwidth=2
|
||||
.cproject -text whitespace=cr-at-eol merge=union
|
||||
org.eclipse.jdt.core.prefs -text whitespace=cr-at-eol merge=union
|
||||
|
||||
*.vcproj text eol=crlf merge=union
|
||||
*.bat text eol=crlf
|
||||
*.cmd text eol=crlf
|
||||
*.cmd.tmpl text eol=crlf
|
||||
*.dsp text eol=crlf -whitespace
|
||||
*.sln text eol=crlf -whitespace
|
||||
*.vcproj text eol=crlf -whitespace merge=union
|
||||
*.vcxproj text eol=crlf -whitespace merge=union
|
||||
|
||||
*.sh text eol=lf
|
||||
*.sh text eol=lf
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@
|
||||
.DS_Store
|
||||
refman.rst
|
||||
OpenCV4Tegra/
|
||||
tegra/
|
||||
*.user
|
||||
.sw[a-z]
|
||||
.*.swp
|
||||
|
1
3rdparty/.gitattributes
vendored
Normal file
1
3rdparty/.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
||||
* -whitespace
|
3
3rdparty/ffmpeg/ffmpeg_version.cmake
vendored
3
3rdparty/ffmpeg/ffmpeg_version.cmake
vendored
@ -1,4 +1,3 @@
|
||||
set(NEW_FFMPEG 1)
|
||||
set(HAVE_FFMPEG_CODEC 1)
|
||||
set(HAVE_FFMPEG_FORMAT 1)
|
||||
set(HAVE_FFMPEG_UTIL 1)
|
||||
@ -8,4 +7,4 @@ set(HAVE_GENTOO_FFMPEG 1)
|
||||
set(ALIASOF_libavcodec_VERSION 53.61.100)
|
||||
set(ALIASOF_libavformat_VERSION 53.32.100)
|
||||
set(ALIASOF_libavutil_VERSION 51.35.100)
|
||||
set(ALIASOF_libswscale_VERSION 2.1.100)
|
||||
set(ALIASOF_libswscale_VERSION 2.1.100)
|
||||
|
2
3rdparty/ffmpeg/make.bat
vendored
2
3rdparty/ffmpeg/make.bat
vendored
@ -1,2 +1,2 @@
|
||||
set path=c:\dev\msys32\bin;%path% & gcc -Wall -shared -o opencv_ffmpeg.dll -O2 -x c++ -I../include -I../include/ffmpeg_ -I../../modules/highgui/src ffopencv.c -L../lib -lavformat -lavcodec -lavdevice -lswscale -lavutil -lwsock32
|
||||
set path=c:\dev\msys64\bin;%path% & gcc -m64 -Wall -shared -o opencv_ffmpeg_64.dll -O2 -x c++ -I../include -I../include/ffmpeg_ -I../../modules/highgui/src ffopencv.c -L../lib -lavformat64 -lavcodec64 -lavdevice64 -lswscale64 -lavutil64 -lavcore64 -lwsock32 -lws2_32
|
||||
set path=c:\dev\msys64\bin;%path% & gcc -m64 -Wall -shared -o opencv_ffmpeg_64.dll -O2 -x c++ -I../include -I../include/ffmpeg_ -I../../modules/highgui/src ffopencv.c -L../lib -lavformat64 -lavcodec64 -lavdevice64 -lswscale64 -lavutil64 -lavcore64 -lwsock32 -lws2_32
|
||||
|
4
3rdparty/ffmpeg/readme.txt
vendored
4
3rdparty/ffmpeg/readme.txt
vendored
@ -16,7 +16,7 @@ How to update opencv_ffmpeg.dll and opencv_ffmpeg_64.dll when a new version of F
|
||||
2. Install 64-bit MinGW. http://mingw-w64.sourceforge.net/
|
||||
Let's assume, it's installed in C:\MSYS64
|
||||
3. Copy C:\MSYS32\msys to C:\MSYS64\msys. Edit C:\MSYS64\msys\etc\fstab, change C:\MSYS32 to C:\MSYS64.
|
||||
|
||||
|
||||
4. Now you have working MSYS32 and MSYS64 environments.
|
||||
Launch, one by one, C:\MSYS32\msys\msys.bat and C:\MSYS64\msys\msys.bat to create your home directories.
|
||||
|
||||
@ -40,5 +40,3 @@ How to update opencv_ffmpeg.dll and opencv_ffmpeg_64.dll when a new version of F
|
||||
|
||||
8. Then, go to <opencv>\3rdparty\ffmpeg, edit make.bat
|
||||
(change paths to the actual paths to your msys32 and msys64 distributions) and then run make.bat
|
||||
|
||||
|
||||
|
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r2.2.0.so
vendored
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r2.2.0.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r2.3.3.so
vendored
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r2.3.3.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r3.0.1.so
vendored
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r3.0.1.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r4.0.0.so
vendored
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r4.0.0.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r4.0.3.so
vendored
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r4.0.3.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r4.1.1.so
vendored
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r4.1.1.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r4.2.0.so
vendored
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r4.2.0.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r4.3.0.so
vendored
Executable file
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r4.3.0.so
vendored
Executable file
Binary file not shown.
BIN
3rdparty/lib/armeabi/libnative_camera_r2.2.0.so
vendored
BIN
3rdparty/lib/armeabi/libnative_camera_r2.2.0.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi/libnative_camera_r2.3.3.so
vendored
BIN
3rdparty/lib/armeabi/libnative_camera_r2.3.3.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi/libnative_camera_r3.0.1.so
vendored
BIN
3rdparty/lib/armeabi/libnative_camera_r3.0.1.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi/libnative_camera_r4.0.0.so
vendored
BIN
3rdparty/lib/armeabi/libnative_camera_r4.0.0.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi/libnative_camera_r4.0.3.so
vendored
BIN
3rdparty/lib/armeabi/libnative_camera_r4.0.3.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi/libnative_camera_r4.1.1.so
vendored
BIN
3rdparty/lib/armeabi/libnative_camera_r4.1.1.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi/libnative_camera_r4.2.0.so
vendored
BIN
3rdparty/lib/armeabi/libnative_camera_r4.2.0.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi/libnative_camera_r4.3.0.so
vendored
Executable file
BIN
3rdparty/lib/armeabi/libnative_camera_r4.3.0.so
vendored
Executable file
Binary file not shown.
BIN
3rdparty/lib/mips/libnative_camera_r4.0.3.so
vendored
BIN
3rdparty/lib/mips/libnative_camera_r4.0.3.so
vendored
Binary file not shown.
BIN
3rdparty/lib/mips/libnative_camera_r4.1.1.so
vendored
BIN
3rdparty/lib/mips/libnative_camera_r4.1.1.so
vendored
Binary file not shown.
BIN
3rdparty/lib/mips/libnative_camera_r4.2.0.so
vendored
BIN
3rdparty/lib/mips/libnative_camera_r4.2.0.so
vendored
Binary file not shown.
BIN
3rdparty/lib/mips/libnative_camera_r4.3.0.so
vendored
Executable file
BIN
3rdparty/lib/mips/libnative_camera_r4.3.0.so
vendored
Executable file
Binary file not shown.
BIN
3rdparty/lib/x86/libnative_camera_r2.3.3.so
vendored
BIN
3rdparty/lib/x86/libnative_camera_r2.3.3.so
vendored
Binary file not shown.
BIN
3rdparty/lib/x86/libnative_camera_r3.0.1.so
vendored
BIN
3rdparty/lib/x86/libnative_camera_r3.0.1.so
vendored
Binary file not shown.
BIN
3rdparty/lib/x86/libnative_camera_r4.0.3.so
vendored
BIN
3rdparty/lib/x86/libnative_camera_r4.0.3.so
vendored
Binary file not shown.
BIN
3rdparty/lib/x86/libnative_camera_r4.1.1.so
vendored
BIN
3rdparty/lib/x86/libnative_camera_r4.1.1.so
vendored
Binary file not shown.
BIN
3rdparty/lib/x86/libnative_camera_r4.2.0.so
vendored
BIN
3rdparty/lib/x86/libnative_camera_r4.2.0.so
vendored
Binary file not shown.
BIN
3rdparty/lib/x86/libnative_camera_r4.3.0.so
vendored
Executable file
BIN
3rdparty/lib/x86/libnative_camera_r4.3.0.so
vendored
Executable file
Binary file not shown.
1
3rdparty/libjasper/CMakeLists.txt
vendored
1
3rdparty/libjasper/CMakeLists.txt
vendored
@ -48,4 +48,3 @@ endif()
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
install(TARGETS ${JASPER_LIBRARY} ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main)
|
||||
endif()
|
||||
|
||||
|
4
3rdparty/libpng/CMakeLists.txt
vendored
4
3rdparty/libpng/CMakeLists.txt
vendored
@ -29,6 +29,10 @@ if(MSVC)
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
endif(MSVC)
|
||||
|
||||
if (HAVE_WINRT)
|
||||
add_definitions(-DHAVE_WINRT)
|
||||
endif()
|
||||
|
||||
add_library(${PNG_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs})
|
||||
target_link_libraries(${PNG_LIBRARY} ${ZLIB_LIBRARY})
|
||||
|
||||
|
22
3rdparty/libpng/opencv-libpng.patch
vendored
Normal file
22
3rdparty/libpng/opencv-libpng.patch
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
diff --git a/3rdparty/libpng/pngpriv.h b/3rdparty/libpng/pngpriv.h
|
||||
index 07b2b0b..e7824b8 100644
|
||||
--- a/3rdparty/libpng/pngpriv.h
|
||||
+++ b/3rdparty/libpng/pngpriv.h
|
||||
@@ -360,7 +360,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
|
||||
|
||||
/* Memory model/platform independent fns */
|
||||
#ifndef PNG_ABORT
|
||||
-# ifdef _WINDOWS_
|
||||
+# if defined(_WINDOWS_) && !defined(HAVE_WINRT)
|
||||
# define PNG_ABORT() ExitProcess(0)
|
||||
# else
|
||||
# define PNG_ABORT() abort()
|
||||
@@ -378,7 +378,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
|
||||
# define png_memcpy _fmemcpy
|
||||
# define png_memset _fmemset
|
||||
#else
|
||||
-# ifdef _WINDOWS_ /* Favor Windows over C runtime fns */
|
||||
+# if defined(_WINDOWS_) && !defined(HAVE_WINRT) /* Favor Windows over C runtime fns */
|
||||
# define CVT_PTR(ptr) (ptr)
|
||||
# define CVT_PTR_NOCHECK(ptr) (ptr)
|
||||
# define png_strlen lstrlenA
|
4
3rdparty/libpng/pngpriv.h
vendored
4
3rdparty/libpng/pngpriv.h
vendored
@ -360,7 +360,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
|
||||
|
||||
/* Memory model/platform independent fns */
|
||||
#ifndef PNG_ABORT
|
||||
# ifdef _WINDOWS_
|
||||
# if defined(_WINDOWS_) && !defined(HAVE_WINRT)
|
||||
# define PNG_ABORT() ExitProcess(0)
|
||||
# else
|
||||
# define PNG_ABORT() abort()
|
||||
@ -378,7 +378,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
|
||||
# define png_memcpy _fmemcpy
|
||||
# define png_memset _fmemset
|
||||
#else
|
||||
# ifdef _WINDOWS_ /* Favor Windows over C runtime fns */
|
||||
# if defined(_WINDOWS_) && !defined(HAVE_WINRT) /* Favor Windows over C runtime fns */
|
||||
# define CVT_PTR(ptr) (ptr)
|
||||
# define CVT_PTR_NOCHECK(ptr) (ptr)
|
||||
# define png_strlen lstrlenA
|
||||
|
12
3rdparty/libtiff/CMakeLists.txt
vendored
12
3rdparty/libtiff/CMakeLists.txt
vendored
@ -17,7 +17,7 @@ check_include_file(string.h HAVE_STRING_H)
|
||||
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
|
||||
check_include_file(unistd.h HAVE_UNISTD_H)
|
||||
|
||||
if(WIN32)
|
||||
if(WIN32 AND NOT HAVE_WINRT)
|
||||
set(USE_WIN32_FILEIO 1)
|
||||
endif()
|
||||
|
||||
@ -79,14 +79,12 @@ set(lib_srcs
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/tif_config.h"
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
if(WIN32 AND NOT HAVE_WINRT)
|
||||
list(APPEND lib_srcs tif_win32.c)
|
||||
else()
|
||||
list(APPEND lib_srcs tif_unix.c)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND lib_srcs tif_win32.c)
|
||||
endif(WIN32)
|
||||
|
||||
|
||||
ocv_warnings_disable(CMAKE_C_FLAGS -Wno-unused-but-set-variable -Wmissing-prototypes -Wmissing-declarations -Wundef -Wunused -Wsign-compare
|
||||
-Wcast-align -Wshadow -Wno-maybe-uninitialized -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast)
|
||||
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter) # clang
|
||||
|
1
3rdparty/libtiff/tif_config.h.cmakein
vendored
1
3rdparty/libtiff/tif_config.h.cmakein
vendored
@ -168,4 +168,3 @@
|
||||
|
||||
/* Support Deflate compression */
|
||||
#define ZIP_SUPPORT 1
|
||||
|
||||
|
4
3rdparty/readme.txt
vendored
4
3rdparty/readme.txt
vendored
@ -45,13 +45,13 @@ jasper-1.900.1 - JasPer is a collection of software
|
||||
and manipulation of images. This software can handle image data in a
|
||||
variety of formats. One such format supported by JasPer is the JPEG-2000
|
||||
format defined in ISO/IEC 15444-1.
|
||||
|
||||
|
||||
Copyright (c) 1999-2000 Image Power, Inc.
|
||||
Copyright (c) 1999-2000 The University of British Columbia
|
||||
Copyright (c) 2001-2003 Michael David Adams
|
||||
|
||||
The JasPer license can be found in src/libjasper.
|
||||
|
||||
|
||||
OpenCV on Windows uses pre-built libjasper library
|
||||
(lib/libjasper*). To get the latest source code,
|
||||
please, visit the project homepage:
|
||||
|
2
3rdparty/tbb/.gitignore
vendored
2
3rdparty/tbb/.gitignore
vendored
@ -1 +1 @@
|
||||
tbb*.tgz
|
||||
tbb*.tgz
|
||||
|
10
3rdparty/tbb/CMakeLists.txt
vendored
10
3rdparty/tbb/CMakeLists.txt
vendored
@ -11,7 +11,7 @@ if (WIN32 AND ARM)
|
||||
set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130613oss_src.tgz")
|
||||
set(tbb_md5 "108c8c1e481b0aaea61878289eb28b6a")
|
||||
set(tbb_version_file "version_string.ver")
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wunused-parameter)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702)
|
||||
else()
|
||||
# 4.1 update 2 - works fine
|
||||
set(tbb_ver "tbb41_20130116oss")
|
||||
@ -230,9 +230,15 @@ endif()
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wmissing-declarations)
|
||||
string(REPLACE "-Werror=non-virtual-dtor" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
if (WIN32)
|
||||
set(tbb_debug_postfix "_debug") # to fit pragmas in _windef.h inside TBB
|
||||
else()
|
||||
set(tbb_debug_postfix ${OPENCV_DEBUG_POSTFIX})
|
||||
endif()
|
||||
|
||||
set_target_properties(tbb
|
||||
PROPERTIES OUTPUT_NAME tbb
|
||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
||||
DEBUG_POSTFIX "${tbb_debug_postfix}"
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
|
||||
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
|
||||
)
|
||||
|
@ -212,7 +212,7 @@ OCV_OPTION(ENABLE_SSE42 "Enable SSE4.2 instructions"
|
||||
OCV_OPTION(ENABLE_AVX "Enable AVX instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_NOISY_WARNINGS "Show all warnings even if they are too noisy" OFF )
|
||||
OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF )
|
||||
|
||||
OCV_OPTION(ENABLE_WINRT_MODE "Build with Windows Runtime support" OFF IF WIN32 )
|
||||
|
||||
# uncategorized options
|
||||
# ===================================================
|
||||
@ -296,7 +296,6 @@ endif()
|
||||
# Path for build/platform -specific headers
|
||||
# ----------------------------------------------------------------------------
|
||||
set(OPENCV_CONFIG_FILE_INCLUDE_DIR "${CMAKE_BINARY_DIR}/" CACHE PATH "Where to create the platform-dependant cvconfig.h")
|
||||
add_definitions(-DHAVE_CVCONFIG_H)
|
||||
ocv_include_directories(${OPENCV_CONFIG_FILE_INCLUDE_DIR})
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
@ -370,9 +369,6 @@ if(UNIX)
|
||||
include(CheckIncludeFile)
|
||||
|
||||
if(NOT APPLE)
|
||||
CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H)
|
||||
CHECK_FUNCTION_EXISTS(alloca HAVE_ALLOCA)
|
||||
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
|
||||
CHECK_INCLUDE_FILE(pthread.h HAVE_LIBPTHREAD)
|
||||
if(ANDROID)
|
||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} dl m log)
|
||||
@ -382,7 +378,7 @@ if(UNIX)
|
||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} dl m pthread rt)
|
||||
endif()
|
||||
else()
|
||||
add_definitions(-DHAVE_ALLOCA -DHAVE_ALLOCA_H -DHAVE_LIBPTHREAD -DHAVE_UNISTD_H)
|
||||
set(HAVE_LIBPTHREAD YES)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -501,6 +497,8 @@ include(cmake/OpenCVGenAndroidMK.cmake)
|
||||
# Generate OpenCVСonfig.cmake and OpenCVConfig-version.cmake for cmake projects
|
||||
include(cmake/OpenCVGenConfig.cmake)
|
||||
|
||||
# Generate Info.plist for the IOS framework
|
||||
include(cmake/OpenCVGenInfoPlist.cmake)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Summary:
|
||||
@ -607,6 +605,16 @@ if(ANDROID)
|
||||
status(" Android examples:" BUILD_ANDROID_EXAMPLES AND CAN_BUILD_ANDROID_PROJECTS THEN YES ELSE NO)
|
||||
endif()
|
||||
|
||||
# ================== Windows RT features ==================
|
||||
if(WIN32)
|
||||
status("")
|
||||
status(" Windows RT support:" HAVE_WINRT THEN YES ELSE NO)
|
||||
if (ENABLE_WINRT_MODE)
|
||||
status(" Windows SDK v8.0:" ${WINDOWS_SDK_PATH})
|
||||
status(" Visual Studio 2012:" ${VISUAL_STUDIO_PATH})
|
||||
endif()
|
||||
endif(WIN32)
|
||||
|
||||
# ========================== GUI ==========================
|
||||
status("")
|
||||
status(" GUI: ")
|
||||
@ -739,8 +747,8 @@ if(DEFINED WITH_GIGEAPI)
|
||||
endif(DEFINED WITH_GIGEAPI)
|
||||
|
||||
if(DEFINED WITH_QUICKTIME)
|
||||
status(" QuickTime:" WITH_QUICKTIME THEN YES ELSE NO)
|
||||
status(" QTKit:" WITH_QUICKTIME THEN NO ELSE YES)
|
||||
status(" QuickTime:" HAVE_QUICKTIME THEN YES ELSE NO)
|
||||
status(" QTKit:" HAVE_QTKIT THEN YES ELSE NO)
|
||||
endif(DEFINED WITH_QUICKTIME)
|
||||
|
||||
if(DEFINED WITH_UNICAP)
|
||||
@ -885,4 +893,3 @@ ocv_finalize_status()
|
||||
if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
message(WARNING "The source directory is the same as binary directory. \"make clean\" may damage the source tree")
|
||||
endif()
|
||||
|
||||
|
17
README
17
README
@ -1,17 +0,0 @@
|
||||
OpenCV: open source computer vision library
|
||||
|
||||
Homepage: http://opencv.org
|
||||
Online docs: http://docs.opencv.org
|
||||
Q&A forum: http://answers.opencv.org
|
||||
Dev zone: http://code.opencv.org
|
||||
|
||||
Please read before starting work on a pull request:
|
||||
http://code.opencv.org/projects/opencv/wiki/How_to_contribute
|
||||
|
||||
Summary of guidelines:
|
||||
|
||||
* One pull request per issue;
|
||||
* Choose the right base branch;
|
||||
* Include tests and documentation;
|
||||
* Clean up "oops" commits before submitting;
|
||||
* Follow the coding style guide.
|
23
README.md
Normal file
23
README.md
Normal file
@ -0,0 +1,23 @@
|
||||
### OpenCV: Open Source Computer Vision Library
|
||||
|
||||
#### Resources
|
||||
|
||||
* Homepage: <http://opencv.org>
|
||||
* Docs: <http://docs.opencv.org>
|
||||
* Q&A forum: <http://answers.opencv.org>
|
||||
* Issue tracking: <http://code.opencv.org>
|
||||
|
||||
#### Contributing
|
||||
|
||||
Please read before starting work on a pull request: <http://code.opencv.org/projects/opencv/wiki/How_to_contribute>
|
||||
|
||||
Summary of guidelines:
|
||||
|
||||
* One pull request per issue;
|
||||
* Choose the right base branch;
|
||||
* Include tests and documentation;
|
||||
* Clean up "oops" commits before submitting;
|
||||
* Follow the coding style guide.
|
||||
|
||||
[](https://www.gittip.com/OpenCV/)
|
||||
[](https://www.paypal.com/cgi-bin/webscr?item_name=Donation+to+OpenCV&cmd=_donations&business=accountant%40opencv.org)
|
@ -79,4 +79,3 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
set_target_properties(opencv_haartraining PROPERTIES FOLDER "applications")
|
||||
set_target_properties(opencv_haartraining_engine PROPERTIES FOLDER "applications")
|
||||
endif()
|
||||
|
||||
|
@ -100,4 +100,3 @@ int icvGetIdxAt( CvMat* idx, int pos )
|
||||
void icvSave( const CvArr* ptr, const char* filename, int line );
|
||||
|
||||
#endif /* __CVCOMMON_H_ */
|
||||
|
||||
|
@ -376,4 +376,3 @@ int main( int argc, char* argv[] )
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -34,4 +34,3 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
install(TARGETS ${the_target} RUNTIME DESTINATION bin COMPONENT main)
|
||||
|
||||
|
@ -2,6 +2,45 @@ if(NOT MSVC)
|
||||
message(FATAL_ERROR "CRT options are available only for MSVC")
|
||||
endif()
|
||||
|
||||
#INCLUDE (CheckIncludeFiles)
|
||||
|
||||
set(HAVE_WINRT FALSE)
|
||||
|
||||
# search Windows Platform SDK
|
||||
message(STATUS "Checking for Windows Platform SDK")
|
||||
GET_FILENAME_COMPONENT(WINDOWS_SDK_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]" ABSOLUTE CACHE)
|
||||
if (WINDOWS_SDK_PATH STREQUAL "")
|
||||
set(HAVE_MSPDK FALSE)
|
||||
message(STATUS "Windows Platform SDK 8.0 was not found")
|
||||
else()
|
||||
set(HAVE_MSPDK TRUE)
|
||||
endif()
|
||||
|
||||
#search for Visual Studio 11.0 install directory
|
||||
message(STATUS "Checking for Visual Studio 2012")
|
||||
GET_FILENAME_COMPONENT(VISUAL_STUDIO_PATH [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VS;ProductDir] REALPATH CACHE)
|
||||
if (VISUAL_STUDIO_PATH STREQUAL "")
|
||||
set(HAVE_MSVC2012 FALSE)
|
||||
message(STATUS "Visual Studio 2012 was not found")
|
||||
else()
|
||||
set(HAVE_MSVC2012 TRUE)
|
||||
endif()
|
||||
|
||||
try_compile(HAVE_WINRT_SDK
|
||||
"${OpenCV_BINARY_DIR}"
|
||||
"${OpenCV_SOURCE_DIR}/cmake/checks/winrttest.cpp")
|
||||
|
||||
if (ENABLE_WINRT_MODE AND HAVE_WINRT_SDK AND HAVE_MSVC2012 AND HAVE_MSPDK)
|
||||
set(HAVE_WINRT TRUE)
|
||||
endif()
|
||||
|
||||
if (HAVE_WINRT)
|
||||
add_definitions(/DWINVER=0x0602 /DNTDDI_VERSION=NTDDI_WIN8 /D_WIN32_WINNT=0x0602)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /appcontainer")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /appcontainer")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /appcontainer")
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT)
|
||||
foreach(flag_var
|
||||
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
||||
@ -62,4 +101,3 @@ if(NOT BUILD_WITH_DEBUG_INFO AND NOT MSVC)
|
||||
string(REPLACE "/Zi" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
|
||||
string(REPLACE "/Zi" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
|
||||
endif()
|
||||
|
||||
|
@ -239,6 +239,10 @@ if(MSVC)
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /fp:fast") # !! important - be on the same wave with x64 compilers
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(OPENCV_WARNINGS_ARE_ERRORS)
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /WX")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Extra link libs if the user selects building static libs:
|
||||
@ -294,4 +298,4 @@ if(MSVC)
|
||||
if(NOT ENABLE_NOISY_WARNINGS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251") #class 'std::XXX' needs to have dll-interface to be used by clients of YYY
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
@ -156,4 +156,3 @@ else()
|
||||
set(OpenCV_FOUND FALSE CACHE BOOL "" FORCE)
|
||||
set(OPENCV_FOUND FALSE CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
|
||||
|
@ -96,7 +96,11 @@ if(CUDA_FOUND)
|
||||
if(CUDA_GENERATION STREQUAL "Fermi")
|
||||
set(__cuda_arch_bin "2.0 2.1(2.0)")
|
||||
elseif(CUDA_GENERATION STREQUAL "Kepler")
|
||||
set(__cuda_arch_bin "3.0")
|
||||
if(${CUDA_VERSION} VERSION_LESS "5.0")
|
||||
set(__cuda_arch_bin "3.0")
|
||||
else()
|
||||
set(__cuda_arch_bin "3.0 3.5")
|
||||
endif()
|
||||
elseif(CUDA_GENERATION STREQUAL "Auto")
|
||||
execute_process( COMMAND "${CUDA_NVCC_EXECUTABLE}" "${OpenCV_SOURCE_DIR}/cmake/checks/OpenCVDetectCudaArch.cu" "--run"
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/"
|
||||
@ -110,8 +114,12 @@ if(CUDA_FOUND)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED __cuda_arch_bin)
|
||||
set(__cuda_arch_bin "1.1 1.2 1.3 2.0 2.1(2.0) 3.0")
|
||||
set(__cuda_arch_ptx "2.0 3.0")
|
||||
if(${CUDA_VERSION} VERSION_LESS "5.0")
|
||||
set(__cuda_arch_bin "1.1 1.2 1.3 2.0 2.1(2.0) 3.0")
|
||||
else()
|
||||
set(__cuda_arch_bin "1.1 1.2 1.3 2.0 2.1(2.0) 3.0 3.5")
|
||||
endif()
|
||||
set(__cuda_arch_ptx "3.0")
|
||||
endif()
|
||||
|
||||
set(CUDA_ARCH_BIN ${__cuda_arch_bin} CACHE STRING "Specify 'real' GPU architectures to build binaries for, BIN(PTX) format is supported")
|
||||
|
@ -108,7 +108,7 @@ if(PYTHON_EXECUTABLE)
|
||||
OUTPUT_QUIET
|
||||
ERROR_VARIABLE SPHINX_OUTPUT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(SPHINX_OUTPUT MATCHES "^Sphinx v([0-9][^ \n]*)")
|
||||
if(SPHINX_OUTPUT MATCHES "Sphinx v([0-9][^ \n]*)")
|
||||
set(SPHINX_VERSION "${CMAKE_MATCH_1}")
|
||||
set(HAVE_SPHINX 1)
|
||||
message(STATUS "Found Sphinx ${SPHINX_VERSION}: ${SPHINX_BUILD}")
|
||||
|
@ -136,12 +136,20 @@ endfunction()
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
# This is auxiliary function called from set_ipp_variables()
|
||||
# to set IPP_LIBRARIES variable in IPP 7.x style
|
||||
# to set IPP_LIBRARIES variable in IPP 7.x and 8.x style
|
||||
# ------------------------------------------------------------------------
|
||||
function(set_ipp_new_libraries)
|
||||
function(set_ipp_new_libraries _LATEST_VERSION)
|
||||
set(IPP_PREFIX "ipp")
|
||||
set(IPP_SUFFIX "_l") # static not threaded libs suffix
|
||||
set(IPP_THRD "_t") # static threaded libs suffix
|
||||
|
||||
if(${_LATEST_VERSION} VERSION_LESS "8.0")
|
||||
set(IPP_SUFFIX "_l") # static not threaded libs suffix IPP 7.x
|
||||
else()
|
||||
if(WIN32)
|
||||
set(IPP_SUFFIX "mt") # static not threaded libs suffix IPP 8.x for Windows
|
||||
else()
|
||||
set(IPP_SUFFIX "") # static not threaded libs suffix IPP 8.x for Linux/OS X
|
||||
endif()
|
||||
endif()
|
||||
set(IPPCORE "core") # core functionality
|
||||
set(IPPSP "s") # signal processing
|
||||
set(IPPIP "i") # image processing
|
||||
@ -199,7 +207,9 @@ function(set_ipp_variables _LATEST_VERSION)
|
||||
# set INCLUDE and LIB folders
|
||||
set(IPP_INCLUDE_DIRS ${IPP_ROOT_DIR}/include PARENT_SCOPE)
|
||||
|
||||
if (IPP_X64)
|
||||
if (APPLE)
|
||||
set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib PARENT_SCOPE)
|
||||
elseif (IPP_X64)
|
||||
if(NOT EXISTS ${IPP_ROOT_DIR}/lib/intel64)
|
||||
message(SEND_ERROR "IPP EM64T libraries not found")
|
||||
endif()
|
||||
@ -211,8 +221,8 @@ function(set_ipp_variables _LATEST_VERSION)
|
||||
set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib/ia32 PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
# set IPP_LIBRARIES variable (7.x lib names)
|
||||
set_ipp_new_libraries()
|
||||
# set IPP_LIBRARIES variable (7.x or 8.x lib names)
|
||||
set_ipp_new_libraries(${_LATEST_VERSION})
|
||||
set(IPP_LIBRARIES ${IPP_LIBRARIES} PARENT_SCOPE)
|
||||
message(STATUS "IPP libs: ${IPP_LIBRARIES}")
|
||||
|
||||
@ -336,4 +346,4 @@ if(WIN32 AND MINGW AND NOT IPP_LATEST_VERSION_MAJOR LESS 7)
|
||||
# See http://code.opencv.org/issues/1906 for additional details
|
||||
set(MSV_NTDLL "ntdll")
|
||||
set(IPP_LIBRARIES ${IPP_LIBRARIES} ${MSV_NTDLL}${IPP_LIB_SUFFIX})
|
||||
endif()
|
||||
endif()
|
||||
|
@ -5,12 +5,11 @@
|
||||
#--- Win32 UI ---
|
||||
ocv_clear_vars(HAVE_WIN32UI)
|
||||
if(WITH_WIN32UI)
|
||||
TRY_COMPILE(HAVE_WIN32UI
|
||||
"${OPENCV_BINARY_DIR}/CMakeFiles/CMakeTmp"
|
||||
try_compile(HAVE_WIN32UI
|
||||
"${OpenCV_BINARY_DIR}"
|
||||
"${OpenCV_SOURCE_DIR}/cmake/checks/win32uitest.cpp"
|
||||
CMAKE_FLAGS "\"user32.lib\" \"gdi32.lib\""
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
endif(WITH_WIN32UI)
|
||||
CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=user32;gdi32")
|
||||
endif()
|
||||
|
||||
# --- QT4 ---
|
||||
ocv_clear_vars(HAVE_QT HAVE_QT5)
|
||||
@ -65,3 +64,12 @@ if(WITH_OPENGL)
|
||||
endif()
|
||||
endif()
|
||||
endif(WITH_OPENGL)
|
||||
|
||||
# --- Carbon & Cocoa ---
|
||||
if(APPLE)
|
||||
if(WITH_CARBON)
|
||||
set(HAVE_CARBON YES)
|
||||
elseif(NOT IOS)
|
||||
set(HAVE_COCOA YES)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -36,57 +36,59 @@ if(WITH_TIFF)
|
||||
ocv_parse_header("${TIFF_INCLUDE_DIR}/tiff.h" TIFF_VERSION_LINES TIFF_VERSION_CLASSIC TIFF_VERSION_BIG TIFF_VERSION TIFF_BIGTIFF_VERSION)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_TIFF AND NOT TIFF_FOUND)
|
||||
ocv_clear_vars(TIFF_LIBRARY TIFF_LIBRARIES TIFF_INCLUDE_DIR)
|
||||
if(NOT TIFF_FOUND)
|
||||
ocv_clear_vars(TIFF_LIBRARY TIFF_LIBRARIES TIFF_INCLUDE_DIR)
|
||||
|
||||
set(TIFF_LIBRARY libtiff)
|
||||
set(TIFF_LIBRARIES ${TIFF_LIBRARY})
|
||||
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libtiff")
|
||||
set(TIFF_INCLUDE_DIR "${${TIFF_LIBRARY}_SOURCE_DIR}" "${${TIFF_LIBRARY}_BINARY_DIR}")
|
||||
ocv_parse_header("${${TIFF_LIBRARY}_SOURCE_DIR}/tiff.h" TIFF_VERSION_LINES TIFF_VERSION_CLASSIC TIFF_VERSION_BIG TIFF_VERSION TIFF_BIGTIFF_VERSION)
|
||||
endif()
|
||||
|
||||
if(TIFF_VERSION_CLASSIC AND NOT TIFF_VERSION)
|
||||
set(TIFF_VERSION ${TIFF_VERSION_CLASSIC})
|
||||
endif()
|
||||
|
||||
if(TIFF_BIGTIFF_VERSION AND NOT TIFF_VERSION_BIG)
|
||||
set(TIFF_VERSION_BIG ${TIFF_BIGTIFF_VERSION})
|
||||
endif()
|
||||
|
||||
if(NOT TIFF_VERSION_STRING AND TIFF_INCLUDE_DIR)
|
||||
list(GET TIFF_INCLUDE_DIR 0 _TIFF_INCLUDE_DIR)
|
||||
if(EXISTS "${_TIFF_INCLUDE_DIR}/tiffvers.h")
|
||||
file(STRINGS "${_TIFF_INCLUDE_DIR}/tiffvers.h" tiff_version_str REGEX "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version .*")
|
||||
string(REGEX REPLACE "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version +([^ \\n]*).*" "\\1" TIFF_VERSION_STRING "${tiff_version_str}")
|
||||
unset(tiff_version_str)
|
||||
set(TIFF_LIBRARY libtiff)
|
||||
set(TIFF_LIBRARIES ${TIFF_LIBRARY})
|
||||
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libtiff")
|
||||
set(TIFF_INCLUDE_DIR "${${TIFF_LIBRARY}_SOURCE_DIR}" "${${TIFF_LIBRARY}_BINARY_DIR}")
|
||||
ocv_parse_header("${${TIFF_LIBRARY}_SOURCE_DIR}/tiff.h" TIFF_VERSION_LINES TIFF_VERSION_CLASSIC TIFF_VERSION_BIG TIFF_VERSION TIFF_BIGTIFF_VERSION)
|
||||
endif()
|
||||
unset(_TIFF_INCLUDE_DIR)
|
||||
|
||||
if(TIFF_VERSION_CLASSIC AND NOT TIFF_VERSION)
|
||||
set(TIFF_VERSION ${TIFF_VERSION_CLASSIC})
|
||||
endif()
|
||||
|
||||
if(TIFF_BIGTIFF_VERSION AND NOT TIFF_VERSION_BIG)
|
||||
set(TIFF_VERSION_BIG ${TIFF_BIGTIFF_VERSION})
|
||||
endif()
|
||||
|
||||
if(NOT TIFF_VERSION_STRING AND TIFF_INCLUDE_DIR)
|
||||
list(GET TIFF_INCLUDE_DIR 0 _TIFF_INCLUDE_DIR)
|
||||
if(EXISTS "${_TIFF_INCLUDE_DIR}/tiffvers.h")
|
||||
file(STRINGS "${_TIFF_INCLUDE_DIR}/tiffvers.h" tiff_version_str REGEX "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version .*")
|
||||
string(REGEX REPLACE "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version +([^ \\n]*).*" "\\1" TIFF_VERSION_STRING "${tiff_version_str}")
|
||||
unset(tiff_version_str)
|
||||
endif()
|
||||
unset(_TIFF_INCLUDE_DIR)
|
||||
endif()
|
||||
|
||||
set(HAVE_TIFF YES)
|
||||
endif()
|
||||
|
||||
# --- libjpeg (optional) ---
|
||||
if(WITH_JPEG AND NOT IOS)
|
||||
if(WITH_JPEG)
|
||||
if(BUILD_JPEG)
|
||||
ocv_clear_vars(JPEG_FOUND)
|
||||
else()
|
||||
include(FindJPEG)
|
||||
endif()
|
||||
|
||||
if(NOT JPEG_FOUND)
|
||||
ocv_clear_vars(JPEG_LIBRARY JPEG_LIBRARIES JPEG_INCLUDE_DIR)
|
||||
|
||||
set(JPEG_LIBRARY libjpeg)
|
||||
set(JPEG_LIBRARIES ${JPEG_LIBRARY})
|
||||
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjpeg")
|
||||
set(JPEG_INCLUDE_DIR "${${JPEG_LIBRARY}_SOURCE_DIR}")
|
||||
endif()
|
||||
|
||||
ocv_parse_header("${JPEG_INCLUDE_DIR}/jpeglib.h" JPEG_VERSION_LINES JPEG_LIB_VERSION)
|
||||
set(HAVE_JPEG YES)
|
||||
endif()
|
||||
|
||||
if(WITH_JPEG AND NOT JPEG_FOUND)
|
||||
ocv_clear_vars(JPEG_LIBRARY JPEG_LIBRARIES JPEG_INCLUDE_DIR)
|
||||
|
||||
set(JPEG_LIBRARY libjpeg)
|
||||
set(JPEG_LIBRARIES ${JPEG_LIBRARY})
|
||||
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjpeg")
|
||||
set(JPEG_INCLUDE_DIR "${${JPEG_LIBRARY}_SOURCE_DIR}")
|
||||
endif()
|
||||
|
||||
ocv_parse_header("${JPEG_INCLUDE_DIR}/jpeglib.h" JPEG_VERSION_LINES JPEG_LIB_VERSION)
|
||||
|
||||
|
||||
# --- libjasper (optional, should be searched after libjpeg) ---
|
||||
if(WITH_JASPER)
|
||||
if(BUILD_JASPER)
|
||||
@ -94,53 +96,55 @@ if(WITH_JASPER)
|
||||
else()
|
||||
include(FindJasper)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_JASPER AND NOT JASPER_FOUND)
|
||||
ocv_clear_vars(JASPER_LIBRARY JASPER_LIBRARIES JASPER_INCLUDE_DIR)
|
||||
if(NOT JASPER_FOUND)
|
||||
ocv_clear_vars(JASPER_LIBRARY JASPER_LIBRARIES JASPER_INCLUDE_DIR)
|
||||
|
||||
set(JASPER_LIBRARY libjasper)
|
||||
set(JASPER_LIBRARIES ${JASPER_LIBRARY})
|
||||
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjasper")
|
||||
set(JASPER_INCLUDE_DIR "${${JASPER_LIBRARY}_SOURCE_DIR}")
|
||||
endif()
|
||||
set(JASPER_LIBRARY libjasper)
|
||||
set(JASPER_LIBRARIES ${JASPER_LIBRARY})
|
||||
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjasper")
|
||||
set(JASPER_INCLUDE_DIR "${${JASPER_LIBRARY}_SOURCE_DIR}")
|
||||
endif()
|
||||
|
||||
if(NOT JASPER_VERSION_STRING)
|
||||
ocv_parse_header2(JASPER "${JASPER_INCLUDE_DIR}/jasper/jas_config.h" JAS_VERSION "")
|
||||
set(HAVE_JASPER YES)
|
||||
|
||||
if(NOT JASPER_VERSION_STRING)
|
||||
ocv_parse_header2(JASPER "${JASPER_INCLUDE_DIR}/jasper/jas_config.h" JAS_VERSION "")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# --- libpng (optional, should be searched after zlib) ---
|
||||
if(WITH_PNG AND NOT IOS)
|
||||
if(WITH_PNG)
|
||||
if(BUILD_PNG)
|
||||
ocv_clear_vars(PNG_FOUND)
|
||||
else()
|
||||
include(FindPNG)
|
||||
if(PNG_FOUND)
|
||||
include(CheckIncludeFile)
|
||||
check_include_file("${PNG_PNG_INCLUDE_DIR}/png.h" HAVE_PNG_H)
|
||||
check_include_file("${PNG_PNG_INCLUDE_DIR}/libpng/png.h" HAVE_LIBPNG_PNG_H)
|
||||
if(HAVE_PNG_H)
|
||||
ocv_parse_header("${PNG_PNG_INCLUDE_DIR}/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
|
||||
elseif(HAVE_LIBPNG_PNG_H)
|
||||
if(HAVE_LIBPNG_PNG_H)
|
||||
ocv_parse_header("${PNG_PNG_INCLUDE_DIR}/libpng/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
|
||||
else()
|
||||
ocv_parse_header("${PNG_PNG_INCLUDE_DIR}/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT PNG_FOUND)
|
||||
ocv_clear_vars(PNG_LIBRARY PNG_LIBRARIES PNG_INCLUDE_DIR PNG_PNG_INCLUDE_DIR HAVE_LIBPNG_PNG_H PNG_DEFINITIONS)
|
||||
|
||||
set(PNG_LIBRARY libpng)
|
||||
set(PNG_LIBRARIES ${PNG_LIBRARY})
|
||||
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libpng")
|
||||
set(PNG_INCLUDE_DIR "${${PNG_LIBRARY}_SOURCE_DIR}")
|
||||
set(PNG_DEFINITIONS "")
|
||||
ocv_parse_header("${PNG_INCLUDE_DIR}/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
|
||||
endif()
|
||||
|
||||
set(HAVE_PNG YES)
|
||||
set(PNG_VERSION "${PNG_LIBPNG_VER_MAJOR}.${PNG_LIBPNG_VER_MINOR}.${PNG_LIBPNG_VER_RELEASE}")
|
||||
endif()
|
||||
|
||||
if(WITH_PNG AND NOT PNG_FOUND)
|
||||
ocv_clear_vars(PNG_LIBRARY PNG_LIBRARIES PNG_INCLUDE_DIR PNG_PNG_INCLUDE_DIR HAVE_PNG_H HAVE_LIBPNG_PNG_H PNG_DEFINITIONS)
|
||||
|
||||
set(PNG_LIBRARY libpng)
|
||||
set(PNG_LIBRARIES ${PNG_LIBRARY})
|
||||
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libpng")
|
||||
set(PNG_INCLUDE_DIR "${${PNG_LIBRARY}_SOURCE_DIR}")
|
||||
set(PNG_DEFINITIONS "")
|
||||
ocv_parse_header("${PNG_INCLUDE_DIR}/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
|
||||
endif()
|
||||
|
||||
set(PNG_VERSION "${PNG_LIBPNG_VER_MAJOR}.${PNG_LIBPNG_VER_MINOR}.${PNG_LIBPNG_VER_RELEASE}")
|
||||
|
||||
# --- OpenEXR (optional) ---
|
||||
if(WITH_OPENEXR)
|
||||
if(BUILD_OPENEXR)
|
||||
@ -148,17 +152,24 @@ if(WITH_OPENEXR)
|
||||
else()
|
||||
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindOpenEXR.cmake")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_OPENEXR AND NOT OPENEXR_FOUND)
|
||||
ocv_clear_vars(OPENEXR_INCLUDE_PATHS OPENEXR_LIBRARIES OPENEXR_ILMIMF_LIBRARY OPENEXR_VERSION)
|
||||
if(NOT OPENEXR_FOUND)
|
||||
ocv_clear_vars(OPENEXR_INCLUDE_PATHS OPENEXR_LIBRARIES OPENEXR_ILMIMF_LIBRARY OPENEXR_VERSION)
|
||||
|
||||
set(OPENEXR_LIBRARIES IlmImf)
|
||||
set(OPENEXR_ILMIMF_LIBRARY IlmImf)
|
||||
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/openexr")
|
||||
set(OPENEXR_LIBRARIES IlmImf)
|
||||
set(OPENEXR_ILMIMF_LIBRARY IlmImf)
|
||||
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/openexr")
|
||||
endif()
|
||||
|
||||
set(HAVE_OPENEXR YES)
|
||||
endif()
|
||||
|
||||
#cmake 2.8.2 bug - it fails to determine zlib version
|
||||
if(ZLIB_FOUND)
|
||||
ocv_parse_header2(ZLIB "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_VERSION)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# --- Apple ImageIO ---
|
||||
if(WITH_IMAGEIO)
|
||||
set(HAVE_IMAGEIO YES)
|
||||
endif()
|
||||
|
@ -3,13 +3,12 @@
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
ocv_clear_vars(HAVE_VFW)
|
||||
if (WITH_VFW)
|
||||
TRY_COMPILE(HAVE_VFW
|
||||
"${OPENCV_BINARY_DIR}/CMakeFiles/CMakeTmp"
|
||||
if(WITH_VFW)
|
||||
try_compile(HAVE_VFW
|
||||
"${OpenCV_BINARY_DIR}"
|
||||
"${OpenCV_SOURCE_DIR}/cmake/checks/vfwtest.cpp"
|
||||
CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=vfw32"
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
endif(WITH_VFW)
|
||||
CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=vfw32")
|
||||
endif(WITH_VFW)
|
||||
|
||||
# --- GStreamer ---
|
||||
ocv_clear_vars(HAVE_GSTREAMER)
|
||||
@ -58,7 +57,14 @@ if(WITH_PVAPI)
|
||||
set(_PVAPI_LIBRARY "${_PVAPI_LIBRARY}/${CMAKE_OPENCV_GCC_VERSION_MAJOR}.${CMAKE_OPENCV_GCC_VERSION_MINOR}")
|
||||
endif()
|
||||
|
||||
set(PVAPI_LIBRARY "${_PVAPI_LIBRARY}/${CMAKE_STATIC_LIBRARY_PREFIX}PvAPI${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE PATH "The PvAPI library")
|
||||
if(WIN32)
|
||||
if(MINGW)
|
||||
set(PVAPI_DEFINITIONS "-DPVDECL=__stdcall")
|
||||
endif(MINGW)
|
||||
set(PVAPI_LIBRARY "${_PVAPI_LIBRARY}/PvAPI.lib" CACHE PATH "The PvAPI library")
|
||||
else(WIN32)
|
||||
set(PVAPI_LIBRARY "${_PVAPI_LIBRARY}/${CMAKE_STATIC_LIBRARY_PREFIX}PvAPI${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE PATH "The PvAPI library")
|
||||
endif(WIN32)
|
||||
if(EXISTS "${PVAPI_LIBRARY}")
|
||||
set(HAVE_PVAPI TRUE)
|
||||
endif()
|
||||
@ -228,3 +234,17 @@ if(WIN32)
|
||||
list(APPEND HIGHGUI_LIBRARIES winmm)
|
||||
endif()
|
||||
endif(WIN32)
|
||||
|
||||
# --- Apple AV Foundation ---
|
||||
if(WITH_AVFOUNDATION)
|
||||
set(HAVE_AVFOUNDATION YES)
|
||||
endif()
|
||||
|
||||
# --- QuickTime ---
|
||||
if (NOT IOS)
|
||||
if(WITH_QUICKTIME)
|
||||
set(HAVE_QUICKTIME YES)
|
||||
elseif(APPLE)
|
||||
set(HAVE_QTKIT YES)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -19,7 +19,7 @@ set(XIMEA_LIBRARY_DIR)
|
||||
if(WIN32)
|
||||
# Try to find the XIMEA API path in registry.
|
||||
GET_FILENAME_COMPONENT(XIMEA_PATH "[HKEY_CURRENT_USER\\Software\\XIMEA\\CamSupport\\API;Path]" ABSOLUTE)
|
||||
|
||||
|
||||
if(EXISTS ${XIMEA_PATH})
|
||||
set(XIMEA_FOUND 1)
|
||||
# set LIB folders
|
||||
@ -43,4 +43,4 @@ endif()
|
||||
|
||||
mark_as_advanced(FORCE XIMEA_FOUND)
|
||||
mark_as_advanced(FORCE XIMEA_PATH)
|
||||
mark_as_advanced(FORCE XIMEA_LIBRARY_DIR)
|
||||
mark_as_advanced(FORCE XIMEA_LIBRARY_DIR)
|
||||
|
@ -1,13 +1,3 @@
|
||||
# ----------------------------------------------------------------------------
|
||||
# Variables for cvconfig.h.cmake
|
||||
# ----------------------------------------------------------------------------
|
||||
set(PACKAGE "opencv")
|
||||
set(PACKAGE_BUGREPORT "opencvlibrary-devel@lists.sourceforge.net")
|
||||
set(PACKAGE_NAME "opencv")
|
||||
set(PACKAGE_STRING "${PACKAGE} ${OPENCV_VERSION}")
|
||||
set(PACKAGE_TARNAME "${PACKAGE}")
|
||||
set(PACKAGE_VERSION "${OPENCV_VERSION}")
|
||||
|
||||
# platform-specific config file
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/cvconfig.h.cmake" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h")
|
||||
|
||||
|
4
cmake/OpenCVGenInfoPlist.cmake
Normal file
4
cmake/OpenCVGenInfoPlist.cmake
Normal file
@ -0,0 +1,4 @@
|
||||
if(IOS)
|
||||
configure_file("${OpenCV_SOURCE_DIR}/platforms/ios/Info.plist.in"
|
||||
"${CMAKE_BINARY_DIR}/ios/Info.plist")
|
||||
endif()
|
@ -12,7 +12,6 @@ set(prefix "${CMAKE_INSTALL_PREFIX}")
|
||||
set(exec_prefix "\${prefix}")
|
||||
set(libdir "") #TODO: need link paths for OpenCV_EXTRA_COMPONENTS
|
||||
set(includedir "\${prefix}/${OPENCV_INCLUDE_INSTALL_PATH}")
|
||||
set(VERSION ${OPENCV_VERSION})
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Release")
|
||||
set(ocv_optkind OPT)
|
||||
|
@ -22,4 +22,3 @@ if(DEFINED OPENCV_BUILD_3RDPARTY_LIBS)
|
||||
set(BUILD_PNG ${OPENCV_BUILD_3RDPARTY_LIBS} CACHE BOOL "Set via depricated OPENCV_BUILD_3RDPARTY_LIBS" FORCE)
|
||||
unset(OPENCV_BUILD_3RDPARTY_LIBS CACHE)
|
||||
endif()
|
||||
|
||||
|
@ -470,8 +470,16 @@ endmacro()
|
||||
# ocv_create_module(<extra link dependencies>)
|
||||
# ocv_create_module(SKIP_LINK)
|
||||
macro(ocv_create_module)
|
||||
# The condition we ought to be testing here is whether ocv_add_precompiled_headers will
|
||||
# be called at some point in the future. We can't look into the future, though,
|
||||
# so this will have to do.
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/precomp.hpp")
|
||||
get_native_precompiled_header(${the_module} precomp.hpp)
|
||||
endif()
|
||||
|
||||
add_library(${the_module} ${OPENCV_MODULE_TYPE} ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES}
|
||||
"${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp")
|
||||
"${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp"
|
||||
${${the_module}_pch})
|
||||
|
||||
if(NOT "${ARGN}" STREQUAL "SKIP_LINK")
|
||||
target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
|
||||
@ -508,7 +516,8 @@ macro(ocv_create_module)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
if((NOT DEFINED OPENCV_MODULE_TYPE AND BUILD_SHARED_LIBS)
|
||||
OR (DEFINED OPENCV_MODULE_TYPE AND OPENCV_MODULE_TYPE STREQUAL SHARED))
|
||||
if(MSVC)
|
||||
set_target_properties(${the_module} PROPERTIES DEFINE_SYMBOL CVAPI_EXPORTS)
|
||||
else()
|
||||
@ -636,7 +645,9 @@ function(ocv_add_perf_tests)
|
||||
set(OPENCV_PERF_${the_module}_SOURCES ${perf_srcs} ${perf_hdrs})
|
||||
endif()
|
||||
|
||||
add_executable(${the_target} ${OPENCV_PERF_${the_module}_SOURCES})
|
||||
get_native_precompiled_header(${the_target} perf_precomp.hpp)
|
||||
|
||||
add_executable(${the_target} ${OPENCV_PERF_${the_module}_SOURCES} ${${the_target}_pch})
|
||||
target_link_libraries(${the_target} ${OPENCV_MODULE_${the_module}_DEPS} ${perf_deps} ${OPENCV_LINKER_LIBS})
|
||||
add_dependencies(opencv_perf_tests ${the_target})
|
||||
|
||||
@ -684,7 +695,9 @@ function(ocv_add_accuracy_tests)
|
||||
set(OPENCV_TEST_${the_module}_SOURCES ${test_srcs} ${test_hdrs})
|
||||
endif()
|
||||
|
||||
add_executable(${the_target} ${OPENCV_TEST_${the_module}_SOURCES})
|
||||
get_native_precompiled_header(${the_target} test_precomp.hpp)
|
||||
|
||||
add_executable(${the_target} ${OPENCV_TEST_${the_module}_SOURCES} ${${the_target}_pch})
|
||||
target_link_libraries(${the_target} ${OPENCV_MODULE_${the_module}_DEPS} ${test_deps} ${OPENCV_LINKER_LIBS})
|
||||
add_dependencies(opencv_tests ${the_target})
|
||||
|
||||
|
@ -272,12 +272,9 @@ ENDMACRO(ADD_PRECOMPILED_HEADER)
|
||||
MACRO(GET_NATIVE_PRECOMPILED_HEADER _targetName _input)
|
||||
|
||||
if(CMAKE_GENERATOR MATCHES "^Visual.*$")
|
||||
SET(_dummy_str "#include \"${_input}\"\n"
|
||||
"// This is required to suppress LNK4221. Very annoying.\n"
|
||||
"void *g_${_targetName}Dummy = 0\;\n")
|
||||
set(_dummy_str "#include \"${_input}\"\n")
|
||||
|
||||
# Use of cxx extension for generated files (as Qt does)
|
||||
SET(${_targetName}_pch ${CMAKE_CURRENT_BINARY_DIR}/${_targetName}_pch.cxx)
|
||||
set(${_targetName}_pch ${CMAKE_CURRENT_BINARY_DIR}/${_targetName}_pch.cpp)
|
||||
if(EXISTS ${${_targetName}_pch})
|
||||
# Check if contents is the same, if not rewrite
|
||||
# todo
|
||||
@ -337,11 +334,7 @@ ENDMACRO(ADD_NATIVE_PRECOMPILED_HEADER)
|
||||
|
||||
macro(ocv_add_precompiled_header_to_target the_target pch_header)
|
||||
if(PCHSupport_FOUND AND ENABLE_PRECOMPILED_HEADERS AND EXISTS "${pch_header}")
|
||||
if(CMAKE_GENERATOR MATCHES Visual)
|
||||
string(REGEX REPLACE "hpp$" "cpp" ${the_target}_pch "${pch_header}")
|
||||
add_native_precompiled_header(${the_target} ${pch_header})
|
||||
unset(${the_target}_pch)
|
||||
elseif(CMAKE_GENERATOR MATCHES Xcode)
|
||||
if(CMAKE_GENERATOR MATCHES "^Visual" OR CMAKE_GENERATOR MATCHES Xcode)
|
||||
add_native_precompiled_header(${the_target} ${pch_header})
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_GENERATOR MATCHES "Makefiles|Ninja")
|
||||
add_precompiled_header(${the_target} ${pch_header})
|
||||
|
@ -77,7 +77,7 @@ MACRO(ocv_check_compiler_flag LANG FLAG RESULT)
|
||||
if(_fname)
|
||||
MESSAGE(STATUS "Performing Test ${RESULT}")
|
||||
TRY_COMPILE(${RESULT}
|
||||
${CMAKE_BINARY_DIR}
|
||||
"${CMAKE_BINARY_DIR}"
|
||||
"${_fname}"
|
||||
COMPILE_DEFINITIONS "${FLAG}"
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
@ -515,4 +515,4 @@ function(ocv_source_group group)
|
||||
cmake_parse_arguments(OCV_SOURCE_GROUP "" "" "GLOB" ${ARGN})
|
||||
file(GLOB srcs ${OCV_SOURCE_GROUP_GLOB})
|
||||
source_group(${group} FILES ${srcs})
|
||||
endfunction()
|
||||
endfunction()
|
||||
|
@ -11,4 +11,4 @@ int main()
|
||||
printf("%d.%d ", prop.major, prop.minor);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -7,4 +7,4 @@ int main()
|
||||
AVIFileInit();
|
||||
AVIFileExit();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
CreateWindow(NULL /*lpClassName*/, NULL /*lpWindowName*/, 0 /*dwStyle*/, 0 /*x*/,
|
||||
0 /*y*/, 0 /*nWidth*/, 0 /*nHeight*/, NULL /*hWndParent*/, NULL /*hMenu*/,
|
||||
NULL /*hInstance*/, NULL /*lpParam*/);
|
||||
DeleteDC(NULL);
|
||||
CreateWindow(NULL /*lpClassName*/, NULL /*lpWindowName*/, 0 /*dwStyle*/, 0 /*x*/,
|
||||
0 /*y*/, 0 /*nWidth*/, 0 /*nHeight*/, NULL /*hWndParent*/, NULL /*hMenu*/,
|
||||
NULL /*hInstance*/, NULL /*lpParam*/);
|
||||
DeleteDC(NULL);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
6
cmake/checks/winrttest.cpp
Normal file
6
cmake/checks/winrttest.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include <wrl/client.h>
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
return 0;
|
||||
}
|
@ -32,4 +32,4 @@ foreach(cl ${cl_list})
|
||||
file(APPEND ${OUTPUT} "const char* ${cl_filename}=\"${lines};\n")
|
||||
endforeach()
|
||||
|
||||
file(APPEND ${OUTPUT} "}\n}\n")
|
||||
file(APPEND ${OUTPUT} "}\n}\n")
|
||||
|
@ -23,5 +23,3 @@ FOREACH(file ${files})
|
||||
MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
|
||||
ENDIF(EXISTS "$ENV{DESTDIR}${file}")
|
||||
ENDFOREACH(file)
|
||||
|
||||
|
||||
|
@ -1,20 +1,20 @@
|
||||
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||
systems. This function is required for `alloca.c' support on those systems.
|
||||
*/
|
||||
#cmakedefine CRAY_STACKSEG_END
|
||||
/* OpenCV compiled as static or dynamic libs */
|
||||
#cmakedefine BUILD_SHARED_LIBS
|
||||
|
||||
/* Define to 1 if using `alloca.c'. */
|
||||
#cmakedefine C_ALLOCA
|
||||
/* Compile for 'real' NVIDIA GPU architectures */
|
||||
#define CUDA_ARCH_BIN "${OPENCV_CUDA_ARCH_BIN}"
|
||||
|
||||
/* Define to 1 if you have `alloca', as a function or macro. */
|
||||
#cmakedefine HAVE_ALLOCA 1
|
||||
/* Create PTX or BIN for 1.0 compute capability */
|
||||
#cmakedefine CUDA_ARCH_BIN_OR_PTX_10
|
||||
|
||||
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
|
||||
*/
|
||||
#cmakedefine HAVE_ALLOCA_H 1
|
||||
/* NVIDIA GPU features are used */
|
||||
#define CUDA_ARCH_FEATURES "${OPENCV_CUDA_ARCH_FEATURES}"
|
||||
|
||||
/* Video for Windows support */
|
||||
#cmakedefine HAVE_VFW
|
||||
/* Compile for 'virtual' NVIDIA PTX architectures */
|
||||
#define CUDA_ARCH_PTX "${OPENCV_CUDA_ARCH_PTX}"
|
||||
|
||||
/* AVFoundation video libraries */
|
||||
#cmakedefine HAVE_AVFOUNDATION
|
||||
|
||||
/* V4L capturing support */
|
||||
#cmakedefine HAVE_CAMV4L
|
||||
@ -22,15 +22,30 @@
|
||||
/* V4L2 capturing support */
|
||||
#cmakedefine HAVE_CAMV4L2
|
||||
|
||||
/* V4L2 capturing support in videoio.h */
|
||||
#cmakedefine HAVE_VIDEOIO
|
||||
|
||||
/* V4L/V4L2 capturing support via libv4l */
|
||||
#cmakedefine HAVE_LIBV4L
|
||||
|
||||
/* Carbon windowing environment */
|
||||
#cmakedefine HAVE_CARBON
|
||||
|
||||
/* AMD's Basic Linear Algebra Subprograms Library*/
|
||||
#cmakedefine HAVE_CLAMDBLAS
|
||||
|
||||
/* AMD's OpenCL Fast Fourier Transform Library*/
|
||||
#cmakedefine HAVE_CLAMDFFT
|
||||
|
||||
/* Cocoa API */
|
||||
#cmakedefine HAVE_COCOA
|
||||
|
||||
/* C= */
|
||||
#cmakedefine HAVE_CSTRIPES
|
||||
|
||||
/* NVidia Cuda Basic Linear Algebra Subprograms (BLAS) API*/
|
||||
#cmakedefine HAVE_CUBLAS
|
||||
|
||||
/* NVidia Cuda Runtime API*/
|
||||
#cmakedefine HAVE_CUDA
|
||||
|
||||
/* NVidia Cuda Fast Fourier Transform (FFT) API*/
|
||||
#cmakedefine HAVE_CUFFT
|
||||
|
||||
/* IEEE1394 capturing support */
|
||||
#cmakedefine HAVE_DC1394
|
||||
|
||||
@ -40,197 +55,111 @@
|
||||
/* IEEE1394 capturing support - libdc1394 v2.x */
|
||||
#cmakedefine HAVE_DC1394_2
|
||||
|
||||
/* DirectShow Video Capture library */
|
||||
#cmakedefine HAVE_DSHOW
|
||||
|
||||
/* Eigen Matrix & Linear Algebra Library */
|
||||
#cmakedefine HAVE_EIGEN
|
||||
|
||||
/* FFMpeg video library */
|
||||
#cmakedefine HAVE_FFMPEG
|
||||
|
||||
/* ffmpeg's libswscale */
|
||||
#cmakedefine HAVE_FFMPEG_SWSCALE
|
||||
|
||||
/* ffmpeg in Gentoo */
|
||||
#cmakedefine HAVE_GENTOO_FFMPEG
|
||||
|
||||
/* FFMpeg video library */
|
||||
#cmakedefine HAVE_FFMPEG
|
||||
|
||||
/* FFMpeg version flag */
|
||||
#cmakedefine NEW_FFMPEG
|
||||
|
||||
/* ffmpeg's libswscale */
|
||||
#cmakedefine HAVE_FFMPEG_SWSCALE
|
||||
|
||||
/* GStreamer multimedia framework */
|
||||
#cmakedefine HAVE_GSTREAMER
|
||||
#cmakedefine HAVE_GSTREAMER
|
||||
|
||||
/* GTK+ 2.0 Thread support */
|
||||
#cmakedefine HAVE_GTHREAD
|
||||
#cmakedefine HAVE_GTHREAD
|
||||
|
||||
/* Windows Runtime support */
|
||||
#cmakedefine HAVE_WINRT
|
||||
|
||||
/* Win32 UI */
|
||||
#cmakedefine HAVE_WIN32UI
|
||||
|
||||
/* GTK+ 2.x toolkit */
|
||||
#cmakedefine HAVE_GTK
|
||||
|
||||
/* OpenEXR codec */
|
||||
#cmakedefine HAVE_ILMIMF
|
||||
#cmakedefine HAVE_GTK
|
||||
|
||||
/* Apple ImageIO Framework */
|
||||
#cmakedefine HAVE_IMAGEIO
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#cmakedefine HAVE_INTTYPES_H 1
|
||||
|
||||
/* JPEG-2000 codec */
|
||||
#cmakedefine HAVE_JASPER
|
||||
|
||||
/* IJG JPEG codec */
|
||||
#cmakedefine HAVE_JPEG
|
||||
|
||||
/* Define to 1 if you have the `dl' library (-ldl). */
|
||||
#cmakedefine HAVE_LIBDL 1
|
||||
|
||||
/* Define to 1 if you have the `gomp' library (-lgomp). */
|
||||
#cmakedefine HAVE_LIBGOMP 1
|
||||
|
||||
/* Define to 1 if you have the `m' library (-lm). */
|
||||
#cmakedefine HAVE_LIBM 1
|
||||
|
||||
/* libpng/png.h needs to be included */
|
||||
#cmakedefine HAVE_LIBPNG_PNG_H
|
||||
|
||||
/* Define to 1 if you have the `pthread' library (-lpthread). */
|
||||
#cmakedefine HAVE_LIBPTHREAD 1
|
||||
|
||||
/* Define to 1 if you have the `lrint' function. */
|
||||
#cmakedefine HAVE_LRINT 1
|
||||
|
||||
/* PNG codec */
|
||||
#cmakedefine HAVE_PNG
|
||||
|
||||
/* Define to 1 if you have the `png_get_valid' function. */
|
||||
#cmakedefine HAVE_PNG_GET_VALID 1
|
||||
|
||||
/* png.h needs to be included */
|
||||
#cmakedefine HAVE_PNG_H
|
||||
|
||||
/* Define to 1 if you have the `png_set_tRNS_to_alpha' function. */
|
||||
#cmakedefine HAVE_PNG_SET_TRNS_TO_ALPHA 1
|
||||
|
||||
/* QuickTime video libraries */
|
||||
#cmakedefine HAVE_QUICKTIME
|
||||
|
||||
/* AVFoundation video libraries */
|
||||
#cmakedefine HAVE_AVFOUNDATION
|
||||
|
||||
/* TIFF codec */
|
||||
#cmakedefine HAVE_TIFF
|
||||
|
||||
/* Unicap video capture library */
|
||||
#cmakedefine HAVE_UNICAP
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#cmakedefine HAVE_UNISTD_H 1
|
||||
|
||||
/* Xine video library */
|
||||
#cmakedefine HAVE_XINE
|
||||
|
||||
/* OpenNI library */
|
||||
#cmakedefine HAVE_OPENNI
|
||||
|
||||
/* LZ77 compression/decompression library (used for PNG) */
|
||||
#cmakedefine HAVE_ZLIB
|
||||
#cmakedefine HAVE_IMAGEIO
|
||||
|
||||
/* Intel Integrated Performance Primitives */
|
||||
#cmakedefine HAVE_IPP
|
||||
#cmakedefine HAVE_IPP
|
||||
|
||||
/* OpenCV compiled as static or dynamic libs */
|
||||
#cmakedefine BUILD_SHARED_LIBS
|
||||
/* JPEG-2000 codec */
|
||||
#cmakedefine HAVE_JASPER
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "${PACKAGE}"
|
||||
/* IJG JPEG codec */
|
||||
#cmakedefine HAVE_JPEG
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "${PACKAGE_BUGREPORT}"
|
||||
/* libpng/png.h needs to be included */
|
||||
#cmakedefine HAVE_LIBPNG_PNG_H
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "${PACKAGE_NAME}"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "${PACKAGE_STRING}"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "${PACKAGE_TARNAME}"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "${PACKAGE_VERSION}"
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at runtime.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
#cmakedefine STACK_DIRECTION
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "${PACKAGE_VERSION}"
|
||||
|
||||
/* Define to 1 if your processor stores words with the most significant byte
|
||||
first (like Motorola and SPARC, unlike Intel and VAX). */
|
||||
#cmakedefine WORDS_BIGENDIAN
|
||||
|
||||
/* Intel Threading Building Blocks */
|
||||
#cmakedefine HAVE_TBB
|
||||
|
||||
/* C= */
|
||||
#cmakedefine HAVE_CSTRIPES
|
||||
|
||||
/* Eigen Matrix & Linear Algebra Library */
|
||||
#cmakedefine HAVE_EIGEN
|
||||
|
||||
/* NVidia Cuda Runtime API*/
|
||||
#cmakedefine HAVE_CUDA
|
||||
|
||||
/* NVidia Cuda Fast Fourier Transform (FFT) API*/
|
||||
#cmakedefine HAVE_CUFFT
|
||||
|
||||
/* NVidia Cuda Basic Linear Algebra Subprograms (BLAS) API*/
|
||||
#cmakedefine HAVE_CUBLAS
|
||||
|
||||
/* NVidia Video Decoding API*/
|
||||
#cmakedefine HAVE_NVCUVID
|
||||
|
||||
/* Compile for 'real' NVIDIA GPU architectures */
|
||||
#define CUDA_ARCH_BIN "${OPENCV_CUDA_ARCH_BIN}"
|
||||
|
||||
/* Compile for 'virtual' NVIDIA PTX architectures */
|
||||
#define CUDA_ARCH_PTX "${OPENCV_CUDA_ARCH_PTX}"
|
||||
|
||||
/* NVIDIA GPU features are used */
|
||||
#define CUDA_ARCH_FEATURES "${OPENCV_CUDA_ARCH_FEATURES}"
|
||||
|
||||
/* Create PTX or BIN for 1.0 compute capability */
|
||||
#cmakedefine CUDA_ARCH_BIN_OR_PTX_10
|
||||
|
||||
/* OpenCL Support */
|
||||
#cmakedefine HAVE_OPENCL
|
||||
|
||||
/* AMD's OpenCL Fast Fourier Transform Library*/
|
||||
#cmakedefine HAVE_CLAMDFFT
|
||||
|
||||
/* AMD's Basic Linear Algebra Subprograms Library*/
|
||||
#cmakedefine HAVE_CLAMDBLAS
|
||||
|
||||
/* DirectShow Video Capture library */
|
||||
#cmakedefine HAVE_DSHOW
|
||||
/* V4L/V4L2 capturing support via libv4l */
|
||||
#cmakedefine HAVE_LIBV4L
|
||||
|
||||
/* Microsoft Media Foundation Capture library */
|
||||
#cmakedefine HAVE_MSMF
|
||||
|
||||
/* XIMEA camera support */
|
||||
#cmakedefine HAVE_XIMEA
|
||||
/* NVidia Video Decoding API*/
|
||||
#cmakedefine HAVE_NVCUVID
|
||||
|
||||
/* OpenCL Support */
|
||||
#cmakedefine HAVE_OPENCL
|
||||
|
||||
/* OpenEXR codec */
|
||||
#cmakedefine HAVE_OPENEXR
|
||||
|
||||
/* OpenGL support*/
|
||||
#cmakedefine HAVE_OPENGL
|
||||
|
||||
/* Clp support */
|
||||
#cmakedefine HAVE_CLP
|
||||
/* OpenNI library */
|
||||
#cmakedefine HAVE_OPENNI
|
||||
|
||||
/* PNG codec */
|
||||
#cmakedefine HAVE_PNG
|
||||
|
||||
/* Qt support */
|
||||
#cmakedefine HAVE_QT
|
||||
|
||||
/* Qt OpenGL support */
|
||||
#cmakedefine HAVE_QT_OPENGL
|
||||
|
||||
/* QuickTime video libraries */
|
||||
#cmakedefine HAVE_QUICKTIME
|
||||
|
||||
/* QTKit video libraries */
|
||||
#cmakedefine HAVE_QTKIT
|
||||
|
||||
/* Intel Threading Building Blocks */
|
||||
#cmakedefine HAVE_TBB
|
||||
|
||||
/* TIFF codec */
|
||||
#cmakedefine HAVE_TIFF
|
||||
|
||||
/* Unicap video capture library */
|
||||
#cmakedefine HAVE_UNICAP
|
||||
|
||||
/* Video for Windows support */
|
||||
#cmakedefine HAVE_VFW
|
||||
|
||||
/* V4L2 capturing support in videoio.h */
|
||||
#cmakedefine HAVE_VIDEOIO
|
||||
|
||||
/* Win32 UI */
|
||||
#cmakedefine HAVE_WIN32UI
|
||||
|
||||
/* XIMEA camera support */
|
||||
#cmakedefine HAVE_XIMEA
|
||||
|
||||
/* Xine video library */
|
||||
#cmakedefine HAVE_XINE
|
||||
|
||||
/* Define to 1 if your processor stores words with the most significant byte
|
||||
first (like Motorola and SPARC, unlike Intel and VAX). */
|
||||
#cmakedefine WORDS_BIGENDIAN
|
||||
|
@ -8,6 +8,6 @@ includedir_new=@includedir@
|
||||
|
||||
Name: OpenCV
|
||||
Description: Open Source Computer Vision Library
|
||||
Version: @VERSION@
|
||||
Version: @OPENCV_VERSION@
|
||||
Libs: @OpenCV_LIB_COMPONENTS@
|
||||
Cflags: -I${includedir_old} -I${includedir_new}
|
||||
|
@ -6,4 +6,4 @@
|
||||
*
|
||||
*/
|
||||
|
||||
@OPENCV_MODULE_DEFINITIONS_CONFIGMAKE@
|
||||
@OPENCV_MODULE_DEFINITIONS_CONFIGMAKE@
|
||||
|
@ -49,7 +49,7 @@ if(BUILD_DOCS AND HAVE_SPHINX)
|
||||
set(toc_file "${OPENCV_MODULE_opencv_${mod}_LOCATION}/doc/${mod}.rst")
|
||||
if(EXISTS "${toc_file}")
|
||||
file(RELATIVE_PATH toc_file "${OpenCV_SOURCE_DIR}/modules" "${toc_file}")
|
||||
set(OPENCV_REFMAN_TOC "${OPENCV_REFMAN_TOC} ${toc_file}\r\n")
|
||||
set(OPENCV_REFMAN_TOC "${OPENCV_REFMAN_TOC} ${toc_file}\n")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
@ -122,4 +122,4 @@ if(BUILD_DOCS AND HAVE_SPHINX)
|
||||
install(FILES "${f}" DESTINATION "${OPENCV_DOC_INSTALL_PATH}" OPTIONAL)
|
||||
endforeach()
|
||||
|
||||
endif()
|
||||
endif()
|
||||
|
3
doc/_static/insertIframe.js
vendored
3
doc/_static/insertIframe.js
vendored
@ -1,4 +1,4 @@
|
||||
function insertIframe (elementId, iframeSrc)
|
||||
function insertIframe (elementId, iframeSrc)
|
||||
{
|
||||
var iframe;
|
||||
if (document.createElement && (iframe = document.createElement('iframe')))
|
||||
@ -10,4 +10,3 @@ function insertIframe (elementId, iframeSrc)
|
||||
element.parentNode.replaceChild(iframe, element);
|
||||
}
|
||||
}
|
||||
|
||||
|
2
doc/_themes/blue/static/default.css_t
vendored
2
doc/_themes/blue/static/default.css_t
vendored
@ -402,4 +402,4 @@ div.sphinxsidebar #searchbox input[type="text"] {
|
||||
|
||||
div.sphinxsidebar #searchbox input[type="submit"] {
|
||||
width:auto;
|
||||
}
|
||||
}
|
||||
|
2
doc/_themes/blue/theme.conf
vendored
2
doc/_themes/blue/theme.conf
vendored
@ -28,4 +28,4 @@ feedbacklinkcolor = #ffffff
|
||||
bodyfont = sans-serif
|
||||
headfont = 'Trebuchet MS', sans-serif
|
||||
guifont = "Lucida Sans","Lucida Sans Unicode","Lucida Grande",Verdana,Arial,Helvetica,sans-serif
|
||||
lang = none
|
||||
lang = none
|
||||
|
@ -184,5 +184,3 @@ p = RSTParser()
|
||||
for m in opencv_module_list:
|
||||
print "\n\n*************************** " + m + " *************************\n"
|
||||
p.check_module_docs(m)
|
||||
|
||||
|
||||
|
@ -39,4 +39,3 @@
|
||||
#7 & #8 & #9
|
||||
\end{bmatrix}
|
||||
}
|
||||
|
||||
|
@ -75,11 +75,11 @@
|
||||
% if using A4 paper. (This probably isn't strictly necessary.)
|
||||
% If using another size paper, use default 1cm margins.
|
||||
\ifthenelse{\lengthtest { \paperwidth = 11in}}
|
||||
{ \geometry{top=.5in,left=.5in,right=.5in,bottom=.5in} }
|
||||
{\ifthenelse{ \lengthtest{ \paperwidth = 297mm}}
|
||||
{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
|
||||
{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
|
||||
}
|
||||
{ \geometry{top=.5in,left=.5in,right=.5in,bottom=.5in} }
|
||||
{\ifthenelse{ \lengthtest{ \paperwidth = 297mm}}
|
||||
{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
|
||||
{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
|
||||
}
|
||||
|
||||
% Turn off header and footer
|
||||
% \pagestyle{empty}
|
||||
|
@ -4,14 +4,14 @@ INSTRUCTIONS TO BUILD WIN32 PACKAGES WITH CMAKE+CPACK
|
||||
|
||||
- Install NSIS.
|
||||
- Generate OpenCV solutions for MSVC using CMake as usual.
|
||||
- In cmake-gui:
|
||||
- In cmake-gui:
|
||||
- Mark BUILD_PACKAGE
|
||||
- Mark BUILD_EXAMPLES (If examples are desired to be shipped as binaries...)
|
||||
- Unmark ENABLE_OPENMP, since this feature seems to have some issues yet...
|
||||
- Mark INSTALL_*_EXAMPLES
|
||||
- Open the OpenCV solution and build ALL in Debug and Release.
|
||||
- Build PACKAGE, from the Release configuration. An NSIS installer package will be
|
||||
- Build PACKAGE, from the Release configuration. An NSIS installer package will be
|
||||
created with both release and debug LIBs and DLLs.
|
||||
|
||||
|
||||
|
||||
Jose Luis Blanco, 2009/JUL/29
|
||||
|
@ -3667,4 +3667,3 @@ class YErrorBars:
|
||||
output.append(LineAxis(x, start, x, end, start, end, bars, False, False, **self.attr).SVG(trans))
|
||||
|
||||
return output
|
||||
|
||||
|
@ -3,42 +3,42 @@
|
||||
Camera calibration With OpenCV
|
||||
******************************
|
||||
|
||||
Cameras have been around for a long-long time. However, with the introduction of the cheap *pinhole* cameras in the late 20th century, they became a common occurrence in our everyday life. Unfortunately, this cheapness comes with its price: significant distortion. Luckily, these are constants and with a calibration and some remapping we can correct this. Furthermore, with calibration you may also determinate the relation between the camera's natural units (pixels) and the real world units (for example millimeters).
|
||||
Cameras have been around for a long-long time. However, with the introduction of the cheap *pinhole* cameras in the late 20th century, they became a common occurrence in our everyday life. Unfortunately, this cheapness comes with its price: significant distortion. Luckily, these are constants and with a calibration and some remapping we can correct this. Furthermore, with calibration you may also determine the relation between the camera's natural units (pixels) and the real world units (for example millimeters).
|
||||
|
||||
Theory
|
||||
======
|
||||
|
||||
For the distortion OpenCV takes into account the radial and tangential factors. For the radial one uses the following formula:
|
||||
For the distortion OpenCV takes into account the radial and tangential factors. For the radial factor one uses the following formula:
|
||||
|
||||
.. math::
|
||||
.. math::
|
||||
|
||||
x_{corrected} = x( 1 + k_1 r^2 + k_2 r^4 + k_3 r^6) \\
|
||||
y_{corrected} = y( 1 + k_1 r^2 + k_2 r^4 + k_3 r^6)
|
||||
|
||||
So for an old pixel point at :math:`(x,y)` coordinate in the input image, for a corrected output image its position will be :math:`(x_{corrected} y_{corrected})` . The presence of the radial distortion manifests in form of the "barrel" or "fish-eye" effect.
|
||||
So for an old pixel point at :math:`(x,y)` coordinates in the input image, its position on the corrected output image will be :math:`(x_{corrected} y_{corrected})`. The presence of the radial distortion manifests in form of the "barrel" or "fish-eye" effect.
|
||||
|
||||
Tangential distortion occurs because the image taking lenses are not perfectly parallel to the imaging plane. Correcting this is made via the formulas:
|
||||
Tangential distortion occurs because the image taking lenses are not perfectly parallel to the imaging plane. It can be corrected via the formulas:
|
||||
|
||||
.. math::
|
||||
.. math::
|
||||
|
||||
x_{corrected} = x + [ 2p_1xy + p_2(r^2+2x^2)] \\
|
||||
y_{corrected} = y + [ p_1(r^2+ 2y^2)+ 2p_2xy]
|
||||
|
||||
So we have five distortion parameters, which in OpenCV are organized in a 5 column one row matrix:
|
||||
So we have five distortion parameters which in OpenCV are presented as one row matrix with 5 columns:
|
||||
|
||||
.. math::
|
||||
.. math::
|
||||
|
||||
Distortion_{coefficients}=(k_1 \hspace{10pt} k_2 \hspace{10pt} p_1 \hspace{10pt} p_2 \hspace{10pt} k_3)
|
||||
|
||||
Now for the unit conversion, we use the following formula:
|
||||
Now for the unit conversion we use the following formula:
|
||||
|
||||
.. math::
|
||||
|
||||
\left [ \begin{matrix} x \\ y \\ w \end{matrix} \right ] = \left [ \begin{matrix} f_x & 0 & c_x \\ 0 & f_y & c_y \\ 0 & 0 & 1 \end{matrix} \right ] \left [ \begin{matrix} X \\ Y \\ Z \end{matrix} \right ]
|
||||
|
||||
Here the presence of the :math:`w` is cause we use a homography coordinate system (and :math:`w=Z`). The unknown parameters are :math:`f_x` and :math:`f_y` (camera focal lengths) and :math:`(c_x, c_y)` what are the optical centers expressed in pixels coordinates. If for both axes a common focal length is used with a given :math:`a` aspect ratio (usually 1), then :math:`f_y=f_x*a` and in the upper formula we will have a single :math:`f` focal length. The matrix containing these four parameters is referred to as the *camera matrix*. While the distortion coefficients are the same regardless of the camera resolutions used, these should be scaled along with the current resolution from the calibrated resolution.
|
||||
Here the presence of :math:`w` is explained by the use of homography coordinate system (and :math:`w=Z`). The unknown parameters are :math:`f_x` and :math:`f_y` (camera focal lengths) and :math:`(c_x, c_y)` which are the optical centers expressed in pixels coordinates. If for both axes a common focal length is used with a given :math:`a` aspect ratio (usually 1), then :math:`f_y=f_x*a` and in the upper formula we will have a single focal length :math:`f`. The matrix containing these four parameters is referred to as the *camera matrix*. While the distortion coefficients are the same regardless of the camera resolutions used, these should be scaled along with the current resolution from the calibrated resolution.
|
||||
|
||||
The process of determining these two matrices is the calibration. Calculating these parameters is done by some basic geometrical equations. The equations used depend on the calibrating objects used. Currently OpenCV supports three types of object for calibration:
|
||||
The process of determining these two matrices is the calibration. Calculation of these parameters is done through basic geometrical equations. The equations used depend on the chosen calibrating objects. Currently OpenCV supports three types of objects for calibration:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
@ -46,28 +46,28 @@ The process of determining these two matrices is the calibration. Calculating th
|
||||
+ Symmetrical circle pattern
|
||||
+ Asymmetrical circle pattern
|
||||
|
||||
Basically, you need to take snapshots of these patterns with your camera and let OpenCV find them. Each found pattern equals in a new equation. To solve the equation you need at least a predetermined number of pattern snapshots to form a well-posed equation system. This number is higher for the chessboard pattern and less for the circle ones. For example, in theory the chessboard one requires at least two. However, in practice we have a good amount of noise present in our input images, so for good results you will probably want at least 10 good snapshots of the input pattern in different position.
|
||||
Basically, you need to take snapshots of these patterns with your camera and let OpenCV find them. Each found pattern results in a new equation. To solve the equation you need at least a predetermined number of pattern snapshots to form a well-posed equation system. This number is higher for the chessboard pattern and less for the circle ones. For example, in theory the chessboard pattern requires at least two snapshots. However, in practice we have a good amount of noise present in our input images, so for good results you will probably need at least 10 good snapshots of the input pattern in different positions.
|
||||
|
||||
Goal
|
||||
====
|
||||
|
||||
The sample application will:
|
||||
The sample application will:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
+ Determinate the distortion matrix
|
||||
+ Determinate the camera matrix
|
||||
+ Input from Camera, Video and Image file list
|
||||
+ Configuration from XML/YAML file
|
||||
+ Determine the distortion matrix
|
||||
+ Determine the camera matrix
|
||||
+ Take input from Camera, Video and Image file list
|
||||
+ Read configuration from XML/YAML file
|
||||
+ Save the results into XML/YAML file
|
||||
+ Calculate re-projection error
|
||||
|
||||
Source code
|
||||
===========
|
||||
|
||||
You may also find the source code in the :file:`samples/cpp/tutorial_code/calib3d/camera_calibration/` folder of the OpenCV source library or :download:`download it from here <../../../../samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp>`. The program has a single argument. The name of its configuration file. If none given it will try to open the one named "default.xml". :download:`Here's a sample configuration file <../../../../samples/cpp/tutorial_code/calib3d/camera_calibration/in_VID5.xml>` in XML format. In the configuration file you may choose to use as input a camera, a video file or an image list. If you opt for the later one, you need to create a configuration file where you enumerate the images to use. Here's :download:`an example of this <../../../../samples/cpp/tutorial_code/calib3d/camera_calibration/VID5.xml>`. The important part to remember is that the images needs to be specified using the absolute path or the relative one from your applications working directory. You may find all this in the beforehand mentioned directory.
|
||||
You may also find the source code in the :file:`samples/cpp/tutorial_code/calib3d/camera_calibration/` folder of the OpenCV source library or :download:`download it from here <../../../../samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp>`. The program has a single argument: the name of its configuration file. If none is given then it will try to open the one named "default.xml". :download:`Here's a sample configuration file <../../../../samples/cpp/tutorial_code/calib3d/camera_calibration/in_VID5.xml>` in XML format. In the configuration file you may choose to use camera as an input, a video file or an image list. If you opt for the last one, you will need to create a configuration file where you enumerate the images to use. Here's :download:`an example of this <../../../../samples/cpp/tutorial_code/calib3d/camera_calibration/VID5.xml>`. The important part to remember is that the images need to be specified using the absolute path or the relative one from your application's working directory. You may find all this in the samples directory mentioned above.
|
||||
|
||||
The application starts up with reading the settings from the configuration file. Although, this is an important part of it, it has nothing to do with the subject of this tutorial: *camera calibration*. Therefore, I've chosen to do not post here the code part for that. The technical background on how to do this you can find in the :ref:`fileInputOutputXMLYAML` tutorial.
|
||||
The application starts up with reading the settings from the configuration file. Although, this is an important part of it, it has nothing to do with the subject of this tutorial: *camera calibration*. Therefore, I've chosen not to post the code for that part here. Technical background on how to do this you can find in the :ref:`fileInputOutputXMLYAML` tutorial.
|
||||
|
||||
Explanation
|
||||
===========
|
||||
@ -76,15 +76,15 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
Settings s;
|
||||
Settings s;
|
||||
const string inputSettingsFile = argc > 1 ? argv[1] : "default.xml";
|
||||
FileStorage fs(inputSettingsFile, FileStorage::READ); // Read the settings
|
||||
if (!fs.isOpened())
|
||||
{
|
||||
cout << "Could not open the configuration file: \"" << inputSettingsFile << "\"" << endl;
|
||||
cout << "Could not open the configuration file: \"" << inputSettingsFile << "\"" << endl;
|
||||
return -1;
|
||||
}
|
||||
fs["Settings"] >> s;
|
||||
fs["Settings"] >> s;
|
||||
fs.release(); // close Settings file
|
||||
|
||||
if (!s.goodInput)
|
||||
@ -93,9 +93,9 @@ Explanation
|
||||
return -1;
|
||||
}
|
||||
|
||||
For this I've used simple OpenCV class input operation. After reading the file I've an additional post-process function that checks for the validity of the input. Only if all of them are good will be the *goodInput* variable true.
|
||||
For this I've used simple OpenCV class input operation. After reading the file I've an additional post-processing function that checks validity of the input. Only if all inputs are good then *goodInput* variable will be true.
|
||||
|
||||
#. **Get next input, if it fails or we have enough of them calibrate**. After this we have a big loop where we do the following operations: get the next image from the image list, camera or video file. If this fails or we have enough images we run the calibration process. In case of image we step out of the loop and otherwise the remaining frames will be undistorted (if the option is set) via changing from *DETECTION* mode to *CALIBRATED* one.
|
||||
#. **Get next input, if it fails or we have enough of them - calibrate**. After this we have a big loop where we do the following operations: get the next image from the image list, camera or video file. If this fails or we have enough images then we run the calibration process. In case of image we step out of the loop and otherwise the remaining frames will be undistorted (if the option is set) via changing from *DETECTION* mode to the *CALIBRATED* one.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -123,9 +123,9 @@ Explanation
|
||||
if( s.flipVertical ) flip( view, view, 0 );
|
||||
}
|
||||
|
||||
For some cameras we may need to flip the input image. Here we do this too.
|
||||
For some cameras we may need to flip the input image. Here we do this too.
|
||||
|
||||
#. **Find the pattern in the current input**. The formation of the equations I mentioned above consists of finding the major patterns in the input: in case of the chessboard this is their corners of the squares and for the circles, well, the circles itself. The position of these will form the result and is collected into the *pointBuf* vector.
|
||||
#. **Find the pattern in the current input**. The formation of the equations I mentioned above aims to finding major patterns in the input: in case of the chessboard this are corners of the squares and for the circles, well, the circles themselves. The position of these will form the result which will be written into the *pointBuf* vector.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -146,19 +146,19 @@ Explanation
|
||||
break;
|
||||
}
|
||||
|
||||
Depending on the type of the input pattern you use either the :calib3d:`findChessboardCorners <findchessboardcorners>` or the :calib3d:`findCirclesGrid <findcirclesgrid>` function. For both of them you pass on the current image, the size of the board and you'll get back the positions of the patterns. Furthermore, they return a boolean variable that states if in the input we could find or not the pattern (we only need to take into account images where this is true!).
|
||||
Depending on the type of the input pattern you use either the :calib3d:`findChessboardCorners <findchessboardcorners>` or the :calib3d:`findCirclesGrid <findcirclesgrid>` function. For both of them you pass the current image and the size of the board and you'll get the positions of the patterns. Furthermore, they return a boolean variable which states if the pattern was found in the input (we only need to take into account those images where this is true!).
|
||||
|
||||
Then again in case of cameras we only take camera images after an input delay time passed. This is in order to allow for the user to move the chessboard around and as getting different images. Same images mean same equations, and same equations at the calibration will form an ill-posed problem, so the calibration will fail. For square images the position of the corners are only approximate. We may improve this by calling the :feature2d:`cornerSubPix <cornersubpix>` function. This way will get a better calibration result. After this we add a valid inputs result to the *imagePoints* vector to collect all of the equations into a single container. Finally, for visualization feedback purposes we will draw the found points on the input image with the :calib3d:`findChessboardCorners <drawchessboardcorners>` function.
|
||||
Then again in case of cameras we only take camera images when an input delay time is passed. This is done in order to allow user moving the chessboard around and getting different images. Similar images result in similar equations, and similar equations at the calibration step will form an ill-posed problem, so the calibration will fail. For square images the positions of the corners are only approximate. We may improve this by calling the :feature2d:`cornerSubPix <cornersubpix>` function. It will produce better calibration result. After this we add a valid inputs result to the *imagePoints* vector to collect all of the equations into a single container. Finally, for visualization feedback purposes we will draw the found points on the input image using :calib3d:`findChessboardCorners <drawchessboardcorners>` function.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
if ( found) // If done with success,
|
||||
if ( found) // If done with success,
|
||||
{
|
||||
// improve the found corners' coordinate accuracy for chessboard
|
||||
if( s.calibrationPattern == Settings::CHESSBOARD)
|
||||
if( s.calibrationPattern == Settings::CHESSBOARD)
|
||||
{
|
||||
Mat viewGray;
|
||||
cvtColor(view, viewGray, CV_BGR2GRAY);
|
||||
cvtColor(view, viewGray, CV_BGR2GRAY);
|
||||
cornerSubPix( viewGray, pointBuf, Size(11,11),
|
||||
Size(-1,-1), TermCriteria( CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 30, 0.1 ));
|
||||
}
|
||||
@ -171,11 +171,11 @@ Explanation
|
||||
blinkOutput = s.inputCapture.isOpened();
|
||||
}
|
||||
|
||||
// Draw the corners.
|
||||
// Draw the corners.
|
||||
drawChessboardCorners( view, s.boardSize, Mat(pointBuf), found );
|
||||
}
|
||||
|
||||
#. **Show state and result for the user, plus command line control of the application**. The showing part consists of a text output on the live feed, and for video or camera input to show the "capturing" frame we simply bitwise negate the input image.
|
||||
#. **Show state and result to the user, plus command line control of the application**. This part shows text output on the image.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -183,7 +183,7 @@ Explanation
|
||||
string msg = (mode == CAPTURING) ? "100/100" :
|
||||
mode == CALIBRATED ? "Calibrated" : "Press 'g' to start";
|
||||
int baseLine = 0;
|
||||
Size textSize = getTextSize(msg, 1, 1, 1, &baseLine);
|
||||
Size textSize = getTextSize(msg, 1, 1, 1, &baseLine);
|
||||
Point textOrigin(view.cols - 2*textSize.width - 10, view.rows - 2*baseLine - 10);
|
||||
|
||||
if( mode == CAPTURING )
|
||||
@ -199,7 +199,7 @@ Explanation
|
||||
if( blinkOutput )
|
||||
bitwise_not(view, view);
|
||||
|
||||
If we only ran the calibration and got the camera matrix plus the distortion coefficients we may just as correct the image with the :imgproc_geometric:`undistort <undistort>` function:
|
||||
If we ran calibration and got camera's matrix with the distortion coefficients we may want to correct the image using :imgproc_geometric:`undistort <undistort>` function:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -212,7 +212,7 @@ Explanation
|
||||
//------------------------------ Show image and check for input commands -------------------
|
||||
imshow("Image View", view);
|
||||
|
||||
Then we wait for an input key and if this is *u* we toggle the distortion removal, if it is *g* we start all over the detection process (or simply start it), and finally for the *ESC* key quit the application:
|
||||
Then we wait for an input key and if this is *u* we toggle the distortion removal, if it is *g* we start again the detection process, and finally for the *ESC* key we quit the application:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -229,7 +229,7 @@ Explanation
|
||||
imagePoints.clear();
|
||||
}
|
||||
|
||||
#. **Show the distortion removal for the images too**. When you work with an image list it is not possible to remove the distortion inside the loop. Therefore, you must append this after the loop. Taking advantage of this now I'll expand the :imgproc_geometric:`undistort <undistort>` function, which is in fact first a call of the :imgproc_geometric:`initUndistortRectifyMap <initundistortrectifymap>` to find out the transformation matrices and then doing the transformation with the :imgproc_geometric:`remap <remap>` function. Because, after a successful calibration the map calculation needs to be done only once, by using this expanded form you may speed up your application:
|
||||
#. **Show the distortion removal for the images too**. When you work with an image list it is not possible to remove the distortion inside the loop. Therefore, you must do this after the loop. Taking advantage of this now I'll expand the :imgproc_geometric:`undistort <undistort>` function, which is in fact first calls :imgproc_geometric:`initUndistortRectifyMap <initundistortrectifymap>` to find transformation matrices and then performs transformation using :imgproc_geometric:`remap <remap>` function. Because, after successful calibration map calculation needs to be done only once, by using this expanded form you may speed up your application:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -256,9 +256,9 @@ Explanation
|
||||
The calibration and save
|
||||
========================
|
||||
|
||||
Because the calibration needs to be only once per camera it makes sense to save them after a successful calibration. This way later on you can just load these values into your program. Due to this we first make the calibration, and if it succeeds we save the result into an OpenCV style XML or YAML file, depending on the extension you give in the configuration file.
|
||||
Because the calibration needs to be done only once per camera, it makes sense to save it after a successful calibration. This way later on you can just load these values into your program. Due to this we first make the calibration, and if it succeeds we save the result into an OpenCV style XML or YAML file, depending on the extension you give in the configuration file.
|
||||
|
||||
Therefore in the first function we just split up these two processes. Because we want to save many of the calibration variables we'll create these variables here and pass on both of them to the calibration and saving function. Again, I'll not show the saving part as that has little in common with the calibration. Explore the source file in order to find out how and what:
|
||||
Therefore in the first function we just split up these two processes. Because we want to save many of the calibration variables we'll create these variables here and pass on both of them to the calibration and saving function. Again, I'll not show the saving part as that has little in common with the calibration. Explore the source file in order to find out how and what:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -269,10 +269,10 @@ Therefore in the first function we just split up these two processes. Because we
|
||||
vector<float> reprojErrs;
|
||||
double totalAvgErr = 0;
|
||||
|
||||
bool ok = runCalibration(s,imageSize, cameraMatrix, distCoeffs, imagePoints, rvecs, tvecs,
|
||||
bool ok = runCalibration(s,imageSize, cameraMatrix, distCoeffs, imagePoints, rvecs, tvecs,
|
||||
reprojErrs, totalAvgErr);
|
||||
cout << (ok ? "Calibration succeeded" : "Calibration failed")
|
||||
<< ". avg re projection error = " << totalAvgErr ;
|
||||
<< ". avg re projection error = " << totalAvgErr ;
|
||||
|
||||
if( ok ) // save only if the calibration was done with success
|
||||
saveCameraParams( s, imageSize, cameraMatrix, distCoeffs, rvecs ,tvecs, reprojErrs,
|
||||
@ -280,15 +280,15 @@ Therefore in the first function we just split up these two processes. Because we
|
||||
return ok;
|
||||
}
|
||||
|
||||
We do the calibration with the help of the :calib3d:`calibrateCamera <calibratecamera>` function. This has the following parameters:
|
||||
We do the calibration with the help of the :calib3d:`calibrateCamera <calibratecamera>` function. It has the following parameters:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
+ The object points. This is a vector of *Point3f* vector that for each input image describes how should the pattern look. If we have a planar pattern (like a chessboard) then we can simply set all Z coordinates to zero. This is a collection of the points where these important points are present. Because, we use a single pattern for all the input images we can calculate this just once and multiply it for all the other input views. We calculate the corner points with the *calcBoardCornerPositions* function as:
|
||||
+ The object points. This is a vector of *Point3f* vector that for each input image describes how should the pattern look. If we have a planar pattern (like a chessboard) then we can simply set all Z coordinates to zero. This is a collection of the points where these important points are present. Because, we use a single pattern for all the input images we can calculate this just once and multiply it for all the other input views. We calculate the corner points with the *calcBoardCornerPositions* function as:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
void calcBoardCornerPositions(Size boardSize, float squareSize, vector<Point3f>& corners,
|
||||
void calcBoardCornerPositions(Size boardSize, float squareSize, vector<Point3f>& corners,
|
||||
Settings::Pattern patternType /*= Settings::CHESSBOARD*/)
|
||||
{
|
||||
corners.clear();
|
||||
@ -310,19 +310,19 @@ We do the calibration with the help of the :calib3d:`calibrateCamera <calibratec
|
||||
}
|
||||
}
|
||||
|
||||
And then multiply it as:
|
||||
And then multiply it as:
|
||||
|
||||
.. code-block:: cpp
|
||||
.. code-block:: cpp
|
||||
|
||||
vector<vector<Point3f> > objectPoints(1);
|
||||
calcBoardCornerPositions(s.boardSize, s.squareSize, objectPoints[0], s.calibrationPattern);
|
||||
objectPoints.resize(imagePoints.size(),objectPoints[0]);
|
||||
objectPoints.resize(imagePoints.size(),objectPoints[0]);
|
||||
|
||||
+ The image points. This is a vector of *Point2f* vector that for each input image contains where the important points (corners for chessboard, and center of circles for the circle patterns) were found. We already collected this from what the :calib3d:`findChessboardCorners <findchessboardcorners>` or the :calib3d:`findCirclesGrid <findcirclesgrid>` function returned. We just need to pass it on.
|
||||
+ The image points. This is a vector of *Point2f* vector which for each input image contains coordinates of the important points (corners for chessboard and centers of the circles for the circle pattern). We have already collected this from :calib3d:`findChessboardCorners <findchessboardcorners>` or :calib3d:`findCirclesGrid <findcirclesgrid>` function. We just need to pass it on.
|
||||
|
||||
+ The size of the image acquired from the camera, video file or the images.
|
||||
+ The size of the image acquired from the camera, video file or the images.
|
||||
|
||||
+ The camera matrix. If we used the fix aspect ratio option we need to set the :math:`f_x` to zero:
|
||||
+ The camera matrix. If we used the fixed aspect ratio option we need to set the :math:`f_x` to zero:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -330,24 +330,24 @@ We do the calibration with the help of the :calib3d:`calibrateCamera <calibratec
|
||||
if( s.flag & CV_CALIB_FIX_ASPECT_RATIO )
|
||||
cameraMatrix.at<double>(0,0) = 1.0;
|
||||
|
||||
+ The distortion coefficient matrix. Initialize with zero.
|
||||
+ The distortion coefficient matrix. Initialize with zero.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
distCoeffs = Mat::zeros(8, 1, CV_64F);
|
||||
|
||||
+ The function will calculate for all the views the rotation and translation vector that transform the object points (given in the model coordinate space) to the image points (given in the world coordinate space). The 7th and 8th parameters are an output vector of matrices containing in the ith position the rotation and translation vector for the ith object point to the ith image point.
|
||||
+ For all the views the function will calculate rotation and translation vectors which transform the object points (given in the model coordinate space) to the image points (given in the world coordinate space). The 7-th and 8-th parameters are the output vector of matrices containing in the i-th position the rotation and translation vector for the i-th object point to the i-th image point.
|
||||
|
||||
+ The final argument is a flag. You need to specify here options like fix the aspect ratio for the focal length, assume zero tangential distortion or to fix the principal point.
|
||||
+ The final argument is the flag. You need to specify here options like fix the aspect ratio for the focal length, assume zero tangential distortion or to fix the principal point.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
double rms = calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix,
|
||||
distCoeffs, rvecs, tvecs, s.flag|CV_CALIB_FIX_K4|CV_CALIB_FIX_K5);
|
||||
|
||||
+ The function returns the average re-projection error. This number gives a good estimation of just how exact is the found parameters. This should be as close to zero as possible. Given the intrinsic, distortion, rotation and translation matrices we may calculate the error for one view by using the :calib3d:`projectPoints <projectpoints>` to first transform the object point to image point. Then we calculate the absolute norm between what we got with our transformation and the corner/circle finding algorithm. To find the average error we calculate the arithmetical mean of the errors calculate for all the calibration images.
|
||||
+ The function returns the average re-projection error. This number gives a good estimation of precision of the found parameters. This should be as close to zero as possible. Given the intrinsic, distortion, rotation and translation matrices we may calculate the error for one view by using the :calib3d:`projectPoints <projectpoints>` to first transform the object point to image point. Then we calculate the absolute norm between what we got with our transformation and the corner/circle finding algorithm. To find the average error we calculate the arithmetical mean of the errors calculated for all the calibration images.
|
||||
|
||||
.. code-block:: cpp
|
||||
.. code-block:: cpp
|
||||
|
||||
double computeReprojectionErrors( const vector<vector<Point3f> >& objectPoints,
|
||||
const vector<vector<Point2f> >& imagePoints,
|
||||
@ -378,43 +378,43 @@ We do the calibration with the help of the :calib3d:`calibrateCamera <calibratec
|
||||
Results
|
||||
=======
|
||||
|
||||
Let there be :download:`this input chessboard pattern <../../../pattern.png>` that has a size of 9 X 6. I've used an AXIS IP camera to create a couple of snapshots of the board and saved it into a VID5 directory. I've put this inside the :file:`images/CameraCalibraation` folder of my working directory and created the following :file:`VID5.XML` file that describes which images to use:
|
||||
Let there be :download:`this input chessboard pattern <../../../pattern.png>` which has a size of 9 X 6. I've used an AXIS IP camera to create a couple of snapshots of the board and saved it into VID5 directory. I've put this inside the :file:`images/CameraCalibration` folder of my working directory and created the following :file:`VID5.XML` file that describes which images to use:
|
||||
|
||||
.. code-block:: xml
|
||||
|
||||
<?xml version="1.0"?>
|
||||
<opencv_storage>
|
||||
<images>
|
||||
images/CameraCalibraation/VID5/xx1.jpg
|
||||
images/CameraCalibraation/VID5/xx2.jpg
|
||||
images/CameraCalibraation/VID5/xx3.jpg
|
||||
images/CameraCalibraation/VID5/xx4.jpg
|
||||
images/CameraCalibraation/VID5/xx5.jpg
|
||||
images/CameraCalibraation/VID5/xx6.jpg
|
||||
images/CameraCalibraation/VID5/xx7.jpg
|
||||
images/CameraCalibraation/VID5/xx8.jpg
|
||||
images/CameraCalibration/VID5/xx1.jpg
|
||||
images/CameraCalibration/VID5/xx2.jpg
|
||||
images/CameraCalibration/VID5/xx3.jpg
|
||||
images/CameraCalibration/VID5/xx4.jpg
|
||||
images/CameraCalibration/VID5/xx5.jpg
|
||||
images/CameraCalibration/VID5/xx6.jpg
|
||||
images/CameraCalibration/VID5/xx7.jpg
|
||||
images/CameraCalibration/VID5/xx8.jpg
|
||||
</images>
|
||||
</opencv_storage>
|
||||
|
||||
Then specified the :file:`images/CameraCalibraation/VID5/VID5.XML` as input in the configuration file. Here's a chessboard pattern found during the runtime of the application:
|
||||
Then passed :file:`images/CameraCalibration/VID5/VID5.XML` as an input in the configuration file. Here's a chessboard pattern found during the runtime of the application:
|
||||
|
||||
.. image:: images/fileListImage.jpg
|
||||
.. image:: images/fileListImage.jpg
|
||||
:alt: A found chessboard
|
||||
:align: center
|
||||
|
||||
After applying the distortion removal we get:
|
||||
After applying the distortion removal we get:
|
||||
|
||||
.. image:: images/fileListImageUnDist.jpg
|
||||
.. image:: images/fileListImageUnDist.jpg
|
||||
:alt: Distortion removal for File List
|
||||
:align: center
|
||||
|
||||
The same works for :download:`this asymmetrical circle pattern <../../../acircles_pattern.png>` by setting the input width to 4 and height to 11. This time I've used a live camera feed by specifying its ID ("1") for the input. Here's, how a detected pattern should look:
|
||||
The same works for :download:`this asymmetrical circle pattern <../../../acircles_pattern.png>` by setting the input width to 4 and height to 11. This time I've used a live camera feed by specifying its ID ("1") for the input. Here's, how a detected pattern should look:
|
||||
|
||||
.. image:: images/asymetricalPattern.jpg
|
||||
.. image:: images/asymetricalPattern.jpg
|
||||
:alt: Asymmetrical circle detection
|
||||
:align: center
|
||||
|
||||
In both cases in the specified output XML/YAML file you'll find the camera and distortion coefficients matrices:
|
||||
In both cases in the specified output XML/YAML file you'll find the camera and distortion coefficients matrices:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -433,9 +433,9 @@ In both cases in the specified output XML/YAML file you'll find the camera and d
|
||||
-4.1802327176423804e-001 5.0715244063187526e-001 0. 0.
|
||||
-5.7843597214487474e-001</data></Distortion_Coefficients>
|
||||
|
||||
Add these values as constants to your program, call the :imgproc_geometric:`initUndistortRectifyMap <initundistortrectifymap>` and the :imgproc_geometric:`remap <remap>` function to remove distortion and enjoy distortion free inputs with cheap and low quality cameras.
|
||||
Add these values as constants to your program, call the :imgproc_geometric:`initUndistortRectifyMap <initundistortrectifymap>` and the :imgproc_geometric:`remap <remap>` function to remove distortion and enjoy distortion free inputs for cheap and low quality cameras.
|
||||
|
||||
You may observe a runtime instance of this on the `YouTube here <https://www.youtube.com/watch?v=ViPN810E0SU>`_.
|
||||
You may observe a runtime instance of this on the `YouTube here <https://www.youtube.com/watch?v=ViPN810E0SU>`_.
|
||||
|
||||
.. raw:: html
|
||||
|
||||
|
@ -7,16 +7,16 @@ Camera calibration with square chessboard
|
||||
|
||||
The goal of this tutorial is to learn how to calibrate a camera given a set of chessboard images.
|
||||
|
||||
*Test data*: use images in your data/chess folder.
|
||||
*Test data*: use images in your data/chess folder.
|
||||
|
||||
#.
|
||||
Compile opencv with samples by setting ``BUILD_EXAMPLES`` to ``ON`` in cmake configuration.
|
||||
Compile opencv with samples by setting ``BUILD_EXAMPLES`` to ``ON`` in cmake configuration.
|
||||
|
||||
#.
|
||||
Go to ``bin`` folder and use ``imagelist_creator`` to create an ``XML/YAML`` list of your images.
|
||||
|
||||
|
||||
#.
|
||||
Then, run ``calibration`` sample to get camera parameters. Use square size equal to 3cm.
|
||||
Then, run ``calibration`` sample to get camera parameters. Use square size equal to 3cm.
|
||||
|
||||
Pose estimation
|
||||
===============
|
||||
@ -57,6 +57,6 @@ Now, let us write a code that detects a chessboard in a new image and finds its
|
||||
distCoeffs, rvec, tvec, false);
|
||||
|
||||
#.
|
||||
Calculate reprojection error like it is done in ``calibration`` sample (see ``opencv/samples/cpp/calibration.cpp``, function ``computeReprojectionErrors``).
|
||||
Calculate reprojection error like it is done in ``calibration`` sample (see ``opencv/samples/cpp/calibration.cpp``, function ``computeReprojectionErrors``).
|
||||
|
||||
Question: how to calculate the distance from the camera origin to any of the corners?
|
||||
Question: how to calculate the distance from the camera origin to any of the corners?
|
||||
|
@ -3,11 +3,11 @@
|
||||
*calib3d* module. Camera calibration and 3D reconstruction
|
||||
-----------------------------------------------------------
|
||||
|
||||
Although we got most of our images in a 2D format they do come from a 3D world. Here you will learn how to find out from the 2D images information about the 3D world.
|
||||
Although we got most of our images in a 2D format they do come from a 3D world. Here you will learn how to find out from the 2D images information about the 3D world.
|
||||
|
||||
.. include:: ../../definitions/tocDefinitions.rst
|
||||
.. include:: ../../definitions/tocDefinitions.rst
|
||||
|
||||
+
|
||||
+
|
||||
.. tabularcolumns:: m{100pt} m{300pt}
|
||||
.. cssclass:: toctableopencv
|
||||
|
||||
@ -26,7 +26,7 @@ Although we got most of our images in a 2D format they do come from a 3D world.
|
||||
:height: 90pt
|
||||
:width: 90pt
|
||||
|
||||
+
|
||||
+
|
||||
.. tabularcolumns:: m{100pt} m{300pt}
|
||||
.. cssclass:: toctableopencv
|
||||
|
||||
|
@ -18,7 +18,7 @@ Theory
|
||||
|
||||
.. note::
|
||||
|
||||
The explanation below belongs to the book `Computer Vision: Algorithms and Applications <http://szeliski.org/Book/>`_ by Richard Szeliski
|
||||
The explanation below belongs to the book `Computer Vision: Algorithms and Applications <http://szeliski.org/Book/>`_ by Richard Szeliski
|
||||
|
||||
From our previous tutorial, we know already a bit of *Pixel operators*. An interesting dyadic (two-input) operator is the *linear blend operator*:
|
||||
|
||||
@ -43,7 +43,7 @@ As usual, after the not-so-lengthy explanation, let's go to the code:
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
double alpha = 0.5; double beta; double input;
|
||||
double alpha = 0.5; double beta; double input;
|
||||
|
||||
Mat src1, src2, dst;
|
||||
|
||||
@ -69,7 +69,7 @@ As usual, after the not-so-lengthy explanation, let's go to the code:
|
||||
|
||||
beta = ( 1.0 - alpha );
|
||||
addWeighted( src1, alpha, src2, beta, 0.0, dst);
|
||||
|
||||
|
||||
imshow( "Linear Blend", dst );
|
||||
|
||||
waitKey(0);
|
||||
@ -99,10 +99,10 @@ Explanation
|
||||
#. Now we need to generate the :math:`g(x)` image. For this, the function :add_weighted:`addWeighted <>` comes quite handy:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
|
||||
beta = ( 1.0 - alpha );
|
||||
addWeighted( src1, alpha, src2, beta, 0.0, dst);
|
||||
|
||||
|
||||
since :add_weighted:`addWeighted <>` produces:
|
||||
|
||||
.. math::
|
||||
@ -110,12 +110,12 @@ Explanation
|
||||
dst = \alpha \cdot src1 + \beta \cdot src2 + \gamma
|
||||
|
||||
In this case, :math:`\gamma` is the argument :math:`0.0` in the code above.
|
||||
|
||||
#. Create windows, show the images and wait for the user to end the program.
|
||||
|
||||
#. Create windows, show the images and wait for the user to end the program.
|
||||
|
||||
Result
|
||||
=======
|
||||
|
||||
.. image:: images/Adding_Images_Tutorial_Result_0.jpg
|
||||
:alt: Blending Images Tutorial - Final Result
|
||||
:align: center
|
||||
:align: center
|
||||
|
@ -99,11 +99,11 @@ Explanation
|
||||
|
||||
/// 2.b. Creating rectangles
|
||||
rectangle( rook_image,
|
||||
Point( 0, 7*w/8.0 ),
|
||||
Point( w, w),
|
||||
Scalar( 0, 255, 255 ),
|
||||
-1,
|
||||
8 );
|
||||
Point( 0, 7*w/8.0 ),
|
||||
Point( w, w),
|
||||
Scalar( 0, 255, 255 ),
|
||||
-1,
|
||||
8 );
|
||||
|
||||
/// 2.c. Create a few lines
|
||||
MyLine( rook_image, Point( 0, 15*w/16 ), Point( w, 15*w/16 ) );
|
||||
@ -118,16 +118,16 @@ Explanation
|
||||
.. code-block:: cpp
|
||||
|
||||
void MyLine( Mat img, Point start, Point end )
|
||||
{
|
||||
int thickness = 2;
|
||||
int lineType = 8;
|
||||
line( img,
|
||||
start,
|
||||
end,
|
||||
Scalar( 0, 0, 0 ),
|
||||
thickness,
|
||||
lineType );
|
||||
}
|
||||
{
|
||||
int thickness = 2;
|
||||
int lineType = 8;
|
||||
line( img,
|
||||
start,
|
||||
end,
|
||||
Scalar( 0, 0, 0 ),
|
||||
thickness,
|
||||
lineType );
|
||||
}
|
||||
|
||||
As we can see, *MyLine* just call the function :line:`line <>`, which does the following:
|
||||
|
||||
@ -145,18 +145,18 @@ Explanation
|
||||
|
||||
void MyEllipse( Mat img, double angle )
|
||||
{
|
||||
int thickness = 2;
|
||||
int lineType = 8;
|
||||
int thickness = 2;
|
||||
int lineType = 8;
|
||||
|
||||
ellipse( img,
|
||||
Point( w/2.0, w/2.0 ),
|
||||
Size( w/4.0, w/16.0 ),
|
||||
angle,
|
||||
0,
|
||||
360,
|
||||
Scalar( 255, 0, 0 ),
|
||||
thickness,
|
||||
lineType );
|
||||
ellipse( img,
|
||||
Point( w/2.0, w/2.0 ),
|
||||
Size( w/4.0, w/16.0 ),
|
||||
angle,
|
||||
0,
|
||||
360,
|
||||
Scalar( 255, 0, 0 ),
|
||||
thickness,
|
||||
lineType );
|
||||
}
|
||||
|
||||
From the code above, we can observe that the function :ellipse:`ellipse <>` draws an ellipse such that:
|
||||
@ -176,17 +176,17 @@ Explanation
|
||||
.. code-block:: cpp
|
||||
|
||||
void MyFilledCircle( Mat img, Point center )
|
||||
{
|
||||
int thickness = -1;
|
||||
int lineType = 8;
|
||||
{
|
||||
int thickness = -1;
|
||||
int lineType = 8;
|
||||
|
||||
circle( img,
|
||||
center,
|
||||
w/32.0,
|
||||
Scalar( 0, 0, 255 ),
|
||||
thickness,
|
||||
lineType );
|
||||
}
|
||||
circle( img,
|
||||
center,
|
||||
w/32.0,
|
||||
Scalar( 0, 0, 255 ),
|
||||
thickness,
|
||||
lineType );
|
||||
}
|
||||
|
||||
Similar to the ellipse function, we can observe that *circle* receives as arguments:
|
||||
|
||||
@ -203,41 +203,41 @@ Explanation
|
||||
.. code-block:: cpp
|
||||
|
||||
void MyPolygon( Mat img )
|
||||
{
|
||||
int lineType = 8;
|
||||
{
|
||||
int lineType = 8;
|
||||
|
||||
/** Create some points */
|
||||
Point rook_points[1][20];
|
||||
rook_points[0][0] = Point( w/4.0, 7*w/8.0 );
|
||||
rook_points[0][1] = Point( 3*w/4.0, 7*w/8.0 );
|
||||
rook_points[0][2] = Point( 3*w/4.0, 13*w/16.0 );
|
||||
rook_points[0][3] = Point( 11*w/16.0, 13*w/16.0 );
|
||||
rook_points[0][4] = Point( 19*w/32.0, 3*w/8.0 );
|
||||
rook_points[0][5] = Point( 3*w/4.0, 3*w/8.0 );
|
||||
rook_points[0][6] = Point( 3*w/4.0, w/8.0 );
|
||||
rook_points[0][7] = Point( 26*w/40.0, w/8.0 );
|
||||
rook_points[0][8] = Point( 26*w/40.0, w/4.0 );
|
||||
rook_points[0][9] = Point( 22*w/40.0, w/4.0 );
|
||||
rook_points[0][10] = Point( 22*w/40.0, w/8.0 );
|
||||
rook_points[0][11] = Point( 18*w/40.0, w/8.0 );
|
||||
rook_points[0][12] = Point( 18*w/40.0, w/4.0 );
|
||||
rook_points[0][13] = Point( 14*w/40.0, w/4.0 );
|
||||
rook_points[0][14] = Point( 14*w/40.0, w/8.0 );
|
||||
rook_points[0][15] = Point( w/4.0, w/8.0 );
|
||||
rook_points[0][16] = Point( w/4.0, 3*w/8.0 );
|
||||
rook_points[0][17] = Point( 13*w/32.0, 3*w/8.0 );
|
||||
rook_points[0][18] = Point( 5*w/16.0, 13*w/16.0 );
|
||||
rook_points[0][19] = Point( w/4.0, 13*w/16.0) ;
|
||||
/** Create some points */
|
||||
Point rook_points[1][20];
|
||||
rook_points[0][0] = Point( w/4.0, 7*w/8.0 );
|
||||
rook_points[0][1] = Point( 3*w/4.0, 7*w/8.0 );
|
||||
rook_points[0][2] = Point( 3*w/4.0, 13*w/16.0 );
|
||||
rook_points[0][3] = Point( 11*w/16.0, 13*w/16.0 );
|
||||
rook_points[0][4] = Point( 19*w/32.0, 3*w/8.0 );
|
||||
rook_points[0][5] = Point( 3*w/4.0, 3*w/8.0 );
|
||||
rook_points[0][6] = Point( 3*w/4.0, w/8.0 );
|
||||
rook_points[0][7] = Point( 26*w/40.0, w/8.0 );
|
||||
rook_points[0][8] = Point( 26*w/40.0, w/4.0 );
|
||||
rook_points[0][9] = Point( 22*w/40.0, w/4.0 );
|
||||
rook_points[0][10] = Point( 22*w/40.0, w/8.0 );
|
||||
rook_points[0][11] = Point( 18*w/40.0, w/8.0 );
|
||||
rook_points[0][12] = Point( 18*w/40.0, w/4.0 );
|
||||
rook_points[0][13] = Point( 14*w/40.0, w/4.0 );
|
||||
rook_points[0][14] = Point( 14*w/40.0, w/8.0 );
|
||||
rook_points[0][15] = Point( w/4.0, w/8.0 );
|
||||
rook_points[0][16] = Point( w/4.0, 3*w/8.0 );
|
||||
rook_points[0][17] = Point( 13*w/32.0, 3*w/8.0 );
|
||||
rook_points[0][18] = Point( 5*w/16.0, 13*w/16.0 );
|
||||
rook_points[0][19] = Point( w/4.0, 13*w/16.0) ;
|
||||
|
||||
const Point* ppt[1] = { rook_points[0] };
|
||||
int npt[] = { 20 };
|
||||
const Point* ppt[1] = { rook_points[0] };
|
||||
int npt[] = { 20 };
|
||||
|
||||
fillPoly( img,
|
||||
ppt,
|
||||
npt,
|
||||
1,
|
||||
Scalar( 255, 255, 255 ),
|
||||
lineType );
|
||||
fillPoly( img,
|
||||
ppt,
|
||||
npt,
|
||||
1,
|
||||
Scalar( 255, 255, 255 ),
|
||||
lineType );
|
||||
}
|
||||
|
||||
To draw a filled polygon we use the function :fill_poly:`fillPoly <>`. We note that:
|
||||
@ -255,11 +255,11 @@ Explanation
|
||||
.. code-block:: cpp
|
||||
|
||||
rectangle( rook_image,
|
||||
Point( 0, 7*w/8.0 ),
|
||||
Point( w, w),
|
||||
Scalar( 0, 255, 255 ),
|
||||
-1,
|
||||
8 );
|
||||
Point( 0, 7*w/8.0 ),
|
||||
Point( w, w),
|
||||
Scalar( 0, 255, 255 ),
|
||||
-1,
|
||||
8 );
|
||||
|
||||
Finally we have the :rectangle:`rectangle <>` function (we did not create a special function for this guy). We note that:
|
||||
|
||||
|
@ -10,7 +10,7 @@ In this tutorial you will learn how to:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
+ Access pixel values
|
||||
+ Access pixel values
|
||||
|
||||
+ Initialize a matrix with zeros
|
||||
|
||||
@ -20,16 +20,16 @@ In this tutorial you will learn how to:
|
||||
|
||||
Theory
|
||||
=======
|
||||
|
||||
|
||||
.. note::
|
||||
The explanation below belongs to the book `Computer Vision: Algorithms and Applications <http://szeliski.org/Book/>`_ by Richard Szeliski
|
||||
The explanation below belongs to the book `Computer Vision: Algorithms and Applications <http://szeliski.org/Book/>`_ by Richard Szeliski
|
||||
|
||||
Image Processing
|
||||
--------------------
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* A general image processing operator is a function that takes one or more input images and produces an output image.
|
||||
* A general image processing operator is a function that takes one or more input images and produces an output image.
|
||||
|
||||
* Image transforms can be seen as:
|
||||
|
||||
@ -54,18 +54,18 @@ Brightness and contrast adjustments
|
||||
* Two commonly used point processes are *multiplication* and *addition* with a constant:
|
||||
|
||||
.. math::
|
||||
|
||||
|
||||
g(x) = \alpha f(x) + \beta
|
||||
|
||||
|
||||
* The parameters :math:`\alpha > 0` and :math:`\beta` are often called the *gain* and *bias* parameters; sometimes these parameters are said to control *contrast* and *brightness* respectively.
|
||||
|
||||
* You can think of :math:`f(x)` as the source image pixels and :math:`g(x)` as the output image pixels. Then, more conveniently we can write the expression as:
|
||||
|
||||
.. math::
|
||||
|
||||
|
||||
g(i,j) = \alpha \cdot f(i,j) + \beta
|
||||
|
||||
where :math:`i` and :math:`j` indicates that the pixel is located in the *i-th* row and *j-th* column.
|
||||
|
||||
where :math:`i` and :math:`j` indicates that the pixel is located in the *i-th* row and *j-th* column.
|
||||
|
||||
Code
|
||||
=====
|
||||
@ -91,7 +91,7 @@ Code
|
||||
Mat image = imread( argv[1] );
|
||||
Mat new_image = Mat::zeros( image.size(), image.type() );
|
||||
|
||||
/// Initialize values
|
||||
/// Initialize values
|
||||
std::cout<<" Basic Linear Transforms "<<std::endl;
|
||||
std::cout<<"-------------------------"<<std::endl;
|
||||
std::cout<<"* Enter the alpha value [1.0-3.0]: ";std::cin>>alpha;
|
||||
@ -102,7 +102,7 @@ Code
|
||||
{ for( int x = 0; x < image.cols; x++ )
|
||||
{ for( int c = 0; c < 3; c++ )
|
||||
{
|
||||
new_image.at<Vec3b>(y,x)[c] =
|
||||
new_image.at<Vec3b>(y,x)[c] =
|
||||
saturate_cast<uchar>( alpha*( image.at<Vec3b>(y,x)[c] ) + beta );
|
||||
}
|
||||
}
|
||||
@ -133,41 +133,41 @@ Explanation
|
||||
|
||||
|
||||
#. We load an image using :imread:`imread <>` and save it in a Mat object:
|
||||
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
Mat image = imread( argv[1] );
|
||||
|
||||
#. Now, since we will make some transformations to this image, we need a new Mat object to store it. Also, we want this to have the following features:
|
||||
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* Initial pixel values equal to zero
|
||||
* Same size and type as the original image
|
||||
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
Mat new_image = Mat::zeros( image.size(), image.type() );
|
||||
|
||||
We observe that :mat_zeros:`Mat::zeros <>` returns a Matlab-style zero initializer based on *image.size()* and *image.type()*
|
||||
Mat new_image = Mat::zeros( image.size(), image.type() );
|
||||
|
||||
We observe that :mat_zeros:`Mat::zeros <>` returns a Matlab-style zero initializer based on *image.size()* and *image.type()*
|
||||
|
||||
#. Now, to perform the operation :math:`g(i,j) = \alpha \cdot f(i,j) + \beta` we will access to each pixel in image. Since we are operating with RGB images, we will have three values per pixel (R, G and B), so we will also access them separately. Here is the piece of code:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
|
||||
for( int y = 0; y < image.rows; y++ )
|
||||
{ for( int x = 0; x < image.cols; x++ )
|
||||
{ for( int c = 0; c < 3; c++ )
|
||||
{ new_image.at<Vec3b>(y,x)[c] =
|
||||
{ new_image.at<Vec3b>(y,x)[c] =
|
||||
saturate_cast<uchar>( alpha*( image.at<Vec3b>(y,x)[c] ) + beta ); }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Notice the following:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* To access each pixel in the images we are using this syntax: *image.at<Vec3b>(y,x)[c]* where *y* is the row, *x* is the column and *c* is R, G or B (0, 1 or 2).
|
||||
* To access each pixel in the images we are using this syntax: *image.at<Vec3b>(y,x)[c]* where *y* is the row, *x* is the column and *c* is R, G or B (0, 1 or 2).
|
||||
|
||||
* Since the operation :math:`\alpha \cdot p(i,j) + \beta` can give values out of range or not integers (if :math:`\alpha` is float), we use :saturate_cast:`saturate_cast <>` to make sure the values are valid.
|
||||
|
||||
@ -175,7 +175,7 @@ Explanation
|
||||
#. Finally, we create windows and show the images, the usual way.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
|
||||
namedWindow("Original Image", 1);
|
||||
namedWindow("New Image", 1);
|
||||
|
||||
@ -185,9 +185,9 @@ Explanation
|
||||
waitKey(0);
|
||||
|
||||
.. note::
|
||||
|
||||
|
||||
Instead of using the **for** loops to access each pixel, we could have simply used this command:
|
||||
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
image.convertTo(new_image, -1, alpha, beta);
|
||||
@ -211,4 +211,4 @@ Result
|
||||
|
||||
.. image:: images/Basic_Linear_Transform_Tutorial_Result_0.jpg
|
||||
:alt: Basic Linear Transform - Final Result
|
||||
:align: center
|
||||
:align: center
|
||||
|
@ -4,22 +4,22 @@ Discrete Fourier Transform
|
||||
**************************
|
||||
|
||||
Goal
|
||||
====
|
||||
====
|
||||
|
||||
We'll seek answers for the following questions:
|
||||
We'll seek answers for the following questions:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
+ What is a Fourier transform and why use it?
|
||||
+ How to do it in OpenCV?
|
||||
+ What is a Fourier transform and why use it?
|
||||
+ How to do it in OpenCV?
|
||||
+ Usage of functions such as: :imgprocfilter:`copyMakeBorder() <copymakeborder>`, :operationsonarrays:`merge() <merge>`, :operationsonarrays:`dft() <dft>`, :operationsonarrays:`getOptimalDFTSize() <getoptimaldftsize>`, :operationsonarrays:`log() <log>` and :operationsonarrays:`normalize() <normalize>` .
|
||||
|
||||
Source code
|
||||
===========
|
||||
|
||||
You can :download:`download this from here <../../../../samples/cpp/tutorial_code/core/discrete_fourier_transform/discrete_fourier_transform.cpp>` or find it in the :file:`samples/cpp/tutorial_code/core/discrete_fourier_transform/discrete_fourier_transform.cpp` of the OpenCV source code library.
|
||||
You can :download:`download this from here <../../../../samples/cpp/tutorial_code/core/discrete_fourier_transform/discrete_fourier_transform.cpp>` or find it in the :file:`samples/cpp/tutorial_code/core/discrete_fourier_transform/discrete_fourier_transform.cpp` of the OpenCV source code library.
|
||||
|
||||
Here's a sample usage of :operationsonarrays:`dft() <dft>` :
|
||||
Here's a sample usage of :operationsonarrays:`dft() <dft>` :
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/discrete_fourier_transform/discrete_fourier_transform.cpp
|
||||
:language: cpp
|
||||
@ -30,11 +30,11 @@ Here's a sample usage of :operationsonarrays:`dft() <dft>` :
|
||||
Explanation
|
||||
===========
|
||||
|
||||
The Fourier Transform will decompose an image into its sinus and cosines components. In other words, it will transform an image from its spatial domain to its frequency domain. The idea is that any function may be approximated exactly with the sum of infinite sinus and cosines functions. The Fourier Transform is a way how to do this. Mathematically a two dimensional images Fourier transform is:
|
||||
The Fourier Transform will decompose an image into its sinus and cosines components. In other words, it will transform an image from its spatial domain to its frequency domain. The idea is that any function may be approximated exactly with the sum of infinite sinus and cosines functions. The Fourier Transform is a way how to do this. Mathematically a two dimensional images Fourier transform is:
|
||||
|
||||
.. math::
|
||||
|
||||
F(k,l) = \displaystyle\sum\limits_{i=0}^{N-1}\sum\limits_{j=0}^{N-1} f(i,j)e^{-i2\pi(\frac{ki}{N}+\frac{lj}{N})}
|
||||
F(k,l) = \displaystyle\sum\limits_{i=0}^{N-1}\sum\limits_{j=0}^{N-1} f(i,j)e^{-i2\pi(\frac{ki}{N}+\frac{lj}{N})}
|
||||
|
||||
e^{ix} = \cos{x} + i\sin {x}
|
||||
|
||||
@ -44,65 +44,65 @@ In this sample I'll show how to calculate and show the *magnitude* image of a Fo
|
||||
|
||||
1. **Expand the image to an optimal size**. The performance of a DFT is dependent of the image size. It tends to be the fastest for image sizes that are multiple of the numbers two, three and five. Therefore, to achieve maximal performance it is generally a good idea to pad border values to the image to get a size with such traits. The :operationsonarrays:`getOptimalDFTSize() <getoptimaldftsize>` returns this optimal size and we can use the :imgprocfilter:`copyMakeBorder() <copymakeborder>` function to expand the borders of an image:
|
||||
|
||||
.. code-block:: cpp
|
||||
.. code-block:: cpp
|
||||
|
||||
Mat padded; //expand input image to optimal size
|
||||
int m = getOptimalDFTSize( I.rows );
|
||||
int n = getOptimalDFTSize( I.cols ); // on the border add zero pixels
|
||||
copyMakeBorder(I, padded, 0, m - I.rows, 0, n - I.cols, BORDER_CONSTANT, Scalar::all(0));
|
||||
|
||||
The appended pixels are initialized with zero.
|
||||
The appended pixels are initialized with zero.
|
||||
|
||||
2. **Make place for both the complex and the real values**. The result of a Fourier Transform is complex. This implies that for each image value the result is two image values (one per component). Moreover, the frequency domains range is much larger than its spatial counterpart. Therefore, we store these usually at least in a *float* format. Therefore we'll convert our input image to this type and expand it with another channel to hold the complex values:
|
||||
|
||||
.. code-block:: cpp
|
||||
.. code-block:: cpp
|
||||
|
||||
Mat planes[] = {Mat_<float>(padded), Mat::zeros(padded.size(), CV_32F)};
|
||||
Mat complexI;
|
||||
merge(planes, 2, complexI); // Add to the expanded another plane with zeros
|
||||
|
||||
3. **Make the Discrete Fourier Transform**. It's possible an in-place calculation (same input as output):
|
||||
3. **Make the Discrete Fourier Transform**. It's possible an in-place calculation (same input as output):
|
||||
|
||||
.. code-block:: cpp
|
||||
.. code-block:: cpp
|
||||
|
||||
dft(complexI, complexI); // this way the result may fit in the source matrix
|
||||
|
||||
4. **Transform the real and complex values to magnitude**. A complex number has a real (*Re*) and a complex (imaginary - *Im*) part. The results of a DFT are complex numbers. The magnitude of a DFT is:
|
||||
4. **Transform the real and complex values to magnitude**. A complex number has a real (*Re*) and a complex (imaginary - *Im*) part. The results of a DFT are complex numbers. The magnitude of a DFT is:
|
||||
|
||||
.. math::
|
||||
|
||||
M = \sqrt[2]{ {Re(DFT(I))}^2 + {Im(DFT(I))}^2}
|
||||
|
||||
Translated to OpenCV code:
|
||||
Translated to OpenCV code:
|
||||
|
||||
.. code-block:: cpp
|
||||
.. code-block:: cpp
|
||||
|
||||
split(complexI, planes); // planes[0] = Re(DFT(I), planes[1] = Im(DFT(I))
|
||||
magnitude(planes[0], planes[1], planes[0]);// planes[0] = magnitude
|
||||
magnitude(planes[0], planes[1], planes[0]);// planes[0] = magnitude
|
||||
Mat magI = planes[0];
|
||||
|
||||
5. **Switch to a logarithmic scale**. It turns out that the dynamic range of the Fourier coefficients is too large to be displayed on the screen. We have some small and some high changing values that we can't observe like this. Therefore the high values will all turn out as white points, while the small ones as black. To use the gray scale values to for visualization we can transform our linear scale to a logarithmic one:
|
||||
5. **Switch to a logarithmic scale**. It turns out that the dynamic range of the Fourier coefficients is too large to be displayed on the screen. We have some small and some high changing values that we can't observe like this. Therefore the high values will all turn out as white points, while the small ones as black. To use the gray scale values to for visualization we can transform our linear scale to a logarithmic one:
|
||||
|
||||
.. math::
|
||||
|
||||
M_1 = \log{(1 + M)}
|
||||
|
||||
Translated to OpenCV code:
|
||||
Translated to OpenCV code:
|
||||
|
||||
.. code-block:: cpp
|
||||
.. code-block:: cpp
|
||||
|
||||
magI += Scalar::all(1); // switch to logarithmic scale
|
||||
log(magI, magI);
|
||||
|
||||
6. **Crop and rearrange**. Remember, that at the first step, we expanded the image? Well, it's time to throw away the newly introduced values. For visualization purposes we may also rearrange the quadrants of the result, so that the origin (zero, zero) corresponds with the image center.
|
||||
6. **Crop and rearrange**. Remember, that at the first step, we expanded the image? Well, it's time to throw away the newly introduced values. For visualization purposes we may also rearrange the quadrants of the result, so that the origin (zero, zero) corresponds with the image center.
|
||||
|
||||
.. code-block:: cpp
|
||||
.. code-block:: cpp
|
||||
|
||||
magI = magI(Rect(0, 0, magI.cols & -2, magI.rows & -2));
|
||||
int cx = magI.cols/2;
|
||||
int cy = magI.rows/2;
|
||||
|
||||
Mat q0(magI, Rect(0, 0, cx, cy)); // Top-Left - Create a ROI per quadrant
|
||||
Mat q0(magI, Rect(0, 0, cx, cy)); // Top-Left - Create a ROI per quadrant
|
||||
Mat q1(magI, Rect(cx, 0, cx, cy)); // Top-Right
|
||||
Mat q2(magI, Rect(0, cy, cx, cy)); // Bottom-Left
|
||||
Mat q3(magI, Rect(cx, cy, cx, cy)); // Bottom-Right
|
||||
@ -116,25 +116,25 @@ In this sample I'll show how to calculate and show the *magnitude* image of a Fo
|
||||
q2.copyTo(q1);
|
||||
tmp.copyTo(q2);
|
||||
|
||||
7. **Normalize**. This is done again for visualization purposes. We now have the magnitudes, however this are still out of our image display range of zero to one. We normalize our values to this range using the :operationsonarrays:`normalize() <normalize>` function.
|
||||
7. **Normalize**. This is done again for visualization purposes. We now have the magnitudes, however this are still out of our image display range of zero to one. We normalize our values to this range using the :operationsonarrays:`normalize() <normalize>` function.
|
||||
|
||||
.. code-block:: cpp
|
||||
.. code-block:: cpp
|
||||
|
||||
normalize(magI, magI, 0, 1, CV_MINMAX); // Transform the matrix with float values into a
|
||||
normalize(magI, magI, 0, 1, CV_MINMAX); // Transform the matrix with float values into a
|
||||
// viewable image form (float between values 0 and 1).
|
||||
|
||||
Result
|
||||
======
|
||||
|
||||
An application idea would be to determine the geometrical orientation present in the image. For example, let us find out if a text is horizontal or not? Looking at some text you'll notice that the text lines sort of form also horizontal lines and the letters form sort of vertical lines. These two main components of a text snippet may be also seen in case of the Fourier transform. Let us use :download:`this horizontal <../../../../samples/cpp/tutorial_code/images/imageTextN.png>` and :download:`this rotated<../../../../samples/cpp/tutorial_code/images/imageTextR.png>` image about a text.
|
||||
An application idea would be to determine the geometrical orientation present in the image. For example, let us find out if a text is horizontal or not? Looking at some text you'll notice that the text lines sort of form also horizontal lines and the letters form sort of vertical lines. These two main components of a text snippet may be also seen in case of the Fourier transform. Let us use :download:`this horizontal <../../../../samples/cpp/tutorial_code/images/imageTextN.png>` and :download:`this rotated<../../../../samples/cpp/tutorial_code/images/imageTextR.png>` image about a text.
|
||||
|
||||
In case of the horizontal text:
|
||||
In case of the horizontal text:
|
||||
|
||||
.. image:: images/result_normal.jpg
|
||||
:alt: In case of normal text
|
||||
:align: center
|
||||
|
||||
In case of a rotated text:
|
||||
In case of a rotated text:
|
||||
|
||||
.. image:: images/result_rotated.jpg
|
||||
:alt: In case of rotated text
|
||||
|
@ -4,9 +4,9 @@ File Input and Output using XML and YAML files
|
||||
**********************************************
|
||||
|
||||
Goal
|
||||
====
|
||||
====
|
||||
|
||||
You'll find answers for the following questions:
|
||||
You'll find answers for the following questions:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
@ -18,7 +18,7 @@ You'll find answers for the following questions:
|
||||
Source code
|
||||
===========
|
||||
|
||||
You can :download:`download this from here <../../../../samples/cpp/tutorial_code/core/file_input_output/file_input_output.cpp>` or find it in the :file:`samples/cpp/tutorial_code/core/file_input_output/file_input_output.cpp` of the OpenCV source code library.
|
||||
You can :download:`download this from here <../../../../samples/cpp/tutorial_code/core/file_input_output/file_input_output.cpp>` or find it in the :file:`samples/cpp/tutorial_code/core/file_input_output/file_input_output.cpp` of the OpenCV source code library.
|
||||
|
||||
Here's a sample code of how to achieve all the stuff enumerated at the goal list.
|
||||
|
||||
@ -31,9 +31,9 @@ Here's a sample code of how to achieve all the stuff enumerated at the goal list
|
||||
Explanation
|
||||
===========
|
||||
|
||||
Here we talk only about XML and YAML file inputs. Your output (and its respective input) file may have only one of these extensions and the structure coming from this. They are two kinds of data structures you may serialize: *mappings* (like the STL map) and *element sequence* (like the STL vector>. The difference between these is that in a map every element has a unique name through what you may access it. For sequences you need to go through them to query a specific item.
|
||||
Here we talk only about XML and YAML file inputs. Your output (and its respective input) file may have only one of these extensions and the structure coming from this. They are two kinds of data structures you may serialize: *mappings* (like the STL map) and *element sequence* (like the STL vector>. The difference between these is that in a map every element has a unique name through what you may access it. For sequences you need to go through them to query a specific item.
|
||||
|
||||
1. **XML\\YAML File Open and Close.** Before you write any content to such file you need to open it and at the end to close it. The XML\YAML data structure in OpenCV is :xmlymlpers:`FileStorage <filestorage>`. To specify that this structure to which file binds on your hard drive you can use either its constructor or the *open()* function of this:
|
||||
1. **XML\\YAML File Open and Close.** Before you write any content to such file you need to open it and at the end to close it. The XML\YAML data structure in OpenCV is :xmlymlpers:`FileStorage <filestorage>`. To specify that this structure to which file binds on your hard drive you can use either its constructor or the *open()* function of this:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -42,29 +42,29 @@ Here we talk only about XML and YAML file inputs. Your output (and its respectiv
|
||||
\\...
|
||||
fs.open(filename, FileStorage::READ);
|
||||
|
||||
Either one of this you use the second argument is a constant specifying the type of operations you'll be able to on them: WRITE, READ or APPEND. The extension specified in the file name also determinates the output format that will be used. The output may be even compressed if you specify an extension such as *.xml.gz*.
|
||||
Either one of this you use the second argument is a constant specifying the type of operations you'll be able to on them: WRITE, READ or APPEND. The extension specified in the file name also determinates the output format that will be used. The output may be even compressed if you specify an extension such as *.xml.gz*.
|
||||
|
||||
The file automatically closes when the :xmlymlpers:`FileStorage <filestorage>` objects is destroyed. However, you may explicitly call for this by using the *release* function:
|
||||
|
||||
The file automatically closes when the :xmlymlpers:`FileStorage <filestorage>` objects is destroyed. However, you may explicitly call for this by using the *release* function:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
fs.release(); // explicit close
|
||||
|
||||
#. **Input and Output of text and numbers.** The data structure uses the same << output operator that the STL library. For outputting any type of data structure we need first to specify its name. We do this by just simply printing out the name of this. For basic types you may follow this with the print of the value :
|
||||
#. **Input and Output of text and numbers.** The data structure uses the same << output operator that the STL library. For outputting any type of data structure we need first to specify its name. We do this by just simply printing out the name of this. For basic types you may follow this with the print of the value :
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
fs << "iterationNr" << 100;
|
||||
|
||||
Reading in is a simple addressing (via the [] operator) and casting operation or a read via the >> operator :
|
||||
Reading in is a simple addressing (via the [] operator) and casting operation or a read via the >> operator :
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
int itNr;
|
||||
int itNr;
|
||||
fs["iterationNr"] >> itNr;
|
||||
itNr = (int) fs["iterationNr"];
|
||||
|
||||
#. **Input\\Output of OpenCV Data structures.** Well these behave exactly just as the basic C++ types:
|
||||
#. **Input\\Output of OpenCV Data structures.** Well these behave exactly just as the basic C++ types:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -77,7 +77,7 @@ Here we talk only about XML and YAML file inputs. Your output (and its respectiv
|
||||
fs["R"] >> R; // Read cv::Mat
|
||||
fs["T"] >> T;
|
||||
|
||||
#. **Input\\Output of vectors (arrays) and associative maps.** As I mentioned beforehand we can output maps and sequences (array, vector) too. Again we first print the name of the variable and then we have to specify if our output is either a sequence or map.
|
||||
#. **Input\\Output of vectors (arrays) and associative maps.** As I mentioned beforehand we can output maps and sequences (array, vector) too. Again we first print the name of the variable and then we have to specify if our output is either a sequence or map.
|
||||
|
||||
For sequence before the first element print the "[" character and after the last one the "]" character:
|
||||
|
||||
@ -95,7 +95,7 @@ Here we talk only about XML and YAML file inputs. Your output (and its respectiv
|
||||
fs << "{" << "One" << 1;
|
||||
fs << "Two" << 2 << "}";
|
||||
|
||||
To read from these we use the :xmlymlpers:`FileNode <filenode>` and the :xmlymlpers:`FileNodeIterator <filenodeiterator>` data structures. The [] operator of the :xmlymlpers:`FileStorage <filestorage>` class returns a :xmlymlpers:`FileNode <filenode>` data type. If the node is sequential we can use the :xmlymlpers:`FileNodeIterator <filenodeiterator>` to iterate through the items:
|
||||
To read from these we use the :xmlymlpers:`FileNode <filenode>` and the :xmlymlpers:`FileNodeIterator <filenodeiterator>` data structures. The [] operator of the :xmlymlpers:`FileStorage <filestorage>` class returns a :xmlymlpers:`FileNode <filenode>` data type. If the node is sequential we can use the :xmlymlpers:`FileNodeIterator <filenodeiterator>` to iterate through the items:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -115,8 +115,8 @@ Here we talk only about XML and YAML file inputs. Your output (and its respectiv
|
||||
.. code-block:: cpp
|
||||
|
||||
n = fs["Mapping"]; // Read mappings from a sequence
|
||||
cout << "Two " << (int)(n["Two"]) << "; ";
|
||||
cout << "One " << (int)(n["One"]) << endl << endl;
|
||||
cout << "Two " << (int)(n["Two"]) << "; ";
|
||||
cout << "One " << (int)(n["One"]) << endl << endl;
|
||||
|
||||
#. **Read and write your own data structures.** Suppose you have a data structure such as:
|
||||
|
||||
@ -148,7 +148,7 @@ Here we talk only about XML and YAML file inputs. Your output (and its respectiv
|
||||
id = (string)node["id"];
|
||||
}
|
||||
|
||||
Then you need to add the following functions definitions outside the class:
|
||||
Then you need to add the following functions definitions outside the class:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -175,17 +175,17 @@ Here we talk only about XML and YAML file inputs. Your output (and its respectiv
|
||||
fs << "MyData" << m; // your own data structures
|
||||
fs["MyData"] >> m; // Read your own structure_
|
||||
|
||||
Or to try out reading a non-existing read:
|
||||
Or to try out reading a non-existing read:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
fs["NonExisting"] >> m; // Do not add a fs << "NonExisting" << m command for this to work
|
||||
fs["NonExisting"] >> m; // Do not add a fs << "NonExisting" << m command for this to work
|
||||
cout << endl << "NonExisting = " << endl << m << endl;
|
||||
|
||||
Result
|
||||
======
|
||||
|
||||
Well mostly we just print out the defined numbers. On the screen of your console you could see:
|
||||
Well mostly we just print out the defined numbers. On the screen of your console you could see:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
@ -212,7 +212,7 @@ Well mostly we just print out the defined numbers. On the screen of your console
|
||||
|
||||
Tip: Open up output.xml with a text editor to see the serialized data.
|
||||
|
||||
Nevertheless, it's much more interesting what you may see in the output xml file:
|
||||
Nevertheless, it's much more interesting what you may see in the output xml file:
|
||||
|
||||
.. code-block:: xml
|
||||
|
||||
@ -242,7 +242,7 @@ Nevertheless, it's much more interesting what you may see in the output xml file
|
||||
<id>mydata1234</id></MyData>
|
||||
</opencv_storage>
|
||||
|
||||
Or the YAML file:
|
||||
Or the YAML file:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
@ -277,4 +277,3 @@ You may observe a runtime instance of this on the `YouTube here <https://www.you
|
||||
<div align="center">
|
||||
<iframe title="File Input and Output using XML and YAML files in OpenCV" width="560" height="349" src="http://www.youtube.com/embed/A4yqVnByMMM?rel=0&loop=1" frameborder="0" allowfullscreen align="middle"></iframe>
|
||||
</div>
|
||||
|
||||
|
@ -4,9 +4,9 @@ How to scan images, lookup tables and time measurement with OpenCV
|
||||
*******************************************************************
|
||||
|
||||
Goal
|
||||
====
|
||||
====
|
||||
|
||||
We'll seek answers for the following questions:
|
||||
We'll seek answers for the following questions:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
@ -18,11 +18,11 @@ We'll seek answers for the following questions:
|
||||
Our test case
|
||||
=============
|
||||
|
||||
Let us consider a simple color reduction method. Using the unsigned char C and C++ type for matrix item storing a channel of pixel may have up to 256 different values. For a three channel image this can allow the formation of way too many colors (16 million to be exact). Working with so many color shades may give a heavy blow to our algorithm performance. However, sometimes it is enough to work with a lot less of them to get the same final result.
|
||||
Let us consider a simple color reduction method. Using the unsigned char C and C++ type for matrix item storing a channel of pixel may have up to 256 different values. For a three channel image this can allow the formation of way too many colors (16 million to be exact). Working with so many color shades may give a heavy blow to our algorithm performance. However, sometimes it is enough to work with a lot less of them to get the same final result.
|
||||
|
||||
In this cases it's common that we make a *color space reduction*. This means that we divide the color space current value with a new input value to end up with fewer colors. For instance every value between zero and nine takes the new value zero, every value between ten and nineteen the value ten and so on.
|
||||
In this cases it's common that we make a *color space reduction*. This means that we divide the color space current value with a new input value to end up with fewer colors. For instance every value between zero and nine takes the new value zero, every value between ten and nineteen the value ten and so on.
|
||||
|
||||
When you divide an *uchar* (unsigned char - aka values between zero and 255) value with an *int* value the result will be also *char*. These values may only be char values. Therefore, any fraction will be rounded down. Taking advantage of this fact the upper operation in the *uchar* domain may be expressed as:
|
||||
When you divide an *uchar* (unsigned char - aka values between zero and 255) value with an *int* value the result will be also *char*. These values may only be char values. Therefore, any fraction will be rounded down. Taking advantage of this fact the upper operation in the *uchar* domain may be expressed as:
|
||||
|
||||
.. math::
|
||||
|
||||
@ -30,11 +30,11 @@ When you divide an *uchar* (unsigned char - aka values between zero and 255) val
|
||||
|
||||
A simple color space reduction algorithm would consist of just passing through every pixel of an image matrix and applying this formula. It's worth noting that we do a divide and a multiplication operation. These operations are bloody expensive for a system. If possible it's worth avoiding them by using cheaper operations such as a few subtractions, addition or in best case a simple assignment. Furthermore, note that we only have a limited number of input values for the upper operation. In case of the *uchar* system this is 256 to be exact.
|
||||
|
||||
Therefore, for larger images it would be wise to calculate all possible values beforehand and during the assignment just make the assignment, by using a lookup table. Lookup tables are simple arrays (having one or more dimensions) that for a given input value variation holds the final output value. Its strength lies that we do not need to make the calculation, we just need to read the result.
|
||||
Therefore, for larger images it would be wise to calculate all possible values beforehand and during the assignment just make the assignment, by using a lookup table. Lookup tables are simple arrays (having one or more dimensions) that for a given input value variation holds the final output value. Its strength lies that we do not need to make the calculation, we just need to read the result.
|
||||
|
||||
Our test case program (and the sample presented here) will do the following: read in a console line argument image (that may be either color or gray scale - console line argument too) and apply the reduction with the given console line argument integer value. In OpenCV, at the moment they are three major ways of going through an image pixel by pixel. To make things a little more interesting will make the scanning for each image using all of these methods, and print out how long it took.
|
||||
Our test case program (and the sample presented here) will do the following: read in a console line argument image (that may be either color or gray scale - console line argument too) and apply the reduction with the given console line argument integer value. In OpenCV, at the moment they are three major ways of going through an image pixel by pixel. To make things a little more interesting will make the scanning for each image using all of these methods, and print out how long it took.
|
||||
|
||||
You can download the full source code :download:`here <../../../../samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp>` or look it up in the samples directory of OpenCV at the cpp tutorial code for the core section. Its basic usage is:
|
||||
You can download the full source code :download:`here <../../../../samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp>` or look it up in the samples directory of OpenCV at the cpp tutorial code for the core section. Its basic usage is:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
@ -45,25 +45,25 @@ The final argument is optional. If given the image will be loaded in gray scale
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp
|
||||
:language: cpp
|
||||
:tab-width: 4
|
||||
:lines: 48-60
|
||||
:lines: 48-60
|
||||
|
||||
Here we first use the C++ *stringstream* class to convert the third command line argument from text to an integer format. Then we use a simple look and the upper formula to calculate the lookup table. No OpenCV specific stuff here.
|
||||
|
||||
Another issue is how do we measure time? Well OpenCV offers two simple functions to achieve this :UtilitySystemFunctions:`getTickCount() <gettickcount>` and :UtilitySystemFunctions:`getTickFrequency() <gettickfrequency>`. The first returns the number of ticks of your systems CPU from a certain event (like since you booted your system). The second returns how many times your CPU emits a tick during a second. So to measure in seconds the number of time elapsed between two operations is easy as:
|
||||
Another issue is how do we measure time? Well OpenCV offers two simple functions to achieve this :UtilitySystemFunctions:`getTickCount() <gettickcount>` and :UtilitySystemFunctions:`getTickFrequency() <gettickfrequency>`. The first returns the number of ticks of your systems CPU from a certain event (like since you booted your system). The second returns how many times your CPU emits a tick during a second. So to measure in seconds the number of time elapsed between two operations is easy as:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
double t = (double)getTickCount();
|
||||
// do something ...
|
||||
t = ((double)getTickCount() - t)/getTickFrequency();
|
||||
t = ((double)getTickCount() - t)/getTickFrequency();
|
||||
cout << "Times passed in seconds: " << t << endl;
|
||||
|
||||
.. _How_Image_Stored_Memory:
|
||||
.. _How_Image_Stored_Memory:
|
||||
|
||||
How the image matrix is stored in the memory?
|
||||
=============================================
|
||||
|
||||
As you could already read in my :ref:`matTheBasicImageContainer` tutorial the size of the matrix depends of the color system used. More accurately, it depends from the number of channels used. In case of a gray scale image we have something like:
|
||||
As you could already read in my :ref:`matTheBasicImageContainer` tutorial the size of the matrix depends of the color system used. More accurately, it depends from the number of channels used. In case of a gray scale image we have something like:
|
||||
|
||||
.. math::
|
||||
|
||||
@ -94,14 +94,14 @@ Note that the order of the channels is inverse: BGR instead of RGB. Because in m
|
||||
The efficient way
|
||||
=================
|
||||
|
||||
When it comes to performance you cannot beat the classic C style operator[] (pointer) access. Therefore, the most efficient method we can recommend for making the assignment is:
|
||||
When it comes to performance you cannot beat the classic C style operator[] (pointer) access. Therefore, the most efficient method we can recommend for making the assignment is:
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp
|
||||
:language: cpp
|
||||
:tab-width: 4
|
||||
:lines: 125-152
|
||||
|
||||
Here we basically just acquire a pointer to the start of each row and go through it until it ends. In the special case that the matrix is stored in a continues manner we only need to request the pointer a single time and go all the way to the end. We need to look out for color images: we have three channels so we need to pass through three times more items in each row.
|
||||
Here we basically just acquire a pointer to the start of each row and go through it until it ends. In the special case that the matrix is stored in a continues manner we only need to request the pointer a single time and go all the way to the end. We need to look out for color images: we have three channels so we need to pass through three times more items in each row.
|
||||
|
||||
There's another way of this. The *data* data member of a *Mat* object returns the pointer to the first row, first column. If this pointer is null you have no valid input in that object. Checking this is the simplest method to check if your image loading was a success. In case the storage is continues we can use this to go through the whole data pointer. In case of a gray scale image this would look like:
|
||||
|
||||
@ -114,17 +114,17 @@ There's another way of this. The *data* data member of a *Mat* object returns th
|
||||
|
||||
You would get the same result. However, this code is a lot harder to read later on. It gets even harder if you have some more advanced technique there. Moreover, in practice I've observed you'll get the same performance result (as most of the modern compilers will probably make this small optimization trick automatically for you).
|
||||
|
||||
The iterator (safe) method
|
||||
The iterator (safe) method
|
||||
==========================
|
||||
|
||||
In case of the efficient way making sure that you pass through the right amount of *uchar* fields and to skip the gaps that may occur between the rows was your responsibility. The iterator method is considered a safer way as it takes over these tasks from the user. All you need to do is ask the begin and the end of the image matrix and then just increase the begin iterator until you reach the end. To acquire the value *pointed* by the iterator use the * operator (add it before it).
|
||||
In case of the efficient way making sure that you pass through the right amount of *uchar* fields and to skip the gaps that may occur between the rows was your responsibility. The iterator method is considered a safer way as it takes over these tasks from the user. All you need to do is ask the begin and the end of the image matrix and then just increase the begin iterator until you reach the end. To acquire the value *pointed* by the iterator use the * operator (add it before it).
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp
|
||||
:language: cpp
|
||||
:tab-width: 4
|
||||
:lines: 154-182
|
||||
|
||||
In case of color images we have three uchar items per column. This may be considered a short vector of uchar items, that has been baptized in OpenCV with the *Vec3b* name. To access the n-th sub column we use simple operator[] access. It's important to remember that OpenCV iterators go through the columns and automatically skip to the next row. Therefore in case of color images if you use a simple *uchar* iterator you'll be able to access only the blue channel values.
|
||||
In case of color images we have three uchar items per column. This may be considered a short vector of uchar items, that has been baptized in OpenCV with the *Vec3b* name. To access the n-th sub column we use simple operator[] access. It's important to remember that OpenCV iterators go through the columns and automatically skip to the next row. Therefore in case of color images if you use a simple *uchar* iterator you'll be able to access only the blue channel values.
|
||||
|
||||
On-the-fly address calculation with reference returning
|
||||
=======================================================
|
||||
@ -136,7 +136,7 @@ The final method isn't recommended for scanning. It was made to acquire or modif
|
||||
:tab-width: 4
|
||||
:lines: 184-216
|
||||
|
||||
The functions takes your input type and coordinates and calculates on the fly the address of the queried item. Then returns a reference to that. This may be a constant when you *get* the value and non-constant when you *set* the value. As a safety step in **debug mode only*** there is performed a check that your input coordinates are valid and does exist. If this isn't the case you'll get a nice output message of this on the standard error output stream. Compared to the efficient way in release mode the only difference in using this is that for every element of the image you'll get a new row pointer for what we use the C operator[] to acquire the column element.
|
||||
The functions takes your input type and coordinates and calculates on the fly the address of the queried item. Then returns a reference to that. This may be a constant when you *get* the value and non-constant when you *set* the value. As a safety step in **debug mode only*** there is performed a check that your input coordinates are valid and does exist. If this isn't the case you'll get a nice output message of this on the standard error output stream. Compared to the efficient way in release mode the only difference in using this is that for every element of the image you'll get a new row pointer for what we use the C operator[] to acquire the column element.
|
||||
|
||||
If you need to multiple lookups using this method for an image it may be troublesome and time consuming to enter the type and the at keyword for each of the accesses. To solve this problem OpenCV has a :basicstructures:`Mat_ <id3>` data type. It's the same as Mat with the extra need that at definition you need to specify the data type through what to look at the data matrix, however in return you can use the operator() for fast access of items. To make things even better this is easily convertible from and to the usual :basicstructures:`Mat <id3>` data type. A sample usage of this you can see in case of the color images of the upper function. Nevertheless, it's important to note that the same operation (with the same runtime speed) could have been done with the :basicstructures:`at() <mat-at>` function. It's just a less to write for the lazy programmer trick.
|
||||
|
||||
|
@ -6,7 +6,7 @@ Interoperability with OpenCV 1
|
||||
Goal
|
||||
====
|
||||
|
||||
For the OpenCV developer team it's important to constantly improve the library. We are constantly thinking about methods that will ease your work process, while still maintain the libraries flexibility. The new C++ interface is a development of us that serves this goal. Nevertheless, backward compatibility remains important. We do not want to break your code written for earlier version of the OpenCV library. Therefore, we made sure that we add some functions that deal with this. In the following you'll learn:
|
||||
For the OpenCV developer team it's important to constantly improve the library. We are constantly thinking about methods that will ease your work process, while still maintain the libraries flexibility. The new C++ interface is a development of us that serves this goal. Nevertheless, backward compatibility remains important. We do not want to break your code written for earlier version of the OpenCV library. Therefore, we made sure that we add some functions that deal with this. In the following you'll learn:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
@ -17,9 +17,9 @@ For the OpenCV developer team it's important to constantly improve the library.
|
||||
General
|
||||
=======
|
||||
|
||||
When making the switch you first need to learn some about the new data structure for images: :ref:`matTheBasicImageContainer`, this replaces the old *CvMat* and *IplImage* ones. Switching to the new functions is easier. You just need to remember a couple of new things.
|
||||
When making the switch you first need to learn some about the new data structure for images: :ref:`matTheBasicImageContainer`, this replaces the old *CvMat* and *IplImage* ones. Switching to the new functions is easier. You just need to remember a couple of new things.
|
||||
|
||||
OpenCV 2 received reorganization. No longer are all the functions crammed into a single library. We have many modules, each of them containing data structures and functions relevant to certain tasks. This way you do not need to ship a large library if you use just a subset of OpenCV. This means that you should also include only those headers you will use. For example:
|
||||
OpenCV 2 received reorganization. No longer are all the functions crammed into a single library. We have many modules, each of them containing data structures and functions relevant to certain tasks. This way you do not need to ship a large library if you use just a subset of OpenCV. This means that you should also include only those headers you will use. For example:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -28,13 +28,13 @@ OpenCV 2 received reorganization. No longer are all the functions crammed into a
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
|
||||
|
||||
All the OpenCV related stuff is put into the *cv* namespace to avoid name conflicts with other libraries data structures and functions. Therefore, either you need to prepend the *cv::* keyword before everything that comes from OpenCV or after the includes, you just add a directive to use this:
|
||||
All the OpenCV related stuff is put into the *cv* namespace to avoid name conflicts with other libraries data structures and functions. Therefore, either you need to prepend the *cv::* keyword before everything that comes from OpenCV or after the includes, you just add a directive to use this:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
using namespace cv; // The new C++ interface API is inside this namespace. Import it.
|
||||
|
||||
Because the functions are already in a namespace there is no need for them to contain the *cv* prefix in their name. As such all the new C++ compatible functions don't have this and they follow the camel case naming rule. This means the first letter is small (unless it's a name, like Canny) and the subsequent words start with a capital letter (like *copyMakeBorder*).
|
||||
Because the functions are already in a namespace there is no need for them to contain the *cv* prefix in their name. As such all the new C++ compatible functions don't have this and they follow the camel case naming rule. This means the first letter is small (unless it's a name, like Canny) and the subsequent words start with a capital letter (like *copyMakeBorder*).
|
||||
|
||||
Now, remember that you need to link to your application all the modules you use, and in case you are on Windows using the *DLL* system you will need to add, again, to the path all the binaries. For more in-depth information if you're on Windows read :ref:`Windows_Visual_Studio_How_To` and for Linux an example usage is explained in :ref:`Linux_Eclipse_Usage`.
|
||||
|
||||
@ -42,7 +42,7 @@ Now for converting the *Mat* object you can use either the *IplImage* or the *Cv
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
Mat I;
|
||||
Mat I;
|
||||
IplImage pI = I;
|
||||
CvMat mI = I;
|
||||
|
||||
@ -50,9 +50,9 @@ Now if you want pointers the conversion gets just a little more complicated. The
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
Mat I;
|
||||
IplImage* pI = &I.operator IplImage();
|
||||
CvMat* mI = &I.operator CvMat();
|
||||
Mat I;
|
||||
IplImage* pI = &I.operator IplImage();
|
||||
CvMat* mI = &I.operator CvMat();
|
||||
|
||||
One of the biggest complaints of the C interface is that it leaves all the memory management to you. You need to figure out when it is safe to release your unused objects and make sure you do so before the program finishes or you could have troublesome memory leeks. To work around this issue in OpenCV there is introduced a sort of smart pointer. This will automatically release the object when it's no longer in use. To use this declare the pointers as a specialization of the *Ptr* :
|
||||
|
||||
@ -60,11 +60,11 @@ One of the biggest complaints of the C interface is that it leaves all the memor
|
||||
|
||||
Ptr<IplImage> piI = &I.operator IplImage();
|
||||
|
||||
Converting from the C data structures to the *Mat* is done by passing these inside its constructor. For example:
|
||||
Converting from the C data structures to the *Mat* is done by passing these inside its constructor. For example:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
Mat K(piL), L;
|
||||
Mat K(piL), L;
|
||||
L = Mat(pI);
|
||||
|
||||
A case study
|
||||
@ -79,7 +79,7 @@ Now that you have the basics done :download:`here's <../../../../samples/cpp/tut
|
||||
:tab-width: 4
|
||||
:lines: 1-9, 22-25, 27-44
|
||||
|
||||
Here you can observe that with the new structure we have no pointer problems, although it is possible to use the old functions and in the end just transform the result to a *Mat* object.
|
||||
Here you can observe that with the new structure we have no pointer problems, although it is possible to use the old functions and in the end just transform the result to a *Mat* object.
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp
|
||||
:language: cpp
|
||||
@ -87,7 +87,7 @@ Here you can observe that with the new structure we have no pointer problems, al
|
||||
:tab-width: 4
|
||||
:lines: 46-51
|
||||
|
||||
Because, we want to mess around with the images luma component we first convert from the default RGB to the YUV color space and then split the result up into separate planes. Here the program splits: in the first example it processes each plane using one of the three major image scanning algorithms in OpenCV (C [] operator, iterator, individual element access). In a second variant we add to the image some Gaussian noise and then mix together the channels according to some formula.
|
||||
Because, we want to mess around with the images luma component we first convert from the default RGB to the YUV color space and then split the result up into separate planes. Here the program splits: in the first example it processes each plane using one of the three major image scanning algorithms in OpenCV (C [] operator, iterator, individual element access). In a second variant we add to the image some Gaussian noise and then mix together the channels according to some formula.
|
||||
|
||||
The scanning version looks like:
|
||||
|
||||
@ -97,7 +97,7 @@ The scanning version looks like:
|
||||
:tab-width: 4
|
||||
:lines: 55-75
|
||||
|
||||
Here you can observe that we may go through all the pixels of an image in three fashions: an iterator, a C pointer and an individual element access style. You can read a more in-depth description of these in the :ref:`howToScanImagesOpenCV` tutorial. Converting from the old function names is easy. Just remove the cv prefix and use the new *Mat* data structure. Here's an example of this by using the weighted addition function:
|
||||
Here you can observe that we may go through all the pixels of an image in three fashions: an iterator, a C pointer and an individual element access style. You can read a more in-depth description of these in the :ref:`howToScanImagesOpenCV` tutorial. Converting from the old function names is easy. Just remove the cv prefix and use the new *Mat* data structure. Here's an example of this by using the weighted addition function:
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp
|
||||
:language: cpp
|
||||
@ -105,7 +105,7 @@ Here you can observe that we may go through all the pixels of an image in three
|
||||
:tab-width: 4
|
||||
:lines: 79-112
|
||||
|
||||
As you may observe the *planes* variable is of type *Mat*. However, converting from *Mat* to *IplImage* is easy and made automatically with a simple assignment operator.
|
||||
As you may observe the *planes* variable is of type *Mat*. However, converting from *Mat* to *IplImage* is easy and made automatically with a simple assignment operator.
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp
|
||||
:language: cpp
|
||||
@ -113,20 +113,17 @@ As you may observe the *planes* variable is of type *Mat*. However, converting f
|
||||
:tab-width: 4
|
||||
:lines: 115-127
|
||||
|
||||
The new *imshow* highgui function accepts both the *Mat* and *IplImage* data structures. Compile and run the program and if the first image below is your input you may get either the first or second as output:
|
||||
The new *imshow* highgui function accepts both the *Mat* and *IplImage* data structures. Compile and run the program and if the first image below is your input you may get either the first or second as output:
|
||||
|
||||
.. image:: images/outputInteropOpenCV1.jpg
|
||||
:alt: The output of the sample
|
||||
:align: center
|
||||
|
||||
|
||||
You may observe a runtime instance of this on the `YouTube here <https://www.youtube.com/watch?v=qckm-zvo31w>`_ and you can :download:`download the source code from here <../../../../samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp>` or find it in the :file:`samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp` of the OpenCV source code library.
|
||||
You may observe a runtime instance of this on the `YouTube here <https://www.youtube.com/watch?v=qckm-zvo31w>`_ and you can :download:`download the source code from here <../../../../samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp>` or find it in the :file:`samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp` of the OpenCV source code library.
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<div align="center">
|
||||
<iframe title="Interoperability with OpenCV 1" width="560" height="349" src="http://www.youtube.com/embed/qckm-zvo31w?rel=0&loop=1" frameborder="0" allowfullscreen align="middle"></iframe>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
@ -8,11 +8,11 @@ Mask operations on matrices are quite simple. The idea is that we recalculate ea
|
||||
Our test case
|
||||
=============
|
||||
|
||||
Let us consider the issue of an image contrast enhancement method. Basically we want to apply for every pixel of the image the following formula:
|
||||
Let us consider the issue of an image contrast enhancement method. Basically we want to apply for every pixel of the image the following formula:
|
||||
|
||||
.. math::
|
||||
|
||||
I(i,j) = 5*I(i,j) - [ I(i-1,j) + I(i+1,j) + I(i,j-1) + I(i,j+1)]
|
||||
I(i,j) = 5*I(i,j) - [ I(i-1,j) + I(i+1,j) + I(i,j-1) + I(i,j+1)]
|
||||
|
||||
\iff I(i,j)*M, \text{where }
|
||||
M = \bordermatrix{ _i\backslash ^j & -1 & 0 & +1 \cr
|
||||
@ -23,12 +23,12 @@ Let us consider the issue of an image contrast enhancement method. Basically we
|
||||
|
||||
The first notation is by using a formula, while the second is a compacted version of the first by using a mask. You use the mask by putting the center of the mask matrix (in the upper case noted by the zero-zero index) on the pixel you want to calculate and sum up the pixel values multiplied with the overlapped matrix values. It's the same thing, however in case of large matrices the latter notation is a lot easier to look over.
|
||||
|
||||
Now let us see how we can make this happen by using the basic pixel access method or by using the :filtering:`filter2D <filter2d>` function.
|
||||
Now let us see how we can make this happen by using the basic pixel access method or by using the :filtering:`filter2D <filter2d>` function.
|
||||
|
||||
The Basic Method
|
||||
================
|
||||
|
||||
Here's a function that will do this:
|
||||
Here's a function that will do this:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -49,7 +49,7 @@ Here's a function that will do this:
|
||||
|
||||
for(int i= nChannels;i < nChannels*(myImage.cols-1); ++i)
|
||||
{
|
||||
*output++ = saturate_cast<uchar>(5*current[i]
|
||||
*output++ = saturate_cast<uchar>(5*current[i]
|
||||
-current[i-nChannels] - current[i+nChannels] - previous[i] - next[i]);
|
||||
}
|
||||
}
|
||||
@ -87,7 +87,7 @@ We'll use the plain C [] operator to access pixels. Because we need to access mu
|
||||
|
||||
for(int i= nChannels;i < nChannels*(myImage.cols-1); ++i)
|
||||
{
|
||||
*output++ = saturate_cast<uchar>(5*current[i]
|
||||
*output++ = saturate_cast<uchar>(5*current[i]
|
||||
-current[i-nChannels] - current[i+nChannels] - previous[i] - next[i]);
|
||||
}
|
||||
}
|
||||
@ -96,7 +96,7 @@ On the borders of the image the upper notation results inexistent pixel location
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
Result.row(0).setTo(Scalar(0)); // The top row
|
||||
Result.row(0).setTo(Scalar(0)); // The top row
|
||||
Result.row(Result.rows-1).setTo(Scalar(0)); // The bottom row
|
||||
Result.col(0).setTo(Scalar(0)); // The left column
|
||||
Result.col(Result.cols-1).setTo(Scalar(0)); // The right column
|
||||
@ -108,19 +108,19 @@ Applying such filters are so common in image processing that in OpenCV there exi
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
Mat kern = (Mat_<char>(3,3) << 0, -1, 0,
|
||||
Mat kern = (Mat_<char>(3,3) << 0, -1, 0,
|
||||
-1, 5, -1,
|
||||
0, -1, 0);
|
||||
|
||||
Then call the :filtering:`filter2D <filter2d>` function specifying the input, the output image and the kernell to use:
|
||||
Then call the :filtering:`filter2D <filter2d>` function specifying the input, the output image and the kernell to use:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
filter2D(I, K, I.depth(), kern );
|
||||
filter2D(I, K, I.depth(), kern );
|
||||
|
||||
The function even has a fifth optional argument to specify the center of the kernel, and a sixth one for determining what to do in the regions where the operation is undefined (borders). Using this function has the advantage that it's shorter, less verbose and because there are some optimization techniques implemented it is usually faster than the *hand-coded method*. For example in my test while the second one took only 13 milliseconds the first took around 31 milliseconds. Quite some difference.
|
||||
|
||||
For example:
|
||||
For example:
|
||||
|
||||
.. image:: images/resultMatMaskFilter2D.png
|
||||
:alt: A sample output of the program
|
||||
@ -128,7 +128,7 @@ For example:
|
||||
|
||||
You can download this source code from :download:`here <../../../../samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp>` or look in the OpenCV source code libraries sample directory at :file:`samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp`.
|
||||
|
||||
Check out an instance of running the program on our `YouTube channel <http://www.youtube.com/watch?v=7PF1tAU9se4>`_ .
|
||||
Check out an instance of running the program on our `YouTube channel <http://www.youtube.com/watch?v=7PF1tAU9se4>`_ .
|
||||
|
||||
.. raw:: html
|
||||
|
||||
|
@ -19,15 +19,15 @@ For example in the above image you can see that the mirror of the car is nothing
|
||||
|
||||
OpenCV has been around since 2001. In those days the library was built around a *C* interface and to store the image in the memory they used a C structure called *IplImage*. This is the one you'll see in most of the older tutorials and educational materials. The problem with this is that it brings to the table all the minuses of the C language. The biggest issue is the manual memory management. It builds on the assumption that the user is responsible for taking care of memory allocation and deallocation. While this is not a problem with smaller programs, once your code base grows it will be more of a struggle to handle all this rather than focusing on solving your development goal.
|
||||
|
||||
Luckily C++ came around and introduced the concept of classes making easier for the user through automatic memory management (more or less). The good news is that C++ is fully compatible with C so no compatibility issues can arise from making the change. Therefore, OpenCV 2.0 introduced a new C++ interface which offered a new way of doing things which means you do not need to fiddle with memory management, making your code concise (less to write, to achieve more). The main downside of the C++ interface is that many embedded development systems at the moment support only C. Therefore, unless you are targeting embedded platforms, there's no point to using the *old* methods (unless you're a masochist programmer and you're asking for trouble).
|
||||
Luckily C++ came around and introduced the concept of classes making easier for the user through automatic memory management (more or less). The good news is that C++ is fully compatible with C so no compatibility issues can arise from making the change. Therefore, OpenCV 2.0 introduced a new C++ interface which offered a new way of doing things which means you do not need to fiddle with memory management, making your code concise (less to write, to achieve more). The main downside of the C++ interface is that many embedded development systems at the moment support only C. Therefore, unless you are targeting embedded platforms, there's no point to using the *old* methods (unless you're a masochist programmer and you're asking for trouble).
|
||||
|
||||
The first thing you need to know about *Mat* is that you no longer need to manually allocate its memory and release it as soon as you do not need it. While doing this is still a possibility, most of the OpenCV functions will allocate its output data manually. As a nice bonus if you pass on an already existing *Mat* object, which has already allocated the required space for the matrix, this will be reused. In other words we use at all times only as much memory as we need to perform the task.
|
||||
|
||||
*Mat* is basically a class with two data parts: the matrix header (containing information such as the size of the matrix, the method used for storing, at which address is the matrix stored, and so on) and a pointer to the matrix containing the pixel values (taking any dimensionality depending on the method chosen for storing) . The matrix header size is constant, however the size of the matrix itself may vary from image to image and usually is larger by orders of magnitude.
|
||||
*Mat* is basically a class with two data parts: the matrix header (containing information such as the size of the matrix, the method used for storing, at which address is the matrix stored, and so on) and a pointer to the matrix containing the pixel values (taking any dimensionality depending on the method chosen for storing) . The matrix header size is constant, however the size of the matrix itself may vary from image to image and usually is larger by orders of magnitude.
|
||||
|
||||
OpenCV is an image processing library. It contains a large collection of image processing functions. To solve a computational challenge, most of the time you will end up using multiple functions of the library. Because of this, passing images to functions is a common practice. We should not forget that we are talking about image processing algorithms, which tend to be quite computational heavy. The last thing we want to do is further decrease the speed of your program by making unnecessary copies of potentially *large* images.
|
||||
|
||||
To tackle this issue OpenCV uses a reference counting system. The idea is that each *Mat* object has its own header, however the matrix may be shared between two instance of them by having their matrix pointers point to the same address. Moreover, the copy operators **will only copy the headers** and the pointer to the large matrix, not the data itself.
|
||||
To tackle this issue OpenCV uses a reference counting system. The idea is that each *Mat* object has its own header, however the matrix may be shared between two instance of them by having their matrix pointers point to the same address. Moreover, the copy operators **will only copy the headers** and the pointer to the large matrix, not the data itself.
|
||||
|
||||
.. code-block:: cpp
|
||||
:linenos:
|
||||
@ -39,21 +39,21 @@ To tackle this issue OpenCV uses a reference counting system. The idea is that e
|
||||
|
||||
C = A; // Assignment operator
|
||||
|
||||
All the above objects, in the end, point to the same single data matrix. Their headers are different, however, and making a modification using any of them will affect all the other ones as well. In practice the different objects just provide different access method to the same underlying data. Nevertheless, their header parts are different. The real interesting part is that you can create headers which refer to only a subsection of the full data. For example, to create a region of interest (*ROI*) in an image you just create a new header with the new boundaries:
|
||||
All the above objects, in the end, point to the same single data matrix. Their headers are different, however, and making a modification using any of them will affect all the other ones as well. In practice the different objects just provide different access method to the same underlying data. Nevertheless, their header parts are different. The real interesting part is that you can create headers which refer to only a subsection of the full data. For example, to create a region of interest (*ROI*) in an image you just create a new header with the new boundaries:
|
||||
|
||||
.. code-block:: cpp
|
||||
:linenos:
|
||||
|
||||
Mat D (A, Rect(10, 10, 100, 100) ); // using a rectangle
|
||||
Mat E = A(Range:all(), Range(1,3)); // using row and column boundaries
|
||||
Mat E = A(Range:all(), Range(1,3)); // using row and column boundaries
|
||||
|
||||
Now you may ask if the matrix itself may belong to multiple *Mat* objects who takes responsibility for cleaning it up when it's no longer needed. The short answer is: the last object that used it. This is handled by using a reference counting mechanism. Whenever somebody copies a header of a *Mat* object, a counter is increased for the matrix. Whenever a header is cleaned this counter is decreased. When the counter reaches zero the matrix too is freed. Sometimes you will want to copy the matrix itself too, so OpenCV provides the :basicstructures:`clone() <mat-clone>` and :basicstructures:`copyTo() <mat-copyto>` functions.
|
||||
|
||||
.. code-block:: cpp
|
||||
:linenos:
|
||||
|
||||
Mat F = A.clone();
|
||||
Mat G;
|
||||
Mat F = A.clone();
|
||||
Mat G;
|
||||
A.copyTo(G);
|
||||
|
||||
Now modifying *F* or *G* will not affect the matrix pointed by the *Mat* header. What you need to remember from all this is that:
|
||||
@ -66,19 +66,19 @@ Now modifying *F* or *G* will not affect the matrix pointed by the *Mat* header.
|
||||
* The underlying matrix of an image may be copied using the :basicstructures:`clone()<mat-clone>` and :basicstructures:`copyTo() <mat-copyto>` functions.
|
||||
|
||||
*Storing* methods
|
||||
=================
|
||||
=================
|
||||
|
||||
This is about how you store the pixel values. You can select the color space and the data type used. The color space refers to how we combine color components in order to code a given color. The simplest one is the gray scale where the colors at our disposal are black and white. The combination of these allows us to create many shades of gray.
|
||||
This is about how you store the pixel values. You can select the color space and the data type used. The color space refers to how we combine color components in order to code a given color. The simplest one is the gray scale where the colors at our disposal are black and white. The combination of these allows us to create many shades of gray.
|
||||
|
||||
For *colorful* ways we have a lot more methods to choose from. Each of them breaks it down to three or four basic components and we can use the combination of these to create the others. The most popular one is RGB, mainly because this is also how our eye builds up colors. Its base colors are red, green and blue. To code the transparency of a color sometimes a fourth element: alpha (A) is added.
|
||||
For *colorful* ways we have a lot more methods to choose from. Each of them breaks it down to three or four basic components and we can use the combination of these to create the others. The most popular one is RGB, mainly because this is also how our eye builds up colors. Its base colors are red, green and blue. To code the transparency of a color sometimes a fourth element: alpha (A) is added.
|
||||
|
||||
There are, however, many other color systems each with their own advantages:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* RGB is the most common as our eyes use something similar, our display systems also compose colors using these.
|
||||
* The HSV and HLS decompose colors into their hue, saturation and value/luminance components, which is a more natural way for us to describe colors. You might, for example, dismiss the last component, making your algorithm less sensible to the light conditions of the input image.
|
||||
* YCrCb is used by the popular JPEG image format.
|
||||
* The HSV and HLS decompose colors into their hue, saturation and value/luminance components, which is a more natural way for us to describe colors. You might, for example, dismiss the last component, making your algorithm less sensible to the light conditions of the input image.
|
||||
* YCrCb is used by the popular JPEG image format.
|
||||
* CIE L*a*b* is a perceptually uniform color space, which comes handy if you need to measure the *distance* of a given color to another color.
|
||||
|
||||
Each of the building components has their own valid domains. This leads to the data type used. How we store a component defines the control we have over its domain. The smallest data type possible is *char*, which means one byte or 8 bits. This may be unsigned (so can store values from 0 to 255) or signed (values from -127 to +127). Although in case of three components this already gives 16 million possible colors to represent (like in case of RGB) we may acquire an even finer control by using the float (4 byte = 32 bit) or double (8 byte = 64 bit) data types for each component. Nevertheless, remember that increasing the size of a component also increases the size of the whole picture in the memory.
|
||||
@ -86,13 +86,13 @@ Each of the building components has their own valid domains. This leads to the d
|
||||
Creating a *Mat* object explicitly
|
||||
==================================
|
||||
|
||||
In the :ref:`Load_Save_Image` tutorial you have already learned how to write a matrix to an image file by using the :readWriteImageVideo:` imwrite() <imwrite>` function. However, for debugging purposes it's much more convenient to see the actual values. You can do this using the << operator of *Mat*. Be aware that this only works for two dimensional matrices.
|
||||
In the :ref:`Load_Save_Image` tutorial you have already learned how to write a matrix to an image file by using the :readWriteImageVideo:` imwrite() <imwrite>` function. However, for debugging purposes it's much more convenient to see the actual values. You can do this using the << operator of *Mat*. Be aware that this only works for two dimensional matrices.
|
||||
|
||||
Although *Mat* works really well as an image container, it is also a general matrix class. Therefore, it is possible to create and manipulate multidimensional matrices. You can create a Mat object in multiple ways:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
+ :basicstructures:`Mat() <mat-mat>` Constructor
|
||||
+ :basicstructures:`Mat() <mat-mat>` Constructor
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp
|
||||
:language: cpp
|
||||
@ -105,7 +105,7 @@ Although *Mat* works really well as an image container, it is also a general mat
|
||||
|
||||
For two dimensional and multichannel images we first define their size: row and column count wise.
|
||||
|
||||
Then we need to specify the data type to use for storing the elements and the number of channels per matrix point. To do this we have multiple definitions constructed according to the following convention:
|
||||
Then we need to specify the data type to use for storing the elements and the number of channels per matrix point. To do this we have multiple definitions constructed according to the following convention:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -176,7 +176,7 @@ Although *Mat* works really well as an image container, it is also a general mat
|
||||
:alt: Demo image of the matrix output
|
||||
:align: center
|
||||
|
||||
.. note::
|
||||
.. note::
|
||||
|
||||
You can fill out a matrix with random values using the :operationsOnArrays:`randu() <randu>` function. You need to give the lower and upper value for the random values:
|
||||
|
||||
@ -189,11 +189,11 @@ Although *Mat* works really well as an image container, it is also a general mat
|
||||
Output formatting
|
||||
=================
|
||||
|
||||
In the above examples you could see the default formatting option. OpenCV, however, allows you to format your matrix output:
|
||||
In the above examples you could see the default formatting option. OpenCV, however, allows you to format your matrix output:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
+ Default
|
||||
+ Default
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp
|
||||
:language: cpp
|
||||
@ -215,7 +215,7 @@ In the above examples you could see the default formatting option. OpenCV, howev
|
||||
:alt: Default Output
|
||||
:align: center
|
||||
|
||||
+ Comma separated values (CSV)
|
||||
+ Comma separated values (CSV)
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp
|
||||
:language: cpp
|
||||
@ -255,7 +255,7 @@ OpenCV offers support for output of other common OpenCV data structures too via
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
+ 2D Point
|
||||
+ 2D Point
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp
|
||||
:language: cpp
|
||||
|
@ -44,7 +44,7 @@ Here you will learn the about the basic building blocks of the library. A must r
|
||||
.. |HowScanImag| image:: images/howToScanImages.jpg
|
||||
:height: 90pt
|
||||
:width: 90pt
|
||||
|
||||
|
||||
|
||||
+
|
||||
.. tabularcolumns:: m{100pt} m{300pt}
|
||||
@ -193,7 +193,7 @@ Here you will learn the about the basic building blocks of the library. A must r
|
||||
*Author:* |Author_BernatG|
|
||||
|
||||
Did you used OpenCV before its 2.0 version? Do you wanna know what happened with your library with 2.0? Don't you know how to convert your old OpenCV programs to the new C++ interface? Look here to shed light on all this questions.
|
||||
|
||||
|
||||
=============== ======================================================
|
||||
|
||||
.. |InterOOpenCV1| image:: images/interopOpenCV1.png
|
||||
@ -208,7 +208,7 @@ Here you will learn the about the basic building blocks of the library. A must r
|
||||
|
||||
.. toctree::
|
||||
:hidden:
|
||||
|
||||
|
||||
../mat_the_basic_image_container/mat_the_basic_image_container
|
||||
../how_to_scan_images/how_to_scan_images
|
||||
../mat-mask-operations/mat-mask-operations
|
||||
@ -218,4 +218,4 @@ Here you will learn the about the basic building blocks of the library. A must r
|
||||
../random_generator_and_text/random_generator_and_text
|
||||
../discrete_fourier_transform/discrete_fourier_transform
|
||||
../file_input_output_with_xml_yml/file_input_output_with_xml_yml
|
||||
../interoperability_with_OpenCV_1/interoperability_with_OpenCV_1
|
||||
../interoperability_with_OpenCV_1/interoperability_with_OpenCV_1
|
||||
|
@ -1 +1 @@
|
||||
Include in this directory only defintion files. None of the reST files entered here will be parsed by the Sphinx Builder.
|
||||
Include in this directory only defintion files. None of the reST files entered here will be parsed by the Sphinx Builder.
|
||||
|
@ -1,3 +1,3 @@
|
||||
|
||||
.. note::
|
||||
Unfortunetly we have no tutorials into this section. And you can help us with that, since OpenCV is a community effort. If you have a tutorial suggestion or you have written a tutorial yourself (or coded a sample code) that you would like to see here, please contact follow these instructions: :ref:`howToWriteTutorial` and :how_to_contribute:`How to contribute <>`.
|
||||
Unfortunetly we have no tutorials into this section. And you can help us with that, since OpenCV is a community effort. If you have a tutorial suggestion or you have written a tutorial yourself (or coded a sample code) that you would like to see here, please contact follow these instructions: :ref:`howToWriteTutorial` and :how_to_contribute:`How to contribute <>`.
|
||||
|
@ -3,7 +3,7 @@
|
||||
.. |Author_AndreyK| unicode:: Andrey U+0020 Kamaev
|
||||
.. |Author_LeonidBLB| unicode:: Leonid U+0020 Beynenson
|
||||
.. |Author_VsevolodG| unicode:: Vsevolod U+0020 Glumov
|
||||
.. |Author_VictorE| unicode:: Victor U+0020 Eruhimov
|
||||
.. |Author_VictorE| unicode:: Victor U+0020 Eruhimov
|
||||
.. |Author_ArtemM| unicode:: Artem U+0020 Myagkov
|
||||
.. |Author_FernandoI| unicode:: Fernando U+0020 Iglesias U+0020 Garc U+00ED a
|
||||
.. |Author_EduardF| unicode:: Eduard U+0020 Feicho
|
||||
|
@ -5,9 +5,9 @@ Detection of planar objects
|
||||
|
||||
.. highlight:: cpp
|
||||
|
||||
The goal of this tutorial is to learn how to use *features2d* and *calib3d* modules for detecting known planar objects in scenes.
|
||||
The goal of this tutorial is to learn how to use *features2d* and *calib3d* modules for detecting known planar objects in scenes.
|
||||
|
||||
*Test data*: use images in your data folder, for instance, ``box.png`` and ``box_in_scene.png``.
|
||||
*Test data*: use images in your data folder, for instance, ``box.png`` and ``box_in_scene.png``.
|
||||
|
||||
#.
|
||||
Create a new console project. Read two input images. ::
|
||||
@ -22,7 +22,7 @@ The goal of this tutorial is to learn how to use *features2d* and *calib3d* modu
|
||||
FastFeatureDetector detector(15);
|
||||
vector<KeyPoint> keypoints1;
|
||||
detector.detect(img1, keypoints1);
|
||||
|
||||
|
||||
... // do the same for the second image
|
||||
|
||||
#.
|
||||
@ -32,7 +32,7 @@ The goal of this tutorial is to learn how to use *features2d* and *calib3d* modu
|
||||
SurfDescriptorExtractor extractor;
|
||||
Mat descriptors1;
|
||||
extractor.compute(img1, keypoints1, descriptors1);
|
||||
|
||||
|
||||
... // process keypoints from the second image as well
|
||||
|
||||
#.
|
||||
@ -69,4 +69,4 @@ The goal of this tutorial is to learn how to use *features2d* and *calib3d* modu
|
||||
perspectiveTransform(Mat(points1), points1Projected, H);
|
||||
|
||||
#.
|
||||
Use ``drawMatches`` for drawing inliers.
|
||||
Use ``drawMatches`` for drawing inliers.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user