mirror of
https://github.com/opencv/opencv.git
synced 2026-07-22 03:43:03 +04:00
Compare commits
412 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e6f3f3c029 | |||
| 7746d9b7cc | |||
| 3494d640df | |||
| c22cc67ba8 | |||
| 558054a53d | |||
| c7b471f10f | |||
| f4ffcae8d9 | |||
| 0422054aa1 | |||
| a81f0a5123 | |||
| c36582d2df | |||
| d50c07e303 | |||
| 54693b3fa7 | |||
| 3c3bc123fc | |||
| ac33cd688c | |||
| b5e42d8cc1 | |||
| 7e4e8921bc | |||
| 6dcd455ac4 | |||
| 1d58e1a14a | |||
| d122510c4f | |||
| 6613d14261 | |||
| a14e524b32 | |||
| 226ff93917 | |||
| d28e6c9b36 | |||
| c16f465ff5 | |||
| 3231c2f995 | |||
| 16bcc30e42 | |||
| 69c50e0181 | |||
| 486c40f578 | |||
| 08e38e9ff9 | |||
| ba3b902da7 | |||
| bf94e6a91c | |||
| ecc53dd7a4 | |||
| fc0e0239b8 | |||
| d0210f510e | |||
| 34aa4e4578 | |||
| 447b8bf58a | |||
| e9539061db | |||
| ba7bf1ef68 | |||
| 5a53f41622 | |||
| 80844fd554 | |||
| a96a6bf149 | |||
| b7c9aaa471 | |||
| 1f5fd865aa | |||
| 9a3dccab20 | |||
| ac6ca660f4 | |||
| 6f47c26acf | |||
| 945663bc9b | |||
| 0263b49298 | |||
| c2f59a0f73 | |||
| 9eda260495 | |||
| 3ed54b9008 | |||
| 6b954cd24e | |||
| 42ba5c7d16 | |||
| 72ddeea479 | |||
| 869dda4117 | |||
| 07de67c32f | |||
| c467d0d553 | |||
| 0906744788 | |||
| 67158b12cd | |||
| 9e50cf5375 | |||
| 4bf82e50d0 | |||
| 2e86d46cf2 | |||
| 707d10f115 | |||
| 83a4ad5f51 | |||
| e7b82a8561 | |||
| 546e68dc65 | |||
| b7c2a46830 | |||
| 719099ad6d | |||
| 2e9004813e | |||
| 50842b9036 | |||
| 3d6413cfc6 | |||
| 799622affd | |||
| 57ab0d4d17 | |||
| 02f8b85dd9 | |||
| 1fbdca0c9b | |||
| 9eaac6105f | |||
| 83ace8d580 | |||
| 851ce27240 | |||
| 70f8d807c8 | |||
| daa21a4385 | |||
| 13cef0cdfc | |||
| 083aced3b4 | |||
| 72ec9c159e | |||
| 5b00d9da49 | |||
| 74bb0beeb0 | |||
| 08714c510f | |||
| acfbed8654 | |||
| 6212084046 | |||
| d89b6226a3 | |||
| 11d1909e6b | |||
| 3c6fe75149 | |||
| 00d9f690f6 | |||
| ae79fe10dc | |||
| 62fc342d35 | |||
| 36924d6dbb | |||
| ede4943d7e | |||
| 9d148c76ca | |||
| 21d8b588a2 | |||
| 5d66b1130b | |||
| 0550b2c1fe | |||
| d58d277707 | |||
| 95eed59f2d | |||
| 62bc647731 | |||
| 7f63776395 | |||
| b9792fdc14 | |||
| 0410fe6978 | |||
| 242e64c08d | |||
| cc94b393c5 | |||
| 58dd70e8dc | |||
| 53ff537f1c | |||
| a5814871d9 | |||
| 1aa03cecf1 | |||
| f10537cdd6 | |||
| 9d294cbcf5 | |||
| f1bec940b1 | |||
| dd93d48be4 | |||
| ad3123adfd | |||
| f939d80f4c | |||
| ee316758ca | |||
| 6d7a61cbdc | |||
| b44b1ab47b | |||
| 2e47a1a61b | |||
| 72685cf01c | |||
| 612888c066 | |||
| e7b55f4982 | |||
| 3004f5fa30 | |||
| 9682d2afff | |||
| 87d655325c | |||
| db25e44a17 | |||
| b7a9e672c5 | |||
| 8e49ab1d3b | |||
| 00c36e88ef | |||
| cde697dd14 | |||
| e49e75da06 | |||
| 1d40946959 | |||
| 2598392295 | |||
| 17cc5e2c40 | |||
| 4b14400976 | |||
| 4704a254f7 | |||
| 7708e9882e | |||
| fe1bd0cc2f | |||
| a752f25944 | |||
| bb44316028 | |||
| 0b2cfcfda2 | |||
| 9c02caf392 | |||
| d87c30dc84 | |||
| 63d6cc5ca6 | |||
| 9682430a69 | |||
| b69ffe6376 | |||
| 1f72815637 | |||
| 90c3d7d361 | |||
| f4eebc46b2 | |||
| 2b1103c1d3 | |||
| 007a3ef8b6 | |||
| 83eb1d3608 | |||
| 5c12c92243 | |||
| 9e29762838 | |||
| da229cce9a | |||
| 36af97d00c | |||
| d705c651f2 | |||
| 08848c56b7 | |||
| ebe979090e | |||
| 901d4995e3 | |||
| aad95c7d8c | |||
| d9b7b300b4 | |||
| 044de4105e | |||
| 7a5aa06b9e | |||
| a21fb63c28 | |||
| eaa9b78121 | |||
| fd4df0f67d | |||
| 6decc2596d | |||
| 41b920344d | |||
| 82668e06d4 | |||
| a81374c1d7 | |||
| 66fc6126d2 | |||
| 8b58b59df4 | |||
| f0595b8254 | |||
| 1e01441767 | |||
| c797746b6e | |||
| 1bf4427a5c | |||
| ac3ec0d96d | |||
| 5c6c537044 | |||
| f8c82fc214 | |||
| 40b762bceb | |||
| 89e3c508d8 | |||
| cbdddb473c | |||
| b4c2891ef3 | |||
| 1325213303 | |||
| fb15bdfb21 | |||
| 9d2d173485 | |||
| 26e3bcb9de | |||
| 960dee8ab8 | |||
| 847976de4e | |||
| ceec0eb33a | |||
| 4840c4ae6f | |||
| 02e29fc99c | |||
| 7ce116695d | |||
| c879b1ab09 | |||
| a984da911b | |||
| df55be3c3d | |||
| 55339de684 | |||
| f08dd510fa | |||
| de8d8720a2 | |||
| d308ed3712 | |||
| 6d0f8aa893 | |||
| bea98bd22a | |||
| 4539607ab1 | |||
| b320138dba | |||
| 95ea12588e | |||
| bcd08b5d18 | |||
| 19298ae3cb | |||
| 5e06da3050 | |||
| 17ac18a7b9 | |||
| c259590b26 | |||
| 3f3ca85103 | |||
| 05ddc16eaa | |||
| 2ba77614aa | |||
| ef347aa6a4 | |||
| b1cdb91139 | |||
| a09ad35d98 | |||
| 1b5835cd35 | |||
| 9932bbad3a | |||
| 39ac84ff04 | |||
| fcbefaff86 | |||
| bf2256fb89 | |||
| b0b2fc9e3f | |||
| 1ccd64e102 | |||
| 23bf3e337a | |||
| 3cf265992f | |||
| a855d230ec | |||
| 6a6619ec1e | |||
| 8c2bde2af4 | |||
| d22516872c | |||
| 17608f7ade | |||
| 81ebe28c24 | |||
| f7792f0be2 | |||
| 27302c367c | |||
| a153948a19 | |||
| 4273534c92 | |||
| 7274e2ff1a | |||
| 0e8bfff386 | |||
| 8c55d7be5e | |||
| f6de017171 | |||
| cc63452f65 | |||
| eeae81e903 | |||
| e30139edc3 | |||
| f01b2413c3 | |||
| 772fcf4088 | |||
| b8c00854fe | |||
| ba0a8dc723 | |||
| 100c2dd91c | |||
| 58c9135626 | |||
| 6e121b2e29 | |||
| e6619cf580 | |||
| 122b9f8e17 | |||
| d948b2a235 | |||
| ebd7d08408 | |||
| 140051b18c | |||
| b7276359e9 | |||
| 83d6d70a56 | |||
| a9d4e05346 | |||
| e5e6367223 | |||
| 5678ba1227 | |||
| b01f067614 | |||
| 65b0ecfec5 | |||
| d1902a1276 | |||
| 56cae1b293 | |||
| 7c740b6a31 | |||
| d430664791 | |||
| d057828ee3 | |||
| c9bb18b9f7 | |||
| 297e2b6f1a | |||
| 3853a18e0e | |||
| 226b4e3ed5 | |||
| 756c1a22d9 | |||
| a7bf1d53d8 | |||
| 7711cd284b | |||
| 8755ffbf31 | |||
| 69344f175b | |||
| d14a1de947 | |||
| 514b3b520c | |||
| 4a6b1805e0 | |||
| 4ab525c880 | |||
| 7d665a4754 | |||
| f7d52c774e | |||
| 8efdfd9dfc | |||
| cd42e38013 | |||
| 339e6aa782 | |||
| 309eb3c122 | |||
| 2594e5e384 | |||
| 3a7ea37090 | |||
| 9f0cd9ee10 | |||
| 13694c8ae8 | |||
| dde7c22fad | |||
| 29e7eb7719 | |||
| 3419c704a9 | |||
| cdbb661eab | |||
| afdf319f36 | |||
| 488babf3b3 | |||
| 2c57717ca2 | |||
| e9b4813bb2 | |||
| 9185b62a1d | |||
| ac8045b9c6 | |||
| 417f1e51a4 | |||
| b595812bd0 | |||
| 0172bd6beb | |||
| e02d6e2c8f | |||
| 7458dfc082 | |||
| bed8cb42be | |||
| c849492dfa | |||
| 4f5d30a865 | |||
| 2c0ef660bf | |||
| 21bbed7baf | |||
| 1e95c964f3 | |||
| a5b293b412 | |||
| 7d4cbbd7aa | |||
| b7be49426d | |||
| 42b1c6440c | |||
| 35a89b1541 | |||
| 8ae6402799 | |||
| 67635c6d65 | |||
| a26e496d00 | |||
| d579d3e596 | |||
| 5a77176654 | |||
| e929dd4d98 | |||
| 10a2c51c52 | |||
| 4664a339ae | |||
| fb81e4df1c | |||
| cb1e9adc63 | |||
| 562796e41b | |||
| bb93c53948 | |||
| 00575b346d | |||
| 7316676c41 | |||
| 77585bf8af | |||
| c821cb1489 | |||
| 86c1babd03 | |||
| 2205b2f5bc | |||
| 975e40f1c0 | |||
| 628b23acc8 | |||
| f8758da289 | |||
| ca9c52ac97 | |||
| b2790973a3 | |||
| e650d87e47 | |||
| feb74b125d | |||
| 3c0b0b0f94 | |||
| 942401de16 | |||
| f9ff9c5618 | |||
| b4845d8c9f | |||
| ea51396731 | |||
| aa82f921cc | |||
| 2da7eae2c4 | |||
| 25159d8e81 | |||
| f40ffe4763 | |||
| 116311b7b4 | |||
| f1ef3a4865 | |||
| 9997aa8187 | |||
| f15b42018c | |||
| f9e9ae85bd | |||
| a49beb7c73 | |||
| 51dff5b9e8 | |||
| 826fc00374 | |||
| c10692deff | |||
| daa7b9ce5f | |||
| 1ab02631b0 | |||
| 3e755b2290 | |||
| f15a167df4 | |||
| f6367a2ea5 | |||
| 5f88e2b496 | |||
| 2c7cf52e3b | |||
| b7c5083a87 | |||
| d5d88efd5d | |||
| 6cb7a7be18 | |||
| cdea6b532f | |||
| d01e3529a6 | |||
| 7c13d3277c | |||
| 345b3b0bdd | |||
| a65d7d4dd3 | |||
| 5e986f3347 | |||
| 27a8bb471b | |||
| 7868733002 | |||
| 469aef2e5e | |||
| 5e00fc6afe | |||
| 5170f0b5da | |||
| dc2dbb4173 | |||
| 79e4f7eb78 | |||
| cc73c7000f | |||
| 8bb26fa5de | |||
| 48612d7c58 | |||
| 8ba84f4b47 | |||
| bc653add74 | |||
| 215f78eee2 | |||
| 4425dac7f4 | |||
| 4f79b9de48 | |||
| 397ac5e68f | |||
| 43c75c64b5 | |||
| c319625a07 | |||
| a7d0448faa | |||
| ca10e5e8ae | |||
| 32414afe72 | |||
| ed10f50d25 | |||
| 48d9be70d5 | |||
| c6b31481b6 | |||
| 514b714cc2 | |||
| 7fec87d3f6 | |||
| 00d555f051 | |||
| 6cf7d6ef4e | |||
| 3ebdcafdd3 | |||
| a348f3eeaa | |||
| 33f423de04 | |||
| d6ba52c3f9 | |||
| e9638d0997 | |||
| 5cb0084547 |
Vendored
+2
@@ -3,9 +3,11 @@ set(HAVE_FFMPEG_CODEC 1)
|
||||
set(HAVE_FFMPEG_FORMAT 1)
|
||||
set(HAVE_FFMPEG_UTIL 1)
|
||||
set(HAVE_FFMPEG_SWSCALE 1)
|
||||
set(HAVE_FFMPEG_RESAMPLE 0)
|
||||
set(HAVE_GENTOO_FFMPEG 1)
|
||||
|
||||
set(ALIASOF_libavcodec_VERSION 55.18.102)
|
||||
set(ALIASOF_libavformat_VERSION 55.12.100)
|
||||
set(ALIASOF_libavutil_VERSION 52.38.100)
|
||||
set(ALIASOF_libswscale_VERSION 2.3.100)
|
||||
set(ALIASOF_libavresample_VERSION 1.0.1)
|
||||
@@ -52,6 +52,11 @@ if(POLICY CMP0026)
|
||||
cmake_policy(SET CMP0026 OLD)
|
||||
endif()
|
||||
|
||||
if (POLICY CMP0042)
|
||||
# silence cmake 3.0+ warnings about MACOSX_RPATH
|
||||
cmake_policy(SET CMP0042 OLD)
|
||||
endif()
|
||||
|
||||
# must go before the project command
|
||||
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE)
|
||||
if(DEFINED CMAKE_BUILD_TYPE AND CMAKE_VERSION VERSION_GREATER "2.8")
|
||||
@@ -189,6 +194,7 @@ OCV_OPTION(BUILD_WITH_STATIC_CRT "Enables use of staticaly linked CRT for sta
|
||||
OCV_OPTION(BUILD_FAT_JAVA_LIB "Create fat java wrapper containing the whole OpenCV library" ON IF NOT BUILD_SHARED_LIBS AND CMAKE_COMPILER_IS_GNUCXX )
|
||||
OCV_OPTION(BUILD_ANDROID_SERVICE "Build OpenCV Manager for Google Play" OFF IF ANDROID AND ANDROID_SOURCE_TREE )
|
||||
OCV_OPTION(BUILD_ANDROID_PACKAGE "Build platform-specific package for Google Play" OFF IF ANDROID )
|
||||
OCV_OPTION(BUILD_TINY_GPU_MODULE "Build tiny gpu module with limited image format support" OFF )
|
||||
|
||||
# 3rd party libs
|
||||
OCV_OPTION(BUILD_ZLIB "Build zlib from source" WIN32 OR APPLE )
|
||||
@@ -883,6 +889,7 @@ if(DEFINED WITH_FFMPEG)
|
||||
status(" format:" HAVE_FFMPEG_FORMAT THEN "YES (ver ${ALIASOF_libavformat_VERSION})" ELSE NO)
|
||||
status(" util:" HAVE_FFMPEG_UTIL THEN "YES (ver ${ALIASOF_libavutil_VERSION})" ELSE NO)
|
||||
status(" swscale:" HAVE_FFMPEG_SWSCALE THEN "YES (ver ${ALIASOF_libswscale_VERSION})" ELSE NO)
|
||||
status(" resample:" HAVE_FFMPEG_RESAMPLE THEN "YES (ver ${ALIASOF_libavresample_VERSION})" ELSE NO)
|
||||
status(" gentoo-style:" HAVE_GENTOO_FFMPEG THEN YES ELSE NO)
|
||||
endif(DEFINED WITH_FFMPEG)
|
||||
|
||||
@@ -991,6 +998,7 @@ if(HAVE_CUDA)
|
||||
status(" NVIDIA GPU arch:" ${OPENCV_CUDA_ARCH_BIN})
|
||||
status(" NVIDIA PTX archs:" ${OPENCV_CUDA_ARCH_PTX})
|
||||
status(" Use fast math:" CUDA_FAST_MATH THEN YES ELSE NO)
|
||||
status(" Tiny gpu module:" BUILD_TINY_GPU_MODULE THEN YES ELSE NO)
|
||||
endif()
|
||||
|
||||
if(HAVE_OPENCL)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
SET(deps opencv_core opencv_highgui opencv_imgproc)
|
||||
ocv_check_dependencies(${deps})
|
||||
SET(OPENCV_ANNOTATION_DEPS opencv_core opencv_highgui opencv_imgproc)
|
||||
ocv_check_dependencies(${OPENCV_ANNOTATION_DEPS})
|
||||
|
||||
if(NOT OCV_DEPENDENCIES_FOUND)
|
||||
return()
|
||||
@@ -8,12 +8,13 @@ endif()
|
||||
project(annotation)
|
||||
|
||||
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv")
|
||||
ocv_include_modules(${deps})
|
||||
ocv_include_modules(${OPENCV_ANNOTATION_DEPS})
|
||||
|
||||
set(annotation_files opencv_annotation.cpp)
|
||||
set(the_target opencv_annotation)
|
||||
|
||||
add_executable(${the_target} opencv_annotation.cpp)
|
||||
target_link_libraries(${the_target} ${deps})
|
||||
add_executable(${the_target} ${annotation_files})
|
||||
target_link_libraries(${the_target} ${OPENCV_ANNOTATION_DEPS})
|
||||
|
||||
set_target_properties(${the_target} PROPERTIES
|
||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
||||
|
||||
@@ -1,8 +1,51 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*****************************************************************************************************
|
||||
USAGE:
|
||||
./opencv_annotation -images <folder location> -annotations <ouput file>
|
||||
|
||||
Created by: Puttemans Steven
|
||||
Created by: Puttemans Steven - February 2015
|
||||
*****************************************************************************************************/
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
@@ -12,6 +55,12 @@ Created by: Puttemans Steven
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <direct.h>
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
@@ -152,6 +201,15 @@ void get_annotations(Mat input_image, stringstream* output_stream)
|
||||
|
||||
int main( int argc, const char** argv )
|
||||
{
|
||||
// If no arguments are given, then supply some information on how this tool works
|
||||
if( argc == 1 ){
|
||||
cout << "Usage: " << argv[0] << endl;
|
||||
cout << " -images <folder_location> [example - /data/testimages/]" << endl;
|
||||
cout << " -annotations <ouput_file> [example - /data/annotations.txt]" << endl;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Read in the input arguments
|
||||
string image_folder;
|
||||
string annotations;
|
||||
@@ -167,8 +225,33 @@ int main( int argc, const char** argv )
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the folder actually exists
|
||||
// If -1 is returned then the folder actually exists, and thus you can continue
|
||||
// In all other cases there was a folder creation and thus the folder did not exist
|
||||
#if defined(_WIN32)
|
||||
if(_mkdir(image_folder.c_str()) != -1){
|
||||
// Generate an error message
|
||||
cerr << "The image folder given does not exist. Please check again!" << endl;
|
||||
// Remove the created folder again, to ensure a second run with same code fails again
|
||||
_rmdir(image_folder.c_str());
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
if(mkdir(image_folder.c_str(), 0777) != -1){
|
||||
// Generate an error message
|
||||
cerr << "The image folder given does not exist. Please check again!" << endl;
|
||||
// Remove the created folder again, to ensure a second run with same code fails again
|
||||
remove(image_folder.c_str());
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Create the outputfilestream
|
||||
ofstream output(annotations.c_str());
|
||||
if ( !output.is_open() ){
|
||||
cerr << "The path for the output file contains an error and could not be opened. Please check again!" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Return the image filenames inside the image folder
|
||||
vector<String> filenames;
|
||||
@@ -182,6 +265,12 @@ int main( int argc, const char** argv )
|
||||
// Read in an image
|
||||
Mat current_image = imread(filenames[i]);
|
||||
|
||||
// Check if the image is actually read - avoid other files in the folder, because glob() takes them all
|
||||
// If not then simply skip this iteration
|
||||
if(current_image.empty()){
|
||||
continue;
|
||||
}
|
||||
|
||||
// Perform annotations & generate corresponding output
|
||||
stringstream output_stream;
|
||||
get_annotations(current_image, &output_stream);
|
||||
|
||||
+28
-28
@@ -374,7 +374,7 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id
|
||||
if (is_buf_16u)
|
||||
{
|
||||
unsigned short* udst_idx = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() +
|
||||
vi*sample_count + data_root->offset);
|
||||
(size_t)vi*sample_count + data_root->offset);
|
||||
for( int i = 0; i < num_valid; i++ )
|
||||
{
|
||||
idx = src_idx[i];
|
||||
@@ -387,7 +387,7 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id
|
||||
else
|
||||
{
|
||||
int* idst_idx = buf->data.i + root->buf_idx*get_length_subbuf() +
|
||||
vi*sample_count + root->offset;
|
||||
(size_t)vi*sample_count + root->offset;
|
||||
for( int i = 0; i < num_valid; i++ )
|
||||
{
|
||||
idx = src_idx[i];
|
||||
@@ -404,14 +404,14 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id
|
||||
if (is_buf_16u)
|
||||
{
|
||||
unsigned short* udst = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() +
|
||||
(workVarCount-1)*sample_count + root->offset);
|
||||
(size_t)(workVarCount-1)*sample_count + root->offset);
|
||||
for( int i = 0; i < count; i++ )
|
||||
udst[i] = (unsigned short)src_lbls[sidx[i]];
|
||||
}
|
||||
else
|
||||
{
|
||||
int* idst = buf->data.i + root->buf_idx*get_length_subbuf() +
|
||||
(workVarCount-1)*sample_count + root->offset;
|
||||
(size_t)(workVarCount-1)*sample_count + root->offset;
|
||||
for( int i = 0; i < count; i++ )
|
||||
idst[i] = src_lbls[sidx[i]];
|
||||
}
|
||||
@@ -421,14 +421,14 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id
|
||||
if (is_buf_16u)
|
||||
{
|
||||
unsigned short* sample_idx_dst = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() +
|
||||
workVarCount*sample_count + root->offset);
|
||||
(size_t)workVarCount*sample_count + root->offset);
|
||||
for( int i = 0; i < count; i++ )
|
||||
sample_idx_dst[i] = (unsigned short)sample_idx_src[sidx[i]];
|
||||
}
|
||||
else
|
||||
{
|
||||
int* sample_idx_dst = buf->data.i + root->buf_idx*get_length_subbuf() +
|
||||
workVarCount*sample_count + root->offset;
|
||||
(size_t)workVarCount*sample_count + root->offset;
|
||||
for( int i = 0; i < count; i++ )
|
||||
sample_idx_dst[i] = sample_idx_src[sidx[i]];
|
||||
}
|
||||
@@ -614,9 +614,9 @@ void CvCascadeBoostTrainData::setData( const CvFeatureEvaluator* _featureEvaluat
|
||||
|
||||
// set sample labels
|
||||
if (is_buf_16u)
|
||||
udst = (unsigned short*)(buf->data.s + work_var_count*sample_count);
|
||||
udst = (unsigned short*)(buf->data.s + (size_t)work_var_count*sample_count);
|
||||
else
|
||||
idst = buf->data.i + work_var_count*sample_count;
|
||||
idst = buf->data.i + (size_t)work_var_count*sample_count;
|
||||
|
||||
for (int si = 0; si < sample_count; si++)
|
||||
{
|
||||
@@ -684,11 +684,11 @@ void CvCascadeBoostTrainData::get_ord_var_data( CvDTreeNode* n, int vi, float* o
|
||||
if ( vi < numPrecalcIdx )
|
||||
{
|
||||
if( !is_buf_16u )
|
||||
*sortedIndices = buf->data.i + n->buf_idx*get_length_subbuf() + vi*sample_count + n->offset;
|
||||
*sortedIndices = buf->data.i + n->buf_idx*get_length_subbuf() + (size_t)vi*sample_count + n->offset;
|
||||
else
|
||||
{
|
||||
const unsigned short* shortIndices = (const unsigned short*)(buf->data.s + n->buf_idx*get_length_subbuf() +
|
||||
vi*sample_count + n->offset );
|
||||
(size_t)vi*sample_count + n->offset );
|
||||
for( int i = 0; i < nodeSampleCount; i++ )
|
||||
sortedIndicesBuf[i] = shortIndices[i];
|
||||
|
||||
@@ -799,14 +799,14 @@ struct FeatureIdxOnlyPrecalc : ParallelLoopBody
|
||||
{
|
||||
valCachePtr[si] = (*featureEvaluator)( fi, si );
|
||||
if ( is_buf_16u )
|
||||
*(udst + fi*sample_count + si) = (unsigned short)si;
|
||||
*(udst + (size_t)fi*sample_count + si) = (unsigned short)si;
|
||||
else
|
||||
*(idst + fi*sample_count + si) = si;
|
||||
*(idst + (size_t)fi*sample_count + si) = si;
|
||||
}
|
||||
if ( is_buf_16u )
|
||||
icvSortUShAux( udst + fi*sample_count, sample_count, valCachePtr );
|
||||
icvSortUShAux( udst + (size_t)fi*sample_count, sample_count, valCachePtr );
|
||||
else
|
||||
icvSortIntAux( idst + fi*sample_count, sample_count, valCachePtr );
|
||||
icvSortIntAux( idst + (size_t)fi*sample_count, sample_count, valCachePtr );
|
||||
}
|
||||
}
|
||||
const CvFeatureEvaluator* featureEvaluator;
|
||||
@@ -835,14 +835,14 @@ struct FeatureValAndIdxPrecalc : ParallelLoopBody
|
||||
{
|
||||
valCache->at<float>(fi,si) = (*featureEvaluator)( fi, si );
|
||||
if ( is_buf_16u )
|
||||
*(udst + fi*sample_count + si) = (unsigned short)si;
|
||||
*(udst + (size_t)fi*sample_count + si) = (unsigned short)si;
|
||||
else
|
||||
*(idst + fi*sample_count + si) = si;
|
||||
*(idst + (size_t)fi*sample_count + si) = si;
|
||||
}
|
||||
if ( is_buf_16u )
|
||||
icvSortUShAux( udst + fi*sample_count, sample_count, valCache->ptr<float>(fi) );
|
||||
icvSortUShAux( udst + (size_t)fi*sample_count, sample_count, valCache->ptr<float>(fi) );
|
||||
else
|
||||
icvSortIntAux( idst + fi*sample_count, sample_count, valCache->ptr<float>(fi) );
|
||||
icvSortIntAux( idst + (size_t)fi*sample_count, sample_count, valCache->ptr<float>(fi) );
|
||||
}
|
||||
}
|
||||
const CvFeatureEvaluator* featureEvaluator;
|
||||
@@ -1165,9 +1165,9 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node )
|
||||
if (data->is_buf_16u)
|
||||
{
|
||||
unsigned short *ldst = (unsigned short *)(buf->data.s + left->buf_idx*length_buf_row +
|
||||
(workVarCount-1)*scount + left->offset);
|
||||
(size_t)(workVarCount-1)*scount + left->offset);
|
||||
unsigned short *rdst = (unsigned short *)(buf->data.s + right->buf_idx*length_buf_row +
|
||||
(workVarCount-1)*scount + right->offset);
|
||||
(size_t)(workVarCount-1)*scount + right->offset);
|
||||
|
||||
for( int i = 0; i < n; i++ )
|
||||
{
|
||||
@@ -1188,9 +1188,9 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node )
|
||||
else
|
||||
{
|
||||
int *ldst = buf->data.i + left->buf_idx*length_buf_row +
|
||||
(workVarCount-1)*scount + left->offset;
|
||||
(size_t)(workVarCount-1)*scount + left->offset;
|
||||
int *rdst = buf->data.i + right->buf_idx*length_buf_row +
|
||||
(workVarCount-1)*scount + right->offset;
|
||||
(size_t)(workVarCount-1)*scount + right->offset;
|
||||
|
||||
for( int i = 0; i < n; i++ )
|
||||
{
|
||||
@@ -1218,9 +1218,9 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node )
|
||||
if (data->is_buf_16u)
|
||||
{
|
||||
unsigned short* ldst = (unsigned short*)(buf->data.s + left->buf_idx*length_buf_row +
|
||||
workVarCount*scount + left->offset);
|
||||
(size_t)workVarCount*scount + left->offset);
|
||||
unsigned short* rdst = (unsigned short*)(buf->data.s + right->buf_idx*length_buf_row +
|
||||
workVarCount*scount + right->offset);
|
||||
(size_t)workVarCount*scount + right->offset);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
unsigned short idx = (unsigned short)tempBuf[i];
|
||||
@@ -1239,9 +1239,9 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node )
|
||||
else
|
||||
{
|
||||
int* ldst = buf->data.i + left->buf_idx*length_buf_row +
|
||||
workVarCount*scount + left->offset;
|
||||
(size_t)workVarCount*scount + left->offset;
|
||||
int* rdst = buf->data.i + right->buf_idx*length_buf_row +
|
||||
workVarCount*scount + right->offset;
|
||||
(size_t)workVarCount*scount + right->offset;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
int idx = tempBuf[i];
|
||||
@@ -1410,7 +1410,7 @@ void CvCascadeBoost::update_weights( CvBoostTree* tree )
|
||||
if (data->is_buf_16u)
|
||||
{
|
||||
unsigned short* labels = (unsigned short*)(buf->data.s + data->data_root->buf_idx*length_buf_row +
|
||||
data->data_root->offset + (data->work_var_count-1)*data->sample_count);
|
||||
data->data_root->offset + (size_t)(data->work_var_count-1)*data->sample_count);
|
||||
for( int i = 0; i < n; i++ )
|
||||
{
|
||||
// save original categorical responses {0,1}, convert them to {-1,1}
|
||||
@@ -1428,7 +1428,7 @@ void CvCascadeBoost::update_weights( CvBoostTree* tree )
|
||||
else
|
||||
{
|
||||
int* labels = buf->data.i + data->data_root->buf_idx*length_buf_row +
|
||||
data->data_root->offset + (data->work_var_count-1)*data->sample_count;
|
||||
data->data_root->offset + (size_t)(data->work_var_count-1)*data->sample_count;
|
||||
|
||||
for( int i = 0; i < n; i++ )
|
||||
{
|
||||
|
||||
@@ -136,7 +136,8 @@ bool CvCascadeClassifier::train( const string _cascadeDirName,
|
||||
const CvCascadeParams& _cascadeParams,
|
||||
const CvFeatureParams& _featureParams,
|
||||
const CvCascadeBoostParams& _stageParams,
|
||||
bool baseFormatSave )
|
||||
bool baseFormatSave,
|
||||
double acceptanceRatioBreakValue)
|
||||
{
|
||||
// Start recording clock ticks for training time output
|
||||
const clock_t begin_time = clock();
|
||||
@@ -186,6 +187,7 @@ bool CvCascadeClassifier::train( const string _cascadeDirName,
|
||||
cout << "numStages: " << numStages << endl;
|
||||
cout << "precalcValBufSize[Mb] : " << _precalcValBufSize << endl;
|
||||
cout << "precalcIdxBufSize[Mb] : " << _precalcIdxBufSize << endl;
|
||||
cout << "acceptanceRatioBreakValue : " << acceptanceRatioBreakValue << endl;
|
||||
cascadeParams.printAttrs();
|
||||
stageParams->printAttrs();
|
||||
featureParams->printAttrs();
|
||||
@@ -208,15 +210,20 @@ bool CvCascadeClassifier::train( const string _cascadeDirName,
|
||||
if ( !updateTrainingSet( requiredLeafFARate, tempLeafFARate ) )
|
||||
{
|
||||
cout << "Train dataset for temp stage can not be filled. "
|
||||
"Branch training terminated." << endl;
|
||||
"Branch training terminated." << endl;
|
||||
break;
|
||||
}
|
||||
if( tempLeafFARate <= requiredLeafFARate )
|
||||
{
|
||||
cout << "Required leaf false alarm rate achieved. "
|
||||
"Branch training terminated." << endl;
|
||||
"Branch training terminated." << endl;
|
||||
break;
|
||||
}
|
||||
if( (tempLeafFARate <= acceptanceRatioBreakValue) && (acceptanceRatioBreakValue >= 0) ){
|
||||
cout << "The required acceptanceRatio for the model has been reached to avoid overfitting of trainingdata. "
|
||||
"Branch training terminated." << endl;
|
||||
break;
|
||||
}
|
||||
|
||||
CvCascadeBoost* tempStage = new CvCascadeBoost;
|
||||
bool isStageTrained = tempStage->train( (CvFeatureEvaluator*)featureEvaluator,
|
||||
|
||||
@@ -96,7 +96,8 @@ public:
|
||||
const CvCascadeParams& _cascadeParams,
|
||||
const CvFeatureParams& _featureParams,
|
||||
const CvCascadeBoostParams& _stageParams,
|
||||
bool baseFormatSave = false );
|
||||
bool baseFormatSave = false,
|
||||
double acceptanceRatioBreakValue = -1.0 );
|
||||
private:
|
||||
int predict( int sampleIdx );
|
||||
void save( const std::string cascadeDirName, bool baseFormat = false );
|
||||
|
||||
@@ -32,20 +32,12 @@ bool CvCascadeImageReader::NegReader::create( const string _filename, Size _winS
|
||||
if ( !file.is_open() )
|
||||
return false;
|
||||
|
||||
size_t pos = _filename.rfind('\\');
|
||||
char dlmrt = '\\';
|
||||
if (pos == string::npos)
|
||||
{
|
||||
pos = _filename.rfind('/');
|
||||
dlmrt = '/';
|
||||
}
|
||||
dirname = pos == string::npos ? "" : _filename.substr(0, pos) + dlmrt;
|
||||
while( !file.eof() )
|
||||
{
|
||||
std::getline(file, str);
|
||||
if (str.empty()) break;
|
||||
if (str.at(0) == '#' ) continue; /* comment */
|
||||
imgFilenames.push_back(dirname + str);
|
||||
imgFilenames.push_back(str);
|
||||
}
|
||||
file.close();
|
||||
|
||||
|
||||
@@ -14,9 +14,10 @@ int main( int argc, char* argv[] )
|
||||
int numPos = 2000;
|
||||
int numNeg = 1000;
|
||||
int numStages = 20;
|
||||
int precalcValBufSize = 256,
|
||||
precalcIdxBufSize = 256;
|
||||
int precalcValBufSize = 1024,
|
||||
precalcIdxBufSize = 1024;
|
||||
bool baseFormatSave = false;
|
||||
double acceptanceRatioBreakValue = -1.0;
|
||||
|
||||
CvCascadeParams cascadeParams;
|
||||
CvCascadeBoostParams stageParams;
|
||||
@@ -37,6 +38,7 @@ int main( int argc, char* argv[] )
|
||||
cout << " [-precalcValBufSize <precalculated_vals_buffer_size_in_Mb = " << precalcValBufSize << ">]" << endl;
|
||||
cout << " [-precalcIdxBufSize <precalculated_idxs_buffer_size_in_Mb = " << precalcIdxBufSize << ">]" << endl;
|
||||
cout << " [-baseFormatSave]" << endl;
|
||||
cout << " [-acceptanceRatioBreakValue <value> = " << acceptanceRatioBreakValue << ">]" << endl;
|
||||
cascadeParams.printDefaults();
|
||||
stageParams.printDefaults();
|
||||
for( int fi = 0; fi < fc; fi++ )
|
||||
@@ -83,6 +85,10 @@ int main( int argc, char* argv[] )
|
||||
{
|
||||
baseFormatSave = true;
|
||||
}
|
||||
else if( !strcmp( argv[i], "-acceptanceRatioBreakValue" ) )
|
||||
{
|
||||
acceptanceRatioBreakValue = atof(argv[++i]);
|
||||
}
|
||||
else if ( cascadeParams.scanAttr( argv[i], argv[i+1] ) ) { i++; }
|
||||
else if ( stageParams.scanAttr( argv[i], argv[i+1] ) ) { i++; }
|
||||
else if ( !set )
|
||||
@@ -108,6 +114,7 @@ int main( int argc, char* argv[] )
|
||||
cascadeParams,
|
||||
*featureParams[cascadeParams.featureType],
|
||||
stageParams,
|
||||
baseFormatSave );
|
||||
baseFormatSave,
|
||||
acceptanceRatioBreakValue );
|
||||
return 0;
|
||||
}
|
||||
|
||||
+12
-2
@@ -619,6 +619,8 @@ if(DEFINED CUDA_TARGET_CPU_ARCH)
|
||||
set(_cuda_target_cpu_arch_initial "${CUDA_TARGET_CPU_ARCH}")
|
||||
elseif(CUDA_VERSION VERSION_GREATER "5.0" AND CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm|ARM)")
|
||||
set(_cuda_target_cpu_arch_initial "ARM")
|
||||
elseif(CUDA_VERSION VERSION_GREATER "6.5" AND CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|AARCH64)")
|
||||
set(_cuda_target_cpu_arch_initial "AARCH64")
|
||||
else()
|
||||
set(_cuda_target_cpu_arch_initial "")
|
||||
endif()
|
||||
@@ -643,6 +645,12 @@ elseif(CUDA_VERSION VERSION_GREATER "5.0" AND CMAKE_CROSSCOMPILING AND "${CUDA_T
|
||||
elseif(EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/targets/armv7-linux-gnueabihf")
|
||||
set(_cuda_target_triplet_initial "armv7-linux-gnueabihf")
|
||||
endif()
|
||||
elseif(CUDA_VERSION VERSION_GREATER "6.5" AND CMAKE_CROSSCOMPILING AND "${CUDA_TARGET_CPU_ARCH}" STREQUAL "AARCH64")
|
||||
if("${CUDA_TARGET_OS_VARIANT}" STREQUAL "Android" AND EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/targets/aarch64-linux-androideabi")
|
||||
set(_cuda_target_triplet_initial "aarch64-linux-androideabi")
|
||||
elseif(EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/targets/aarch64-linux-gnueabihf")
|
||||
set(_cuda_target_triplet_initial "aarch64-linux-gnueabihf")
|
||||
endif()
|
||||
endif()
|
||||
set(CUDA_TARGET_TRIPLET "${_cuda_target_triplet_initial}" CACHE STRING "Specify the target triplet for which the input files must be compiled.")
|
||||
file(GLOB __cuda_available_target_tiplets RELATIVE "${CUDA_TOOLKIT_ROOT_DIR}/targets" "${CUDA_TOOLKIT_ROOT_DIR}/targets/*" )
|
||||
@@ -1094,8 +1102,10 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files)
|
||||
set(nvcc_flags ${nvcc_flags} -m32)
|
||||
endif()
|
||||
|
||||
if(CUDA_TARGET_CPU_ARCH)
|
||||
set(nvcc_flags ${nvcc_flags} "--target-cpu-architecture=${CUDA_TARGET_CPU_ARCH}")
|
||||
if(CUDA_TARGET_CPU_ARCH AND CUDA_VERSION VERSION_LESS "7.0")
|
||||
# CPU architecture is either ARM or X86. Patch AARCH64 to be ARM
|
||||
string(REPLACE "AARCH64" "ARM" CUDA_TARGET_CPU_ARCH_patched ${CUDA_TARGET_CPU_ARCH})
|
||||
set(nvcc_flags ${nvcc_flags} "--target-cpu-architecture=${CUDA_TARGET_CPU_ARCH_patched}")
|
||||
endif()
|
||||
|
||||
if(CUDA_TARGET_OS_VARIANT AND CUDA_VERSION VERSION_LESS "7.0")
|
||||
|
||||
@@ -63,6 +63,10 @@ if(OPENCV_CAN_BREAK_BINARY_COMPATIBILITY)
|
||||
add_definitions(-DOPENCV_CAN_BREAK_BINARY_COMPATIBILITY)
|
||||
endif()
|
||||
|
||||
if(BUILD_TINY_GPU_MODULE)
|
||||
add_definitions(-DOPENCV_TINY_GPU_MODULE)
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
# High level of warnings.
|
||||
add_extra_compiler_option(-W)
|
||||
@@ -91,6 +95,8 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
add_extra_compiler_option(-Wno-narrowing)
|
||||
add_extra_compiler_option(-Wno-delete-non-virtual-dtor)
|
||||
add_extra_compiler_option(-Wno-unnamed-type-template-args)
|
||||
add_extra_compiler_option(-Wno-array-bounds)
|
||||
add_extra_compiler_option(-Wno-aggressive-loop-optimizations)
|
||||
endif()
|
||||
add_extra_compiler_option(-fdiagnostics-show-option)
|
||||
|
||||
@@ -257,6 +263,11 @@ if(MSVC)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MSVC12 AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} /FS")
|
||||
set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS} /FS")
|
||||
endif()
|
||||
|
||||
# Extra link libs if the user selects building static libs:
|
||||
if(NOT BUILD_SHARED_LIBS AND ((CMAKE_COMPILER_IS_GNUCXX AND NOT ANDROID) OR QNX))
|
||||
# Android does not need these settings because they are already set by toolchain file
|
||||
|
||||
@@ -79,6 +79,8 @@ if(MSVC)
|
||||
set(OpenCV_RUNTIME vc11)
|
||||
elseif(MSVC_VERSION EQUAL 1800)
|
||||
set(OpenCV_RUNTIME vc12)
|
||||
elseif(MSVC_VERSION EQUAL 1900)
|
||||
set(OpenCV_RUNTIME vc14)
|
||||
endif()
|
||||
elseif(MINGW)
|
||||
set(OpenCV_RUNTIME mingw)
|
||||
@@ -86,7 +88,7 @@ elseif(MINGW)
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
|
||||
OUTPUT_VARIABLE OPENCV_GCC_TARGET_MACHINE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(CMAKE_OPENCV_GCC_TARGET_MACHINE MATCHES "64")
|
||||
if(OPENCV_GCC_TARGET_MACHINE MATCHES "amd64|x86_64|AMD64")
|
||||
set(MINGW64 1)
|
||||
set(OpenCV_ARCH x64)
|
||||
else()
|
||||
|
||||
@@ -86,12 +86,14 @@ if(CUDA_FOUND)
|
||||
set(__cuda_arch_bin "3.2")
|
||||
set(__cuda_arch_ptx "")
|
||||
elseif(AARCH64)
|
||||
set(__cuda_arch_bin "5.2")
|
||||
set(__cuda_arch_bin "5.3")
|
||||
set(__cuda_arch_ptx "")
|
||||
endif()
|
||||
else()
|
||||
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")
|
||||
elseif(${CUDA_VERSION} VERSION_GREATER "6.5")
|
||||
set(__cuda_arch_bin "2.0 2.1(2.0) 3.0 3.5")
|
||||
else()
|
||||
set(__cuda_arch_bin "1.1 1.2 1.3 2.0 2.1(2.0) 3.0 3.5")
|
||||
endif()
|
||||
@@ -216,40 +218,18 @@ else()
|
||||
endif()
|
||||
|
||||
if(HAVE_CUDA)
|
||||
set(CUDA_LIBS_PATH "")
|
||||
foreach(p ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
|
||||
get_filename_component(_tmp ${p} PATH)
|
||||
list(APPEND CUDA_LIBS_PATH ${_tmp})
|
||||
endforeach()
|
||||
|
||||
if(HAVE_CUBLAS)
|
||||
foreach(p ${CUDA_cublas_LIBRARY})
|
||||
get_filename_component(_tmp ${p} PATH)
|
||||
list(APPEND CUDA_LIBS_PATH ${_tmp})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(HAVE_CUFFT)
|
||||
foreach(p ${CUDA_cufft_LIBRARY})
|
||||
get_filename_component(_tmp ${p} PATH)
|
||||
list(APPEND CUDA_LIBS_PATH ${_tmp})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
list(REMOVE_DUPLICATES CUDA_LIBS_PATH)
|
||||
link_directories(${CUDA_LIBS_PATH})
|
||||
|
||||
set(CUDA_LIBRARIES_ABS ${CUDA_LIBRARIES})
|
||||
ocv_convert_to_lib_name(CUDA_LIBRARIES ${CUDA_LIBRARIES})
|
||||
ocv_create_imported_targets(CUDA_LIBRARIES ${CUDA_LIBRARIES})
|
||||
set(CUDA_npp_LIBRARY_ABS ${CUDA_npp_LIBRARY})
|
||||
ocv_convert_to_lib_name(CUDA_npp_LIBRARY ${CUDA_npp_LIBRARY})
|
||||
ocv_create_imported_targets(CUDA_npp_LIBRARY ${CUDA_npp_LIBRARY})
|
||||
|
||||
if(HAVE_CUBLAS)
|
||||
set(CUDA_cublas_LIBRARY_ABS ${CUDA_cublas_LIBRARY})
|
||||
ocv_convert_to_lib_name(CUDA_cublas_LIBRARY ${CUDA_cublas_LIBRARY})
|
||||
ocv_create_imported_targets(CUDA_cublas_LIBRARY ${CUDA_cublas_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(HAVE_CUFFT)
|
||||
set(CUDA_cufft_LIBRARY_ABS ${CUDA_cufft_LIBRARY})
|
||||
ocv_convert_to_lib_name(CUDA_cufft_LIBRARY ${CUDA_cufft_LIBRARY})
|
||||
ocv_create_imported_targets(CUDA_cufft_LIBRARY ${CUDA_cufft_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -91,9 +91,9 @@ elseif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
if(WIN32)
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
|
||||
OUTPUT_VARIABLE CMAKE_OPENCV_GCC_TARGET_MACHINE
|
||||
OUTPUT_VARIABLE OPENCV_GCC_TARGET_MACHINE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(CMAKE_OPENCV_GCC_TARGET_MACHINE MATCHES "amd64|x86_64|AMD64")
|
||||
if(OPENCV_GCC_TARGET_MACHINE MATCHES "amd64|x86_64|AMD64")
|
||||
set(MINGW64 1)
|
||||
endif()
|
||||
endif()
|
||||
@@ -114,7 +114,7 @@ elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64.*|AARCH64.*")
|
||||
endif()
|
||||
|
||||
|
||||
# Similar code is existed in OpenCVConfig.cmake
|
||||
# Similar code exists in OpenCVConfig.cmake
|
||||
if(NOT DEFINED OpenCV_STATIC)
|
||||
# look for global setting
|
||||
if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS)
|
||||
@@ -140,15 +140,13 @@ if(MSVC)
|
||||
set(OpenCV_RUNTIME vc11)
|
||||
elseif(MSVC_VERSION EQUAL 1800)
|
||||
set(OpenCV_RUNTIME vc12)
|
||||
elseif(MSVC_VERSION EQUAL 1900)
|
||||
set(OpenCV_RUNTIME vc14)
|
||||
endif()
|
||||
elseif(MINGW)
|
||||
set(OpenCV_RUNTIME mingw)
|
||||
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
|
||||
OUTPUT_VARIABLE OPENCV_GCC_TARGET_MACHINE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(CMAKE_OPENCV_GCC_TARGET_MACHINE MATCHES "64")
|
||||
set(MINGW64 1)
|
||||
if(MINGW64)
|
||||
set(OpenCV_ARCH x64)
|
||||
else()
|
||||
set(OpenCV_ARCH x86)
|
||||
|
||||
@@ -39,11 +39,11 @@ if(PYTHON_EXECUTABLE)
|
||||
if(NOT ANDROID AND NOT IOS)
|
||||
ocv_check_environment_variables(PYTHON_LIBRARY PYTHON_INCLUDE_DIR)
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
find_host_package(PythonLibs ${PYTHON_VERSION_MAJOR_MINOR})
|
||||
find_package(PythonLibs ${PYTHON_VERSION_MAJOR_MINOR})
|
||||
elseif(CMAKE_VERSION VERSION_GREATER 2.8.8 AND PYTHON_VERSION_FULL)
|
||||
find_host_package(PythonLibs ${PYTHON_VERSION_FULL} EXACT)
|
||||
find_package(PythonLibs ${PYTHON_VERSION_FULL} EXACT)
|
||||
else()
|
||||
find_host_package(PythonLibs ${PYTHON_VERSION_FULL})
|
||||
find_package(PythonLibs ${PYTHON_VERSION_FULL})
|
||||
endif()
|
||||
# cmake 2.4 (at least on Ubuntu 8.04 (hardy)) don't define PYTHONLIBS_FOUND
|
||||
if(NOT PYTHONLIBS_FOUND AND PYTHON_INCLUDE_PATH)
|
||||
|
||||
@@ -63,6 +63,8 @@ if(NOT HAVE_TBB)
|
||||
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc10")
|
||||
elseif(MSVC11)
|
||||
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc11")
|
||||
elseif(MSVC12)
|
||||
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc12")
|
||||
endif()
|
||||
set(TBB_LIB_DIR "${_TBB_LIB_PATH}" CACHE PATH "Full path of TBB library directory")
|
||||
link_directories("${TBB_LIB_DIR}")
|
||||
|
||||
@@ -190,7 +190,7 @@ if(WITH_XIMEA)
|
||||
endif(WITH_XIMEA)
|
||||
|
||||
# --- FFMPEG ---
|
||||
ocv_clear_vars(HAVE_FFMPEG HAVE_FFMPEG_CODEC HAVE_FFMPEG_FORMAT HAVE_FFMPEG_UTIL HAVE_FFMPEG_SWSCALE HAVE_GENTOO_FFMPEG HAVE_FFMPEG_FFMPEG)
|
||||
ocv_clear_vars(HAVE_FFMPEG HAVE_FFMPEG_CODEC HAVE_FFMPEG_FORMAT HAVE_FFMPEG_UTIL HAVE_FFMPEG_SWSCALE HAVE_FFMPEG_RESAMPLE HAVE_GENTOO_FFMPEG HAVE_FFMPEG_FFMPEG)
|
||||
if(WITH_FFMPEG)
|
||||
if(WIN32 AND NOT ARM)
|
||||
include("${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/ffmpeg_version.cmake")
|
||||
@@ -199,6 +199,7 @@ if(WITH_FFMPEG)
|
||||
CHECK_MODULE(libavformat HAVE_FFMPEG_FORMAT)
|
||||
CHECK_MODULE(libavutil HAVE_FFMPEG_UTIL)
|
||||
CHECK_MODULE(libswscale HAVE_FFMPEG_SWSCALE)
|
||||
CHECK_MODULE(libavresample HAVE_FFMPEG_RESAMPLE)
|
||||
|
||||
CHECK_INCLUDE_FILE(libavformat/avformat.h HAVE_GENTOO_FFMPEG)
|
||||
CHECK_INCLUDE_FILE(ffmpeg/avformat.h HAVE_FFMPEG_FFMPEG)
|
||||
|
||||
@@ -25,6 +25,8 @@ if(ANDROID)
|
||||
set( ${VAR} "armeabi" )
|
||||
elseif( " ${TOOLCHAIN_FLAG}" STREQUAL " ARMEABI_V7A" )
|
||||
set( ${VAR} "armeabi-v7a" )
|
||||
elseif( " ${TOOLCHAIN_FLAG}" STREQUAL " ARM64_V8A" )
|
||||
set( ${VAR} "arm64-v8a" )
|
||||
elseif( " ${TOOLCHAIN_FLAG}" STREQUAL " X86" )
|
||||
set( ${VAR} "x86" )
|
||||
elseif( " ${TOOLCHAIN_FLAG}" STREQUAL " MIPS" )
|
||||
@@ -36,7 +38,7 @@ if(ANDROID)
|
||||
endif()
|
||||
|
||||
# setup lists of camera libs
|
||||
foreach(abi ARMEABI ARMEABI_V7A X86 MIPS)
|
||||
foreach(abi ARMEABI ARMEABI_V7A ARM64_V8A X86 MIPS)
|
||||
ANDROID_GET_ABI_RAWNAME(${abi} ndkabi)
|
||||
if(BUILD_ANDROID_CAMERA_WRAPPER)
|
||||
if(ndkabi STREQUAL ANDROID_NDK_ABI_NAME)
|
||||
@@ -46,6 +48,7 @@ if(ANDROID)
|
||||
endif()
|
||||
elseif(HAVE_opencv_androidcamera)
|
||||
set(OPENCV_CAMERA_LIBS_${abi}_CONFIGCMAKE "")
|
||||
# TODO: add prebuild camera libs for arm64-v8a
|
||||
file(GLOB OPENCV_CAMERA_LIBS "${OpenCV_SOURCE_DIR}/3rdparty/lib/${ndkabi}/libnative_camera_r*.so")
|
||||
if(OPENCV_CAMERA_LIBS)
|
||||
list(SORT OPENCV_CAMERA_LIBS)
|
||||
|
||||
@@ -63,22 +63,23 @@ endforeach()
|
||||
# add extra dependencies required for OpenCV
|
||||
if(OpenCV_EXTRA_COMPONENTS)
|
||||
foreach(extra_component ${OpenCV_EXTRA_COMPONENTS})
|
||||
if(TARGET "${extra_component}")
|
||||
get_target_property(extra_component_is_imported "${extra_component}" IMPORTED)
|
||||
if(extra_component_is_imported)
|
||||
get_target_property(extra_component "${extra_component}" LOCATION)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(extra_component MATCHES "^-[lL]")
|
||||
set(libprefix "")
|
||||
set(libname "${extra_component}")
|
||||
if(extra_component MATCHES "^-l")
|
||||
list(APPEND OpenCV_LIB_COMPONENTS_ "${extra_component}")
|
||||
elseif(extra_component MATCHES "[\\/]")
|
||||
get_filename_component(libdir "${extra_component}" PATH)
|
||||
list(APPEND OpenCV_LIB_COMPONENTS_ "-L${libdir}")
|
||||
get_filename_component(libname "${extra_component}" NAME_WE)
|
||||
string(REGEX REPLACE "^lib" "" libname "${libname}")
|
||||
set(libprefix "-l")
|
||||
list(APPEND OpenCV_LIB_COMPONENTS_ "-L${libdir}" "-l${libname}")
|
||||
else()
|
||||
set(libprefix "-l")
|
||||
set(libname "${extra_component}")
|
||||
list(APPEND OpenCV_LIB_COMPONENTS_ "-l${extra_component}")
|
||||
endif()
|
||||
list(APPEND OpenCV_LIB_COMPONENTS_ "${libprefix}${libname}")
|
||||
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
|
||||
+17
-12
@@ -49,6 +49,8 @@ foreach(mod ${OPENCV_MODULES_BUILD} ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MOD
|
||||
if(HAVE_${mod})
|
||||
unset(HAVE_${mod} CACHE)
|
||||
endif()
|
||||
unset(OPENCV_MODULE_${mod}_DEPS CACHE)
|
||||
unset(OPENCV_MODULE_${mod}_DEPS_EXT CACHE)
|
||||
unset(OPENCV_MODULE_${mod}_REQ_DEPS CACHE)
|
||||
unset(OPENCV_MODULE_${mod}_OPT_DEPS CACHE)
|
||||
unset(OPENCV_MODULE_${mod}_PRIVATE_REQ_DEPS CACHE)
|
||||
@@ -488,7 +490,7 @@ macro(ocv_glob_module_sources)
|
||||
|
||||
file(GLOB_RECURSE lib_srcs "src/*.cpp")
|
||||
file(GLOB_RECURSE lib_int_hdrs "src/*.hpp" "src/*.h")
|
||||
file(GLOB lib_hdrs "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h")
|
||||
file(GLOB lib_hdrs "include/opencv2/*.hpp" "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h")
|
||||
file(GLOB lib_hdrs_detail "include/opencv2/${name}/detail/*.hpp" "include/opencv2/${name}/detail/*.h")
|
||||
file(GLOB_RECURSE lib_srcs_apple "src/*.mm")
|
||||
if (APPLE)
|
||||
@@ -629,7 +631,7 @@ macro(ocv_create_module)
|
||||
if(OPENCV_MODULE_${the_module}_HEADERS AND ";${OPENCV_MODULES_PUBLIC};" MATCHES ";${the_module};")
|
||||
foreach(hdr ${OPENCV_MODULE_${the_module}_HEADERS})
|
||||
string(REGEX REPLACE "^.*opencv2/" "opencv2/" hdr2 "${hdr}")
|
||||
if(hdr2 MATCHES "^(opencv2/.*)/[^/]+.h(..)?$")
|
||||
if(hdr2 MATCHES "^(opencv2/?.*)/[^/]+.h(..)?$")
|
||||
install(FILES ${hdr} DESTINATION "${OPENCV_INCLUDE_INSTALL_PATH}/${CMAKE_MATCH_1}" COMPONENT dev)
|
||||
endif()
|
||||
endforeach()
|
||||
@@ -919,25 +921,28 @@ macro(__ocv_track_module_link_dependencies the_module optkind)
|
||||
list(REMOVE_AT __mod_depends 0)
|
||||
if(__dep STREQUAL the_module)
|
||||
set(__has_cycle TRUE)
|
||||
else()#if("${OPENCV_MODULES_BUILD}" MATCHES "(^|;)${__dep}(;|$)")
|
||||
else()
|
||||
ocv_regex_escape(__rdep "${__dep}")
|
||||
if(__resolved_deps MATCHES "(^|;)${__rdep}(;|$)")
|
||||
#all dependencies of this module are already resolved
|
||||
list(APPEND ${the_module}_MODULE_DEPS_${optkind} "${__dep}")
|
||||
elseif(TARGET ${__dep})
|
||||
get_target_property(__module_type ${__dep} TYPE)
|
||||
if(__module_type STREQUAL "STATIC_LIBRARY")
|
||||
if(NOT DEFINED ${__dep}_LIB_DEPENDS_${optkind})
|
||||
ocv_split_libs_list(${__dep}_LIB_DEPENDS ${__dep}_LIB_DEPENDS_DBG ${__dep}_LIB_DEPENDS_OPT)
|
||||
get_target_property(__dep_imported ${__dep} IMPORTED)
|
||||
if(__dep_imported)
|
||||
list(APPEND ${the_module}_EXTRA_DEPS_${optkind} "${__dep}")
|
||||
else()
|
||||
get_target_property(__module_type ${__dep} TYPE)
|
||||
if(__module_type STREQUAL "STATIC_LIBRARY")
|
||||
if(NOT DEFINED ${__dep}_LIB_DEPENDS_${optkind})
|
||||
ocv_split_libs_list(${__dep}_LIB_DEPENDS ${__dep}_LIB_DEPENDS_DBG ${__dep}_LIB_DEPENDS_OPT)
|
||||
endif()
|
||||
list(INSERT __mod_depends 0 ${${__dep}_LIB_DEPENDS_${optkind}} ${__dep})
|
||||
list(APPEND __resolved_deps "${__dep}")
|
||||
endif()
|
||||
list(INSERT __mod_depends 0 ${${__dep}_LIB_DEPENDS_${optkind}} ${__dep})
|
||||
list(APPEND __resolved_deps "${__dep}")
|
||||
endif()
|
||||
else()
|
||||
list(APPEND ${the_module}_EXTRA_DEPS_${optkind} "${__dep}")
|
||||
endif()
|
||||
#else()
|
||||
# get_target_property(__dep_location "${__dep}" LOCATION)
|
||||
endif()
|
||||
endwhile()
|
||||
|
||||
@@ -951,7 +956,7 @@ macro(__ocv_track_module_link_dependencies the_module optkind)
|
||||
list(APPEND ${the_module}_MODULE_DEPS_${optkind} "${the_module}")
|
||||
endif()
|
||||
|
||||
unset(__dep_location)
|
||||
unset(__dep_imported)
|
||||
unset(__mod_depends)
|
||||
unset(__resolved_deps)
|
||||
unset(__has_cycle)
|
||||
|
||||
@@ -25,21 +25,24 @@ set(CPACK_STRIP_FILES 1)
|
||||
|
||||
#arch
|
||||
if(X86)
|
||||
set(CPACK_DEBIAN_ARCHITECTURE "i386")
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386")
|
||||
set(CPACK_RPM_PACKAGE_ARCHITECTURE "i686")
|
||||
elseif(X86_64)
|
||||
set(CPACK_DEBIAN_ARCHITECTURE "amd64")
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
|
||||
set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64")
|
||||
elseif(ARM)
|
||||
set(CPACK_DEBIAN_ARCHITECTURE "armhf")
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "armhf")
|
||||
set(CPACK_RPM_PACKAGE_ARCHITECTURE "armhf")
|
||||
elseif(AARCH64)
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "arm64")
|
||||
set(CPACK_RPM_PACKAGE_ARCHITECTURE "aarch64")
|
||||
else()
|
||||
set(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
|
||||
set(CPACK_RPM_PACKAGE_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
|
||||
endif()
|
||||
|
||||
if(CPACK_GENERATOR STREQUAL "DEB")
|
||||
set(OPENCV_PACKAGE_ARCH_SUFFIX ${CPACK_DEBIAN_ARCHITECTURE})
|
||||
set(OPENCV_PACKAGE_ARCH_SUFFIX ${CPACK_DEBIAN_PACKAGE_ARCHITECTURE})
|
||||
elseif(CPACK_GENERATOR STREQUAL "RPM")
|
||||
set(OPENCV_PACKAGE_ARCH_SUFFIX ${CPACK_RPM_PACKAGE_ARCHITECTURE})
|
||||
else()
|
||||
@@ -104,6 +107,44 @@ if(HAVE_CUDA)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(HAVE_TBB AND NOT BUILD_TBB)
|
||||
if(CPACK_DEB_DEV_PACKAGE_DEPENDS)
|
||||
set(CPACK_DEB_DEV_PACKAGE_DEPENDS "${CPACK_DEB_DEV_PACKAGE_DEPENDS}, libtbb-dev")
|
||||
else()
|
||||
set(CPACK_DEB_DEV_PACKAGE_DEPENDS "libtbb-dev")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(STD_OPENCV_LIBS opencv-data)
|
||||
set(STD_OPENCV_DEV libopencv-dev)
|
||||
|
||||
foreach(module calib3d contrib core features2d flann gpu highgui imgproc legacy
|
||||
ml objdetect ocl photo stitching superres ts video videostab)
|
||||
if(HAVE_opencv_${module})
|
||||
list(APPEND STD_OPENCV_LIBS "libopencv-${module}2.4")
|
||||
list(APPEND STD_OPENCV_DEV "libopencv-${module}-dev")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
string(REPLACE ";" ", " CPACK_COMPONENT_LIBS_CONFLICTS "${STD_OPENCV_LIBS}")
|
||||
string(REPLACE ";" ", " CPACK_COMPONENT_LIBS_PROVIDES "${STD_OPENCV_LIBS}")
|
||||
string(REPLACE ";" ", " CPACK_COMPONENT_LIBS_REPLACES "${STD_OPENCV_LIBS}")
|
||||
|
||||
string(REPLACE ";" ", " CPACK_COMPONENT_DEV_CONFLICTS "${STD_OPENCV_DEV}")
|
||||
string(REPLACE ";" ", " CPACK_COMPONENT_DEV_PROVIDES "${STD_OPENCV_DEV}")
|
||||
string(REPLACE ";" ", " CPACK_COMPONENT_DEV_REPLACES "${STD_OPENCV_DEV}")
|
||||
|
||||
set(CPACK_COMPONENT_PYTHON_CONFLICTS python-opencv)
|
||||
set(CPACK_COMPONENT_PYTHON_PROVIDES python-opencv)
|
||||
set(CPACK_COMPONENT_PYTHON_REPLACES python-opencv)
|
||||
|
||||
set(CPACK_COMPONENT_JAVA_CONFLICTS "libopencv2.4-java, libopencv2.4-jni")
|
||||
set(CPACK_COMPONENT_JAVA_PROVIDES "libopencv2.4-java, libopencv2.4-jni")
|
||||
set(CPACK_COMPONENT_JAVA_REPLACES "libopencv2.4-java, libopencv2.4-jni")
|
||||
|
||||
set(CPACK_COMPONENT_DOCS_CONFLICTS opencv-doc)
|
||||
set(CPACK_COMPONENT_SAMPLES_CONFLICTS opencv-doc)
|
||||
|
||||
if(NOT OPENCV_CUSTOM_PACKAGE_INFO)
|
||||
set(CPACK_COMPONENT_LIBS_DESCRIPTION "Open Computer Vision Library")
|
||||
set(CPACK_DEBIAN_COMPONENT_LIBS_NAME "libopencv")
|
||||
|
||||
+20
-9
@@ -449,18 +449,29 @@ endmacro()
|
||||
|
||||
|
||||
# convert list of paths to libraries names without lib prefix
|
||||
macro(ocv_convert_to_lib_name var)
|
||||
set(__tmp "")
|
||||
function(ocv_convert_to_lib_name var)
|
||||
set(tmp "")
|
||||
foreach(path ${ARGN})
|
||||
get_filename_component(__tmp_name "${path}" NAME_WE)
|
||||
string(REGEX REPLACE "^lib" "" __tmp_name ${__tmp_name})
|
||||
list(APPEND __tmp "${__tmp_name}")
|
||||
get_filename_component(tmp_name "${path}" NAME_WE)
|
||||
string(REGEX REPLACE "^lib" "" tmp_name "${tmp_name}")
|
||||
list(APPEND tmp "${tmp_name}")
|
||||
endforeach()
|
||||
set(${var} ${__tmp})
|
||||
unset(__tmp)
|
||||
unset(__tmp_name)
|
||||
endmacro()
|
||||
set(${var} ${tmp} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# create imported targets for a list of external libraries
|
||||
function(ocv_create_imported_targets var)
|
||||
set(target_list "")
|
||||
|
||||
foreach(library ${ARGN})
|
||||
ocv_convert_to_lib_name(libname "${library}")
|
||||
add_library("opencv_dep_${libname}" UNKNOWN IMPORTED)
|
||||
set_target_properties("opencv_dep_${libname}" PROPERTIES IMPORTED_LOCATION "${library}")
|
||||
list(APPEND target_list "opencv_dep_${libname}")
|
||||
endforeach()
|
||||
|
||||
set("${var}" "${target_list}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# add install command
|
||||
function(ocv_install_target)
|
||||
|
||||
@@ -31,7 +31,16 @@ ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||
endif
|
||||
OPENCV_DYNAMICUDA_MODULE:=@OPENCV_DYNAMICUDA_MODULE_CONFIGMAKE@
|
||||
else
|
||||
OPENCV_DYNAMICUDA_MODULE:=
|
||||
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
|
||||
ifeq ($(OPENCV_HAVE_GPU_MODULE),on)
|
||||
ifneq ($(CUDA_TOOLKIT_DIR),)
|
||||
OPENCV_USE_GPU_MODULE:=on
|
||||
endif
|
||||
endif
|
||||
OPENCV_DYNAMICUDA_MODULE:=@OPENCV_DYNAMICUDA_MODULE_CONFIGMAKE@
|
||||
else
|
||||
OPENCV_DYNAMICUDA_MODULE:=
|
||||
endif
|
||||
endif
|
||||
|
||||
CUDA_RUNTIME_LIBS:=@CUDA_RUNTIME_LIBS_CONFIGMAKE@
|
||||
@@ -56,6 +65,10 @@ else
|
||||
OPENCV_3RDPARTY_COMPONENTS:=@OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE@
|
||||
OPENCV_EXTRA_COMPONENTS:=@OPENCV_EXTRA_COMPONENTS_CONFIGMAKE@
|
||||
endif
|
||||
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
|
||||
OPENCV_3RDPARTY_COMPONENTS:=@OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE@
|
||||
OPENCV_EXTRA_COMPONENTS:=@OPENCV_EXTRA_COMPONENTS_CONFIGMAKE@
|
||||
endif
|
||||
ifeq ($(TARGET_ARCH_ABI),x86)
|
||||
OPENCV_3RDPARTY_COMPONENTS:=@OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE@
|
||||
OPENCV_EXTRA_COMPONENTS:=@OPENCV_EXTRA_COMPONENTS_CONFIGMAKE@
|
||||
@@ -77,6 +90,9 @@ ifeq ($(OPENCV_CAMERA_MODULES),on)
|
||||
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||
OPENCV_CAMERA_MODULES:=@OPENCV_CAMERA_LIBS_ARMEABI_V7A_CONFIGCMAKE@
|
||||
endif
|
||||
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
|
||||
OPENCV_CAMERA_MODULES:=@OPENCV_CAMERA_LIBS_ARM64_V8A_CONFIGCMAKE@
|
||||
endif
|
||||
ifeq ($(TARGET_ARCH_ABI),x86)
|
||||
OPENCV_CAMERA_MODULES:=@OPENCV_CAMERA_LIBS_X86_CONFIGCMAKE@
|
||||
endif
|
||||
@@ -101,10 +117,18 @@ define add_opencv_module
|
||||
include $(PREBUILT_$(OPENCV_LIB_TYPE)_LIBRARY)
|
||||
endef
|
||||
|
||||
ifndef CUDA_LIBS_DIR
|
||||
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
|
||||
CUDA_LIBS_DIR := $(CUDA_TOOLKIT_DIR)/targets/aarch64-linux-androideabi/lib
|
||||
else
|
||||
CUDA_LIBS_DIR := $(CUDA_TOOLKIT_DIR)/targets/armv7-linux-androideabi/lib
|
||||
endif
|
||||
endif
|
||||
|
||||
define add_cuda_module
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE:=$1
|
||||
LOCAL_SRC_FILES:=$(CUDA_TOOLKIT_DIR)/targets/armv7-linux-androideabi/lib/lib$1.so
|
||||
LOCAL_SRC_FILES:=$(CUDA_LIBS_DIR)/lib$(1:opencv_dep_%=%).so
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
endef
|
||||
|
||||
@@ -202,7 +226,8 @@ ifeq ($(OPENCV_USE_GPU_MODULE),on)
|
||||
ifeq ($(INSTALL_CUDA_LIBRARIES),on)
|
||||
LOCAL_SHARED_LIBRARIES += $(foreach mod, $(CUDA_RUNTIME_LIBS), $(mod))
|
||||
else
|
||||
LOCAL_LDLIBS += -L$(CUDA_TOOLKIT_DIR)/targets/armv7-linux-androideabi/lib $(foreach lib, $(CUDA_RUNTIME_LIBS), -l$(lib))
|
||||
LOCAL_LDLIBS += -L$(CUDA_LIBS_DIR) \
|
||||
$(foreach lib, $(CUDA_RUNTIME_LIBS), -l$(lib:opencv_dep_%=%))
|
||||
endif
|
||||
LOCAL_STATIC_LIBRARIES+=libopencv_gpu
|
||||
endif
|
||||
|
||||
@@ -234,55 +234,55 @@ endif()
|
||||
foreach(__opttype OPT DBG)
|
||||
SET(OpenCV_LIBS_${__opttype} "${OpenCV_LIBS}")
|
||||
SET(OpenCV_EXTRA_LIBS_${__opttype} "")
|
||||
|
||||
# CUDA
|
||||
if(OpenCV_CUDA_VERSION)
|
||||
if(NOT CUDA_FOUND)
|
||||
find_host_package(CUDA ${OpenCV_CUDA_VERSION} EXACT REQUIRED)
|
||||
else()
|
||||
if(NOT CUDA_VERSION_STRING VERSION_EQUAL OpenCV_CUDA_VERSION)
|
||||
message(FATAL_ERROR "OpenCV static library was compiled with CUDA ${OpenCV_CUDA_VERSION} support. Please, use the same version or rebuild OpenCV with CUDA ${CUDA_VERSION_STRING}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(OpenCV_CUDA_LIBS_ABSPATH ${CUDA_LIBRARIES})
|
||||
|
||||
if(${CUDA_VERSION} VERSION_LESS "5.5")
|
||||
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_npp_LIBRARY})
|
||||
else()
|
||||
find_cuda_helper_libs(nppc)
|
||||
find_cuda_helper_libs(nppi)
|
||||
find_cuda_helper_libs(npps)
|
||||
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_nppc_LIBRARY} ${CUDA_nppi_LIBRARY} ${CUDA_npps_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(OpenCV_USE_CUBLAS)
|
||||
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_CUBLAS_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(OpenCV_USE_CUFFT)
|
||||
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_CUFFT_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(OpenCV_USE_NVCUVID)
|
||||
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_nvcuvid_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_nvcuvenc_LIBRARIES})
|
||||
endif()
|
||||
|
||||
set(OpenCV_CUDA_LIBS_RELPATH "")
|
||||
foreach(l ${OpenCV_CUDA_LIBS_ABSPATH})
|
||||
get_filename_component(_tmp ${l} PATH)
|
||||
list(APPEND OpenCV_CUDA_LIBS_RELPATH ${_tmp})
|
||||
endforeach()
|
||||
|
||||
list(REMOVE_DUPLICATES OpenCV_CUDA_LIBS_RELPATH)
|
||||
link_directories(${OpenCV_CUDA_LIBS_RELPATH})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Configure CUDA targets
|
||||
if(OpenCV_CUDA_VERSION)
|
||||
if(NOT CUDA_FOUND)
|
||||
find_host_package(CUDA ${OpenCV_CUDA_VERSION} EXACT REQUIRED)
|
||||
else()
|
||||
if(NOT CUDA_VERSION_STRING VERSION_EQUAL OpenCV_CUDA_VERSION)
|
||||
message(FATAL_ERROR "OpenCV static library was compiled with CUDA ${OpenCV_CUDA_VERSION} support. Please, use the same version or rebuild OpenCV with CUDA ${CUDA_VERSION_STRING}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(OpenCV_CUDA_LIBS_ABSPATH ${CUDA_LIBRARIES})
|
||||
|
||||
if(${CUDA_VERSION} VERSION_LESS "5.5")
|
||||
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_npp_LIBRARY})
|
||||
else()
|
||||
find_cuda_helper_libs(nppc)
|
||||
find_cuda_helper_libs(nppi)
|
||||
find_cuda_helper_libs(npps)
|
||||
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_nppc_LIBRARY} ${CUDA_nppi_LIBRARY} ${CUDA_npps_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(OpenCV_USE_CUBLAS)
|
||||
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_CUBLAS_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(OpenCV_USE_CUFFT)
|
||||
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_CUFFT_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(OpenCV_USE_NVCUVID)
|
||||
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_nvcuvid_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_nvcuvenc_LIBRARIES})
|
||||
endif()
|
||||
|
||||
foreach(l ${OpenCV_CUDA_LIBS_ABSPATH})
|
||||
get_filename_component(_tmp "${l}" NAME_WE)
|
||||
string(REGEX REPLACE "^lib" "" _tmp "${_tmp}")
|
||||
if(NOT TARGET "opencv_dep_${_tmp}") # protect against repeated inclusions
|
||||
add_library("opencv_dep_${_tmp}" UNKNOWN IMPORTED)
|
||||
set_target_properties("opencv_dep_${_tmp}" PROPERTIES IMPORTED_LOCATION "${l}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# ==============================================================
|
||||
# Android camera helper macro
|
||||
# ==============================================================
|
||||
|
||||
@@ -55,6 +55,15 @@ OPENCV_TEST_PATH=@CMAKE_INSTALL_PREFIX@/@OPENCV_TEST_INSTALL_PATH@
|
||||
OPENCV_PYTHON_TESTS=@OPENCV_PYTHON_TESTS_LIST@
|
||||
export OPENCV_TEST_DATA_PATH=@CMAKE_INSTALL_PREFIX@/share/OpenCV/testdata
|
||||
|
||||
CUR_DIR=`pwd`
|
||||
if [ -d "$CUR_DIR" -a -w "$CUR_DIR" ]; then
|
||||
echo "${TEXT_CYAN}CUR_DIR : $CUR_DIR${TEXT_RESET}"
|
||||
else
|
||||
echo "${TEXT_RED}Error: Do not have permissions to write to $CUR_DIR${TEXT_RESET}"
|
||||
echo "${TEXT_RED}Please run the script from directory with write access${TEXT_RESET}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run tests
|
||||
|
||||
SUMMARY_STATUS=0
|
||||
@@ -64,9 +73,8 @@ PASSED_TESTS=""
|
||||
for t in "$OPENCV_TEST_PATH/"opencv_test_* "$OPENCV_TEST_PATH/"opencv_perf_*;
|
||||
do
|
||||
test_name=`basename "$t"`
|
||||
report="$test_name-`date --rfc-3339=date`.xml"
|
||||
|
||||
cmd="$t --perf_min_samples=1 --perf_force_samples=1 --gtest_output=xml:\"$report\""
|
||||
cmd="$t --perf_min_samples=1 --perf_force_samples=1 --gtest_output=xml:$test_name.xml"
|
||||
|
||||
seg_reg="s/^/${TEXT_CYAN}[$test_name]${TEXT_RESET} /" # append test name
|
||||
if [ $COLOR_OUTPUT -eq 1 ]; then
|
||||
@@ -79,7 +87,7 @@ do
|
||||
fi
|
||||
|
||||
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RUN : $cmd"
|
||||
$cmd | sed -r "$seg_reg"
|
||||
eval "$cmd" | tee "$test_name.log" | sed -r "$seg_reg"
|
||||
ret=${PIPESTATUS[0]}
|
||||
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RETURN_CODE : $ret"
|
||||
|
||||
@@ -98,14 +106,13 @@ done
|
||||
for t in $OPENCV_PYTHON_TESTS;
|
||||
do
|
||||
test_name=`basename "$t"`
|
||||
report="$test_name-`date --rfc-3339=date`.xml"
|
||||
|
||||
cmd="py.test --junitxml $report \"$OPENCV_TEST_PATH\"/$t"
|
||||
cmd="py.test --junitxml $test_name.xml \"$OPENCV_TEST_PATH\"/$t"
|
||||
|
||||
seg_reg="s/^/${TEXT_CYAN}[$test_name]${TEXT_RESET} /" # append test name
|
||||
|
||||
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RUN : $cmd"
|
||||
eval "$cmd" | sed -r "$seg_reg"
|
||||
eval "$cmd" | tee "$test_name.log" | sed -r "$seg_reg"
|
||||
|
||||
ret=${PIPESTATUS[0]}
|
||||
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RETURN_CODE : $ret"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -47,7 +47,7 @@
|
||||
<opencv_storage>
|
||||
<cascade type_id="opencv-cascade-classifier"><stageType>BOOST</stageType>
|
||||
<featureType>HAAR</featureType>
|
||||
<height>19</height>
|
||||
<height>18</height>
|
||||
<width>36</width>
|
||||
<stageParams>
|
||||
<maxWeakCount>53</maxWeakCount></stageParams>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
function insertIframe (elementId, iframeSrc)
|
||||
{
|
||||
var iframe;
|
||||
if (document.createElement && (iframe = document.createElement('iframe')))
|
||||
{
|
||||
iframe.src = unescape(iframeSrc);
|
||||
iframe.width = "100%";
|
||||
iframe.height = "511px";
|
||||
var element = document.getElementById(elementId);
|
||||
element.parentNode.replaceChild(iframe, element);
|
||||
}
|
||||
}
|
||||
Vendored
-1
@@ -11,7 +11,6 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
{%- endblock %}
|
||||
{% set script_files = script_files + [pathto("_static/insertIframe.js", 1)] %}
|
||||
{%- set reldelim1 = reldelim1 is not defined and ' »' or reldelim1 %}
|
||||
{%- set reldelim2 = reldelim2 is not defined and ' |' or reldelim2 %}
|
||||
{%- set render_sidebar = (not embedded) and (not theme_nosidebar|tobool) and
|
||||
|
||||
+1
-1
@@ -132,7 +132,7 @@ html_logo = 'opencv-logo-white.png'
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
#html_static_path = []
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""gen_pattern.py
|
||||
To run:
|
||||
-c 10 -r 12 -o out.svg
|
||||
-T type of pattern, circles, acircles, checkerboard
|
||||
-s --square_size size of squares in pattern
|
||||
-u --units mm, inches, px, m
|
||||
-w page width in units
|
||||
-h page height in units
|
||||
Usage example:
|
||||
python gen_pattern.py -o out.svg -r 11 -c 8 -T circles -s 20.0 -R 5.0 -u mm -w 216 -h 279
|
||||
|
||||
-o, --output - output file (default out.svg)
|
||||
-r, --rows - pattern rows (default 11)
|
||||
-c, --columns - pattern columns (default 8)
|
||||
-T, --type - type of pattern, circles, acircles, checkerboard (default circles)
|
||||
-s, --square_size - size of squares in pattern (default 20.0)
|
||||
-R, --radius_rate - circles_radius = square_size/radius_rate (default 5.0)
|
||||
-u, --units - mm, inches, px, m (default mm)
|
||||
-w, --page_width - page width in units (default 216)
|
||||
-h, --page_height - page height in units (default 279)
|
||||
-H, --help - show help
|
||||
"""
|
||||
|
||||
from svgfig import *
|
||||
@@ -16,18 +22,20 @@ import sys
|
||||
import getopt
|
||||
|
||||
class PatternMaker:
|
||||
def __init__(self, cols,rows,output,units,square_size,page_width,page_height):
|
||||
def __init__(self, cols,rows,output,units,square_size,radius_rate,page_width,page_height):
|
||||
self.cols = cols
|
||||
self.rows = rows
|
||||
self.output = output
|
||||
self.units = units
|
||||
self.square_size = square_size
|
||||
self.radius_rate = radius_rate
|
||||
self.width = page_width
|
||||
self.height = page_height
|
||||
self.g = SVG("g") # the svg group container
|
||||
|
||||
def makeCirclesPattern(self):
|
||||
spacing = self.square_size
|
||||
r = spacing / 5.0 #radius is a 5th of the spacing TODO parameterize
|
||||
r = spacing / self.radius_rate
|
||||
for x in range(1,self.cols+1):
|
||||
for y in range(1,self.rows+1):
|
||||
dot = SVG("circle", cx=x * spacing, cy=y * spacing, r=r, fill="black")
|
||||
@@ -35,7 +43,7 @@ class PatternMaker:
|
||||
|
||||
def makeACirclesPattern(self):
|
||||
spacing = self.square_size
|
||||
r = spacing / 5.0
|
||||
r = spacing / self.radius_rate
|
||||
for i in range(0,self.rows):
|
||||
for j in range(0,self.cols):
|
||||
dot = SVG("circle", cx= ((j*2 + i%2)*spacing) + spacing, cy=self.height - (i * spacing + spacing), r=r, fill="black")
|
||||
@@ -43,37 +51,23 @@ class PatternMaker:
|
||||
|
||||
def makeCheckerboardPattern(self):
|
||||
spacing = self.square_size
|
||||
r = spacing / 5.0
|
||||
for x in range(1,self.cols+1):
|
||||
for y in range(1,self.rows+1):
|
||||
#TODO make a checkerboard pattern
|
||||
dot = SVG("circle", cx=x * spacing, cy=y * spacing, r=r, fill="black")
|
||||
self.g.append(dot)
|
||||
if x%2 == y%2:
|
||||
dot = SVG("rect", x=x * spacing, y=y * spacing, width=spacing, height=spacing, stroke_width="0", fill="black")
|
||||
self.g.append(dot)
|
||||
|
||||
def save(self):
|
||||
c = canvas(self.g,width="%d%s"%(self.width,self.units),height="%d%s"%(self.height,self.units),viewBox="0 0 %d %d"%(self.width,self.height))
|
||||
c.inkview(self.output)
|
||||
|
||||
def makePattern(cols,rows,output,p_type,units,square_size,page_width,page_height):
|
||||
width = page_width
|
||||
spacing = square_size
|
||||
height = page_height
|
||||
r = spacing / 5.0
|
||||
g = SVG("g") # the svg group container
|
||||
for x in range(1,cols+1):
|
||||
for y in range(1,rows+1):
|
||||
if "circle" in p_type:
|
||||
dot = SVG("circle", cx=x * spacing, cy=y * spacing, r=r, fill="black")
|
||||
g.append(dot)
|
||||
c = canvas(g,width="%d%s"%(width,units),height="%d%s"%(height,units),viewBox="0 0 %d %d"%(width,height))
|
||||
c.inkview(output)
|
||||
|
||||
|
||||
def main():
|
||||
# parse command line options, TODO use argparse for better doc
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "ho:c:r:T:u:s:w:h:", ["help","output","columns","rows",
|
||||
"type","units","square_size","page_width",
|
||||
"page_height"])
|
||||
opts, args = getopt.getopt(sys.argv[1:], "Ho:c:r:T:u:s:R:w:h:", ["help","output=","columns=","rows=",
|
||||
"type=","units=","square_size=","radius_rate=",
|
||||
"page_width=","page_height="])
|
||||
except getopt.error, msg:
|
||||
print msg
|
||||
print "for help use --help"
|
||||
@@ -84,11 +78,12 @@ def main():
|
||||
p_type = "circles"
|
||||
units = "mm"
|
||||
square_size = 20.0
|
||||
radius_rate = 5.0
|
||||
page_width = 216 #8.5 inches
|
||||
page_height = 279 #11 inches
|
||||
# process options
|
||||
for o, a in opts:
|
||||
if o in ("-h", "--help"):
|
||||
if o in ("-H", "--help"):
|
||||
print __doc__
|
||||
sys.exit(0)
|
||||
elif o in ("-r", "--rows"):
|
||||
@@ -103,11 +98,13 @@ def main():
|
||||
units = a
|
||||
elif o in ("-s", "--square_size"):
|
||||
square_size = float(a)
|
||||
elif o in ("-R", "--radius_rate"):
|
||||
radius_rate = float(a)
|
||||
elif o in ("-w", "--page_width"):
|
||||
page_width = float(a)
|
||||
elif o in ("-h", "--page_height"):
|
||||
page_height = float(a)
|
||||
pm = PatternMaker(columns,rows,output,units,square_size,page_width,page_height)
|
||||
pm = PatternMaker(columns,rows,output,units,square_size,radius_rate,page_width,page_height)
|
||||
#dict for easy lookup of pattern type
|
||||
mp = {"circles":pm.makeCirclesPattern,"acircles":pm.makeACirclesPattern,"checkerboard":pm.makeCheckerboardPattern}
|
||||
mp[p_type]()
|
||||
|
||||
@@ -193,7 +193,7 @@ In the main program, before processing, first check input command parameters. He
|
||||
{
|
||||
std::cout<<"RetinaDemo: processing image "<<argv[2]<<std::endl;
|
||||
// image processing case
|
||||
inputFrame = cv::imread(std::string(argv[2]), 1); // load image in RGB mode
|
||||
inputFrame = cv::imread(std::string(argv[2]), 1); // load image in BGR color mode
|
||||
}else
|
||||
if (!strcmp(inputMediaType.c_str(), "-video"))
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ From our previous tutorial, we know already a bit of *Pixel operators*. An inter
|
||||
|
||||
g(x) = (1 - \alpha)f_{0}(x) + \alpha f_{1}(x)
|
||||
|
||||
By varying :math:`\alpha` from :math:`0 \rightarrow 1` this operator can be used to perform a temporal *cross-disolve* between two images or videos, as seen in slide shows and film productions (cool, eh?)
|
||||
By varying :math:`\alpha` from :math:`0 \rightarrow 1` this operator can be used to perform a temporal *cross-dissolve* between two images or videos, as seen in slide shows and film productions (cool, eh?)
|
||||
|
||||
Code
|
||||
=====
|
||||
|
||||
@@ -44,14 +44,14 @@ or
|
||||
Scalar
|
||||
-------
|
||||
* Represents a 4-element vector. The type Scalar is widely used in OpenCV for passing pixel values.
|
||||
* In this tutorial, we will use it extensively to represent RGB color values (3 parameters). It is not necessary to define the last argument if it is not going to be used.
|
||||
* In this tutorial, we will use it extensively to represent BGR color values (3 parameters). It is not necessary to define the last argument if it is not going to be used.
|
||||
* Let's see an example, if we are asked for a color argument and we give:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
Scalar( a, b, c )
|
||||
|
||||
We would be defining a RGB color such as: *Red = c*, *Green = b* and *Blue = a*
|
||||
We would be defining a BGR color such as: *Blue = a*, *Green = b* and *Red = c*
|
||||
|
||||
|
||||
Code
|
||||
@@ -135,7 +135,7 @@ Explanation
|
||||
|
||||
* Draw a line from Point **start** to Point **end**
|
||||
* The line is displayed in the image **img**
|
||||
* The line color is defined by **Scalar( 0, 0, 0)** which is the RGB value correspondent to **Black**
|
||||
* The line color is defined by **Scalar( 0, 0, 0)** which is the BGR value correspondent to **Black**
|
||||
* The line thickness is set to **thickness** (in this case 2)
|
||||
* The line is a 8-connected one (**lineType** = 8)
|
||||
|
||||
@@ -167,7 +167,7 @@ Explanation
|
||||
* The ellipse center is located in the point **(w/2.0, w/2.0)** and is enclosed in a box of size **(w/4.0, w/16.0)**
|
||||
* The ellipse is rotated **angle** degrees
|
||||
* The ellipse extends an arc between **0** and **360** degrees
|
||||
* The color of the figure will be **Scalar( 255, 255, 0)** which means blue in RGB value.
|
||||
* The color of the figure will be **Scalar( 255, 0, 0)** which means blue in BGR value.
|
||||
* The ellipse's **thickness** is 2.
|
||||
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ Explanation
|
||||
|
||||
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:
|
||||
#. 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 BGR images, we will have three values per pixel (B, G and R), so we will also access them separately. Here is the piece of code:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ You can download the full source code :download:`here <../../../../samples/cpp/t
|
||||
|
||||
how_to_scan_images imageName.jpg intValueToReduce [G]
|
||||
|
||||
The final argument is optional. If given the image will be loaded in gray scale format, otherwise the RGB color way is used. The first thing is to calculate the lookup table.
|
||||
The final argument is optional. If given the image will be loaded in gray scale format, otherwise the BGR color way is used. The first thing is to calculate the lookup table.
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp
|
||||
:language: cpp
|
||||
@@ -76,7 +76,7 @@ As you could already read in my :ref:`matTheBasicImageContainer` tutorial the si
|
||||
Row n & \tabItG{n,0} & \tabItG{n,1} & \tabItG{n,...} & \tabItG{n, m} \\
|
||||
\end{tabular}
|
||||
|
||||
For multichannel images the columns contain as many sub columns as the number of channels. For example in case of an RGB color system:
|
||||
For multichannel images the columns contain as many sub columns as the number of channels. For example in case of an BGR color system:
|
||||
|
||||
.. math::
|
||||
|
||||
@@ -89,7 +89,7 @@ For multichannel images the columns contain as many sub columns as the number of
|
||||
Row n & \tabIt{n,0} & \tabIt{n,1} & \tabIt{n,...} & \tabIt{n, m} \\
|
||||
\end{tabular}
|
||||
|
||||
Note that the order of the channels is inverse: BGR instead of RGB. Because in many cases the memory is large enough to store the rows in a successive fashion the rows may follow one after another, creating a single long row. Because everything is in a single place following one after another this may help to speed up the scanning process. We can use the :basicstructures:`isContinuous() <mat-iscontinuous>` function to *ask* the matrix if this is the case. Continue on to the next section to find an example.
|
||||
Because in many cases the memory is large enough to store the rows in a successive fashion the rows may follow one after another, creating a single long row. Because everything is in a single place following one after another this may help to speed up the scanning process. We can use the :basicstructures:`isContinuous() <mat-iscontinuous>` function to *ask* the matrix if this is the case. Continue on to the next section to find an example.
|
||||
|
||||
The efficient way
|
||||
=================
|
||||
|
||||
+1
-1
@@ -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 BGR 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:
|
||||
|
||||
|
||||
@@ -76,12 +76,12 @@ 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.
|
||||
* RGB is the most common as our eyes use something similar, but keep in mind that the OpenCV display system uses BGR colors.
|
||||
* 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 value component, making your algorithm less sensitive 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 color components has its own valid domains. This brings us 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 the case of three components (such as RGB) this already gives 16 million representable colors. 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.
|
||||
Each of the color components has its own valid domains. This brings us 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 the case of three components (such as BGR) this already gives 16 million representable colors. 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.
|
||||
|
||||
Creating a *Mat* object explicitly
|
||||
==================================
|
||||
|
||||
@@ -116,7 +116,7 @@ Explanation
|
||||
pt1.x = rng.uniform( x_1, x_2 );
|
||||
pt1.y = rng.uniform( y_1, y_2 );
|
||||
|
||||
* We know that **rng** is a *Random number generator* object. In the code above we are calling **rng.uniform(a,b)**. This generates a radombly uniformed distribution between the values **a** and **b** (inclusive in **a**, exclusive in **b**).
|
||||
* We know that **rng** is a *Random number generator* object. In the code above we are calling **rng.uniform(a,b)**. This generates a randomly uniformed distribution between the values **a** and **b** (inclusive in **a**, exclusive in **b**).
|
||||
|
||||
* From the explanation above, we deduce that the extremes *pt1* and *pt2* will be random values, so the lines positions will be quite impredictable, giving a nice visual effect (check out the Result section below).
|
||||
|
||||
@@ -138,7 +138,7 @@ Explanation
|
||||
|
||||
As we can see, the return value is an *Scalar* with 3 randomly initialized values, which are used as the *R*, *G* and *B* parameters for the line color. Hence, the color of the lines will be random too!
|
||||
|
||||
#. The explanation above applies for the other functions generating circles, ellipses, polygones, etc. The parameters such as *center* and *vertices* are also generated randomly.
|
||||
#. The explanation above applies for the other functions generating circles, ellipses, polygons, etc. The parameters such as *center* and *vertices* are also generated randomly.
|
||||
|
||||
#. Before finishing, we also should take a look at the functions *Display_Random_Text* and *Displaying_Big_End*, since they both have a few interesting features:
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ Whenever you work with video feeds you may eventually want to save your image pr
|
||||
+ What type of video files you can create with OpenCV
|
||||
+ How to extract a given color channel from a video
|
||||
|
||||
As a simple demonstration I'll just extract one of the RGB color channels of an input video file into a new video. You can control the flow of the application from its console line arguments:
|
||||
As a simple demonstration I'll just extract one of the BGR color channels of an input video file into a new video. You can control the flow of the application from its console line arguments:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
@@ -111,7 +111,7 @@ Afterwards, you use the :hgvideo:`isOpened() <videowriter-isopened>` function to
|
||||
outputVideo.write(res); //or
|
||||
outputVideo << res;
|
||||
|
||||
Extracting a color channel from an RGB image means to set to zero the RGB values of the other channels. You can either do this with image scanning operations or by using the split and merge operations. You first split the channels up into different images, set the other channels to zero images of the same size and type and finally merge them back:
|
||||
Extracting a color channel from an BGR image means to set to zero the BGR values of the other channels. You can either do this with image scanning operations or by using the split and merge operations. You first split the channels up into different images, set the other channels to zero images of the same size and type and finally merge them back:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ Explanation
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* Load an image (can be RGB or grayscale)
|
||||
* Load an image (can be BGR or grayscale)
|
||||
* Create two windows (one for dilation output, the other for erosion)
|
||||
* Create a set of 02 Trackbars for each operation:
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ Code
|
||||
Explanation
|
||||
===========
|
||||
|
||||
#. Declare variables such as the matrices to store the base image and the two other images to compare ( RGB and HSV )
|
||||
#. Declare variables such as the matrices to store the base image and the two other images to compare ( BGR and HSV )
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ How does it work?
|
||||
|
||||
We consider only points such that :math:`r > 0` and :math:`0< \theta < 2 \pi`.
|
||||
|
||||
#. We can do the same operation above for all the points in an image. If the curves of two different points intersect in the plane :math:`\theta` - :math:`r`, that means that both points belong to a same line. For instance, following with the example above and drawing the plot for two more points: :math:`x_{1} = 9`, :math:`y_{1} = 4` and :math:`x_{2} = 12`, :math:`y_{2} = 3`, we get:
|
||||
#. We can do the same operation above for all the points in an image. If the curves of two different points intersect in the plane :math:`\theta` - :math:`r`, that means that both points belong to a same line. For instance, following with the example above and drawing the plot for two more points: :math:`x_{1} = 4`, :math:`y_{1} = 9` and :math:`x_{2} = 12`, :math:`y_{2} = 3`, we get:
|
||||
|
||||
.. image:: images/Hough_Lines_Tutorial_Theory_2.jpg
|
||||
:alt: Polar plot of the family of lines for three points
|
||||
|
||||
@@ -88,7 +88,7 @@ Code
|
||||
GaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT );
|
||||
|
||||
/// Convert the image to grayscale
|
||||
cvtColor( src, src_gray, CV_RGB2GRAY );
|
||||
cvtColor( src, src_gray, CV_BGR2GRAY );
|
||||
|
||||
/// Create window
|
||||
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
|
||||
@@ -141,7 +141,7 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
cvtColor( src, src_gray, CV_RGB2GRAY );
|
||||
cvtColor( src, src_gray, CV_BGR2GRAY );
|
||||
|
||||
#. Apply the Laplacian operator to the grayscale image:
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ Code
|
||||
GaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT );
|
||||
|
||||
/// Convert it to gray
|
||||
cvtColor( src, src_gray, CV_RGB2GRAY );
|
||||
cvtColor( src, src_gray, CV_BGR2GRAY );
|
||||
|
||||
/// Create window
|
||||
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
|
||||
@@ -217,7 +217,7 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
cvtColor( src, src_gray, CV_RGB2GRAY );
|
||||
cvtColor( src, src_gray, CV_BGR2GRAY );
|
||||
|
||||
#. Second, we calculate the "*derivatives*" in *x* and *y* directions. For this, we use the function :sobel:`Sobel <>` as shown below:
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ The tutorial code's is shown lines below. You can also download it from `here <h
|
||||
src = imread( argv[1], 1 );
|
||||
|
||||
/// Convert the image to Gray
|
||||
cvtColor( src, src_gray, CV_RGB2GRAY );
|
||||
cvtColor( src, src_gray, CV_BGR2GRAY );
|
||||
|
||||
/// Create a window to display results
|
||||
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
|
||||
@@ -221,14 +221,14 @@ Explanation
|
||||
|
||||
#. Let's check the general structure of the program:
|
||||
|
||||
* Load an image. If it is RGB we convert it to Grayscale. For this, remember that we can use the function :cvt_color:`cvtColor <>`:
|
||||
* Load an image. If it is BGR we convert it to Grayscale. For this, remember that we can use the function :cvt_color:`cvtColor <>`:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
src = imread( argv[1], 1 );
|
||||
|
||||
/// Convert the image to Gray
|
||||
cvtColor( src, src_gray, CV_RGB2GRAY );
|
||||
cvtColor( src, src_gray, CV_BGR2GRAY );
|
||||
|
||||
|
||||
* Create a window to display the result
|
||||
|
||||
@@ -68,7 +68,7 @@ Now we call the :imread:`imread <>` function which loads the image name specifie
|
||||
|
||||
+ CV_LOAD_IMAGE_UNCHANGED (<0) loads the image as is (including the alpha channel if present)
|
||||
+ CV_LOAD_IMAGE_GRAYSCALE ( 0) loads the image as an intensity one
|
||||
+ CV_LOAD_IMAGE_COLOR (>0) loads the image in the RGB format
|
||||
+ CV_LOAD_IMAGE_COLOR (>0) loads the image in the BGR format
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/introduction/display_image/display_image.cpp
|
||||
:language: cpp
|
||||
|
||||
@@ -63,7 +63,7 @@ Here it is:
|
||||
Explanation
|
||||
============
|
||||
|
||||
#. We begin by loading an image using :readwriteimagevideo:`imread <imread>`, located in the path given by *imageName*. For this example, assume you are loading a RGB image.
|
||||
#. We begin by loading an image using :readwriteimagevideo:`imread <imread>`, located in the path given by *imageName*. For this example, assume you are loading a BGR image.
|
||||
|
||||
#. Now we are going to convert our image from BGR to Grayscale format. OpenCV has a really nice function to do this kind of transformations:
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ Senz3D and Intel Perceptual Computing SDK
|
||||
Using Creative Senz3D and other Intel Perceptual Computing SDK compatible depth sensors
|
||||
=======================================================================================
|
||||
|
||||
Depth sensors compatible with Intel Perceptual Computing SDK are supported through ``VideoCapture`` class. Depth map, RGB image and some other formats of output can be retrieved by using familiar interface of ``VideoCapture``.
|
||||
Depth sensors compatible with Intel Perceptual Computing SDK are supported through ``VideoCapture`` class. Depth map, BGR image and some other formats of output can be retrieved by using familiar interface of ``VideoCapture``.
|
||||
|
||||
In order to use depth sensor with OpenCV you should do the following preliminary steps:
|
||||
|
||||
@@ -28,7 +28,7 @@ VideoCapture can retrieve the following data:
|
||||
* ``CV_CAP_INTELPERC_UVDEPTH_MAP`` - each pixel contains two 32-bit floating point values in the range of 0-1, representing the mapping of depth coordinates to the color coordinates. (CV_32FC2)
|
||||
* ``CV_CAP_INTELPERC_IR_MAP`` - each pixel is a 16-bit integer. The value indicates the intensity of the reflected laser beam. (CV_16UC1)
|
||||
#.
|
||||
data given from RGB image generator:
|
||||
data given from BGR image generator:
|
||||
* ``CV_CAP_INTELPERC_IMAGE`` - color image. (CV_8UC3)
|
||||
|
||||
In order to get depth map from depth sensor use ``VideoCapture::operator >>``, e. g. ::
|
||||
@@ -76,4 +76,4 @@ Since two types of sensor's data generators are supported (image generator and d
|
||||
|
||||
For more information please refer to the example of usage intelperc_capture.cpp_ in ``opencv/samples/cpp`` folder.
|
||||
|
||||
.. _intelperc_capture.cpp: https://github.com/Itseez/opencv/tree/master/samples/cpp/intelperc_capture.cpp
|
||||
.. _intelperc_capture.cpp: https://github.com/Itseez/opencv/tree/master/samples/cpp/intelperc_capture.cpp
|
||||
|
||||
@@ -7,7 +7,7 @@ Kinect and OpenNI
|
||||
Using Kinect and other OpenNI compatible depth sensors
|
||||
======================================================
|
||||
|
||||
Depth sensors compatible with OpenNI (Kinect, XtionPRO, ...) are supported through ``VideoCapture`` class. Depth map, RGB image and some other formats of output can be retrieved by using familiar interface of ``VideoCapture``.
|
||||
Depth sensors compatible with OpenNI (Kinect, XtionPRO, ...) are supported through ``VideoCapture`` class. Depth map, BGR image and some other formats of output can be retrieved by using familiar interface of ``VideoCapture``.
|
||||
|
||||
In order to use depth sensor with OpenCV you should do the following preliminary steps:
|
||||
|
||||
@@ -47,7 +47,7 @@ VideoCapture can retrieve the following data:
|
||||
* ``CV_CAP_OPENNI_DISPARITY_MAP_32F`` - disparity in pixels (CV_32FC1)
|
||||
* ``CV_CAP_OPENNI_VALID_DEPTH_MASK`` - mask of valid pixels (not ocluded, not shaded etc.) (CV_8UC1)
|
||||
#.
|
||||
data given from RGB image generator:
|
||||
data given from BGR image generator:
|
||||
* ``CV_CAP_OPENNI_BGR_IMAGE`` - color image (CV_8UC3)
|
||||
* ``CV_CAP_OPENNI_GRAY_IMAGE`` - gray image (CV_8UC1)
|
||||
|
||||
@@ -69,7 +69,7 @@ For getting several data maps use ``VideoCapture::grab`` and ``VideoCapture::ret
|
||||
for(;;)
|
||||
{
|
||||
Mat depthMap;
|
||||
Mat rgbImage
|
||||
Mat bgrImage;
|
||||
|
||||
capture.grab();
|
||||
|
||||
|
||||
@@ -294,6 +294,10 @@ Command line arguments of ``opencv_traincascade`` application grouped by purpose
|
||||
|
||||
This argument is actual in case of Haar-like features. If it is specified, the cascade will be saved in the old format.
|
||||
|
||||
* ``-acceptanceRatioBreakValue``
|
||||
|
||||
This argument is used to determine how precise your model should keep learning and when to stop. A good guideline is to train not further than 10e-5, to ensure the model does not overtrain on your training data. By default this value is set to -1 to disable this feature.
|
||||
|
||||
#.
|
||||
|
||||
Cascade parameters:
|
||||
|
||||
@@ -128,11 +128,11 @@ Finds the camera intrinsic and extrinsic parameters from several views of a cali
|
||||
|
||||
.. ocv:pyoldfunction:: cv.CalibrateCamera2(objectPoints, imagePoints, pointCounts, imageSize, cameraMatrix, distCoeffs, rvecs, tvecs, flags=0)-> None
|
||||
|
||||
:param objectPoints: In the new interface it is a vector of vectors of calibration pattern points in the calibration pattern coordinate space. The outer vector contains as many elements as the number of the pattern views. If the same calibration pattern is shown in each view and it is fully visible, all the vectors will be the same. Although, it is possible to use partially occluded patterns, or even different patterns in different views. Then, the vectors will be different. The points are 3D, but since they are in a pattern coordinate system, then, if the rig is planar, it may make sense to put the model to a XY coordinate plane so that Z-coordinate of each input object point is 0.
|
||||
:param objectPoints: In the new interface it is a vector of vectors of calibration pattern points in the calibration pattern coordinate space (e.g. std::vector<std::vector<cv::Vec3f>>). The outer vector contains as many elements as the number of the pattern views. If the same calibration pattern is shown in each view and it is fully visible, all the vectors will be the same. Although, it is possible to use partially occluded patterns, or even different patterns in different views. Then, the vectors will be different. The points are 3D, but since they are in a pattern coordinate system, then, if the rig is planar, it may make sense to put the model to a XY coordinate plane so that Z-coordinate of each input object point is 0.
|
||||
|
||||
In the old interface all the vectors of object points from different views are concatenated together.
|
||||
|
||||
:param imagePoints: In the new interface it is a vector of vectors of the projections of calibration pattern points. ``imagePoints.size()`` and ``objectPoints.size()`` and ``imagePoints[i].size()`` must be equal to ``objectPoints[i].size()`` for each ``i``.
|
||||
:param imagePoints: In the new interface it is a vector of vectors of the projections of calibration pattern points (e.g. std::vector<std::vector<cv::Vec2f>>). ``imagePoints.size()`` and ``objectPoints.size()`` and ``imagePoints[i].size()`` must be equal to ``objectPoints[i].size()`` for each ``i``.
|
||||
|
||||
In the old interface all the vectors of object points from different views are concatenated together.
|
||||
|
||||
@@ -144,7 +144,7 @@ Finds the camera intrinsic and extrinsic parameters from several views of a cali
|
||||
|
||||
:param distCoeffs: Output vector of distortion coefficients :math:`(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]])` of 4, 5, or 8 elements.
|
||||
|
||||
:param rvecs: Output vector of rotation vectors (see :ocv:func:`Rodrigues` ) estimated for each pattern view. That is, each k-th rotation vector together with the corresponding k-th translation vector (see the next output parameter description) brings the calibration pattern from the model coordinate space (in which object points are specified) to the world coordinate space, that is, a real position of the calibration pattern in the k-th pattern view (k=0.. *M* -1).
|
||||
:param rvecs: Output vector of rotation vectors (see :ocv:func:`Rodrigues` ) estimated for each pattern view (e.g. std::vector<cv::Mat>>). That is, each k-th rotation vector together with the corresponding k-th translation vector (see the next output parameter description) brings the calibration pattern from the model coordinate space (in which object points are specified) to the world coordinate space, that is, a real position of the calibration pattern in the k-th pattern view (k=0.. *M* -1).
|
||||
|
||||
:param tvecs: Output vector of translation vectors estimated for each pattern view.
|
||||
|
||||
|
||||
@@ -82,18 +82,18 @@ cvTriangulatePoints(CvMat* projMatr1, CvMat* projMatr2, CvMat* projPoints1, CvMa
|
||||
CV_Error( CV_StsUnmatchedSizes, "Size of projection matrices must be 3x4" );
|
||||
|
||||
CvMat matrA;
|
||||
double matrA_dat[24];
|
||||
matrA = cvMat(6,4,CV_64F,matrA_dat);
|
||||
double matrA_dat[16];
|
||||
matrA = cvMat(4,4,CV_64F,matrA_dat);
|
||||
|
||||
//CvMat matrU;
|
||||
CvMat matrW;
|
||||
CvMat matrV;
|
||||
//double matrU_dat[9*9];
|
||||
double matrW_dat[6*4];
|
||||
double matrW_dat[4*4];
|
||||
double matrV_dat[4*4];
|
||||
|
||||
//matrU = cvMat(6,6,CV_64F,matrU_dat);
|
||||
matrW = cvMat(6,4,CV_64F,matrW_dat);
|
||||
matrW = cvMat(4,4,CV_64F,matrW_dat);
|
||||
matrV = cvMat(4,4,CV_64F,matrV_dat);
|
||||
|
||||
CvMat* projPoints[2];
|
||||
@@ -117,9 +117,8 @@ cvTriangulatePoints(CvMat* projMatr1, CvMat* projMatr2, CvMat* projPoints1, CvMa
|
||||
y = cvmGet(projPoints[j],1,i);
|
||||
for( int k = 0; k < 4; k++ )
|
||||
{
|
||||
cvmSet(&matrA, j*3+0, k, x * cvmGet(projMatrs[j],2,k) - cvmGet(projMatrs[j],0,k) );
|
||||
cvmSet(&matrA, j*3+1, k, y * cvmGet(projMatrs[j],2,k) - cvmGet(projMatrs[j],1,k) );
|
||||
cvmSet(&matrA, j*3+2, k, x * cvmGet(projMatrs[j],1,k) - y * cvmGet(projMatrs[j],0,k) );
|
||||
cvmSet(&matrA, j*2+0, k, x * cvmGet(projMatrs[j],2,k) - cvmGet(projMatrs[j],0,k) );
|
||||
cvmSet(&matrA, j*2+1, k, y * cvmGet(projMatrs[j],2,k) - cvmGet(projMatrs[j],1,k) );
|
||||
}
|
||||
}
|
||||
/* Solve system for current point */
|
||||
|
||||
@@ -1870,5 +1870,12 @@ TEST(Calib3d_CalibrationMatrixValues_C, accuracy) { CV_CalibrationMatrixValuesTe
|
||||
TEST(Calib3d_CalibrationMatrixValues_CPP, accuracy) { CV_CalibrationMatrixValuesTest_CPP test; test.safe_run(); }
|
||||
TEST(Calib3d_ProjectPoints_C, accuracy) { CV_ProjectPointsTest_C test; test.safe_run(); }
|
||||
TEST(Calib3d_ProjectPoints_CPP, regression) { CV_ProjectPointsTest_CPP test; test.safe_run(); }
|
||||
|
||||
#ifdef __aarch64__
|
||||
// Tests fail by accuracy (0.019145 vs 0.001000)
|
||||
TEST(Calib3d_StereoCalibrate_C, DISABLED_regression) { CV_StereoCalibrationTest_C test; test.safe_run(); }
|
||||
TEST(Calib3d_StereoCalibrate_CPP, DISABLED_regression) { CV_StereoCalibrationTest_CPP test; test.safe_run(); }
|
||||
#else
|
||||
TEST(Calib3d_StereoCalibrate_C, regression) { CV_StereoCalibrationTest_C test; test.safe_run(); }
|
||||
TEST(Calib3d_StereoCalibrate_CPP, regression) { CV_StereoCalibrationTest_CPP test; test.safe_run(); }
|
||||
#endif
|
||||
|
||||
@@ -110,11 +110,7 @@ void CV_ChessboardDetectorTimingTest::run( int start_from )
|
||||
if( !img )
|
||||
{
|
||||
ts->printf( cvtest::TS::LOG, "one of chessboard images can't be read: %s\n", filename );
|
||||
if( max_idx == 1 )
|
||||
{
|
||||
code = cvtest::TS::FAIL_MISSING_TEST_DATA;
|
||||
goto _exit_;
|
||||
}
|
||||
code = cvtest::TS::FAIL_MISSING_TEST_DATA;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +137,12 @@ protected:
|
||||
{
|
||||
InT d = disp(y, x);
|
||||
|
||||
double from[4] = { x, y, d, 1 };
|
||||
double from[4] = {
|
||||
static_cast<double>(x),
|
||||
static_cast<double>(y),
|
||||
static_cast<double>(d),
|
||||
1.0,
|
||||
};
|
||||
Mat_<double> res = Q * Mat_<double>(4, 1, from);
|
||||
res /= res(3, 0);
|
||||
|
||||
|
||||
@@ -101,7 +101,10 @@ void CV_UndistortPointsBadArgTest::run(int)
|
||||
img_size.height = 600;
|
||||
double cam[9] = {150.f, 0.f, img_size.width/2.f, 0, 300.f, img_size.height/2.f, 0.f, 0.f, 1.f};
|
||||
double dist[4] = {0.01,0.02,0.001,0.0005};
|
||||
double s_points[N_POINTS2] = {img_size.width/4,img_size.height/4};
|
||||
double s_points[N_POINTS2] = {
|
||||
static_cast<double>(img_size.width) / 4.0,
|
||||
static_cast<double>(img_size.height) / 4.0,
|
||||
};
|
||||
double d_points[N_POINTS2];
|
||||
double p[9] = {155.f, 0.f, img_size.width/2.f+img_size.width/50.f, 0, 310.f, img_size.height/2.f+img_size.height/50.f, 0.f, 0.f, 1.f};
|
||||
double r[9] = {1,0,0,0,1,0,0,0,1};
|
||||
|
||||
@@ -293,7 +293,7 @@ Retina::write
|
||||
Retina::setupIPLMagnoChannel
|
||||
++++++++++++++++++++++++++++
|
||||
|
||||
.. ocv:function:: void Retina::setupIPLMagnoChannel(const bool normaliseOutput = true, const float parasolCells_beta = 0, const float parasolCells_tau = 0, const float parasolCells_k = 7, const float amacrinCellsTemporalCutFrequency = 1.2, const float V0CompressionParameter = 0.95, const float localAdaptintegration_tau = 0, const float localAdaptintegration_k = 7 )
|
||||
.. ocv:function:: void Retina::setupIPLMagnoChannel(const bool normaliseOutput = true, const float parasolCells_beta = 0, const float parasolCells_tau = 0, const float parasolCells_k = 7, const float amacrinCellsTemporalCutFrequency = 1.2f, const float V0CompressionParameter = 0.95f, const float localAdaptintegration_tau = 0, const float localAdaptintegration_k = 7 )
|
||||
|
||||
Set parameters values for the Inner Plexiform Layer (IPL) magnocellular channel this channel processes signals output from OPL processing stage in peripheral vision, it allows motion information enhancement. It is decorrelated from the details channel. See reference papers for more details.
|
||||
|
||||
@@ -309,7 +309,7 @@ Retina::setupIPLMagnoChannel
|
||||
Retina::setupOPLandIPLParvoChannel
|
||||
++++++++++++++++++++++++++++++++++
|
||||
|
||||
.. ocv:function:: void Retina::setupOPLandIPLParvoChannel(const bool colorMode = true, const bool normaliseOutput = true, const float photoreceptorsLocalAdaptationSensitivity = 0.7, const float photoreceptorsTemporalConstant = 0.5, const float photoreceptorsSpatialConstant = 0.53, const float horizontalCellsGain = 0, const float HcellsTemporalConstant = 1, const float HcellsSpatialConstant = 7, const float ganglionCellsSensitivity = 0.7 )
|
||||
.. ocv:function:: void Retina::setupOPLandIPLParvoChannel(const bool colorMode = true, const bool normaliseOutput = true, const float photoreceptorsLocalAdaptationSensitivity = 0.7f, const float photoreceptorsTemporalConstant = 0.5f, const float photoreceptorsSpatialConstant = 0.53f, const float horizontalCellsGain = 0, const float HcellsTemporalConstant = 1, const float HcellsSpatialConstant = 7, const float ganglionCellsSensitivity = 0.7f )
|
||||
|
||||
Setup the OPL and IPL parvo channels (see biologocal model) OPL is referred as Outer Plexiform Layer of the retina, it allows the spatio-temporal filtering which withens the spectrum and reduces spatio-temporal noise while attenuating global luminance (low frequency energy) IPL parvo is the OPL next processing stage, it refers to a part of the Inner Plexiform layer of the retina, it allows high contours sensitivity in foveal vision. See reference papers for more informations.
|
||||
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/*! \file core.hpp
|
||||
\brief The Core Functionality
|
||||
*/
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/*! \file core.hpp
|
||||
\brief The Core Functionality
|
||||
*/
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
|
||||
@@ -49,8 +49,8 @@
|
||||
|
||||
#define CV_VERSION_EPOCH 2
|
||||
#define CV_VERSION_MAJOR 4
|
||||
#define CV_VERSION_MINOR 11
|
||||
#define CV_VERSION_REVISION 0
|
||||
#define CV_VERSION_MINOR 12
|
||||
#define CV_VERSION_REVISION 2
|
||||
|
||||
#define CVAUX_STR_EXP(__A) #__A
|
||||
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
|
||||
|
||||
@@ -33,5 +33,8 @@ PERF_TEST_P( Size_DepthSrc_DepthDst_Channels_alpha, convertTo,
|
||||
int runs = (sz.width <= 640) ? 8 : 1;
|
||||
TEST_CYCLE_MULTIRUN(runs) src.convertTo(dst, depthDst, alpha);
|
||||
|
||||
SANITY_CHECK(dst, alpha == 1.0 ? 1e-12 : 1e-7);
|
||||
if (depthDst >= CV_32F)
|
||||
SANITY_CHECK(dst, 1e-7, ERROR_RELATIVE);
|
||||
else
|
||||
SANITY_CHECK(dst, 1e-12);
|
||||
}
|
||||
|
||||
@@ -22,5 +22,5 @@ PERF_TEST_P(Size_MatType, dft, TEST_MATS_DFT)
|
||||
|
||||
TEST_CYCLE() dft(src, dst);
|
||||
|
||||
SANITY_CHECK(dst, 1e-5);
|
||||
SANITY_CHECK(dst, 4e-7, ERROR_RELATIVE);
|
||||
}
|
||||
|
||||
@@ -33,5 +33,12 @@ PERF_TEST_P( Size_SrcDepth_DstChannels, merge,
|
||||
int runs = (sz.width <= 640) ? 8 : 1;
|
||||
TEST_CYCLE_MULTIRUN(runs) merge( (vector<Mat> &)mv, dst );
|
||||
|
||||
#ifdef __aarch64__
|
||||
// looks like random generator produces a little bit
|
||||
// different source data on aarch64 platform and
|
||||
// eps should be increased to allow the tests pass
|
||||
SANITY_CHECK(dst, (srcDepth == CV_32F ? 1.55e-5 : 1e-12));
|
||||
#else
|
||||
SANITY_CHECK(dst, 1e-12);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -29,5 +29,12 @@ PERF_TEST_P( Size_Depth_Channels, split,
|
||||
int runs = (sz.width <= 640) ? 8 : 1;
|
||||
TEST_CYCLE_MULTIRUN(runs) split(m, (vector<Mat>&)mv);
|
||||
|
||||
#ifdef __aarch64__
|
||||
// looks like random generator produces a little bit
|
||||
// different source data on aarch64 platform and
|
||||
// eps should be increased to allow the tests pass
|
||||
SANITY_CHECK(mv, (depth == CV_32F ? 1.55e-5 : 1e-12));
|
||||
#else
|
||||
SANITY_CHECK(mv, 1e-12);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ struct _VAdd32f { __m128 operator()(const __m128& a, const __m128& b) const { re
|
||||
struct _VSub32f { __m128 operator()(const __m128& a, const __m128& b) const { return _mm_sub_ps(a,b); }};
|
||||
struct _VMin32f { __m128 operator()(const __m128& a, const __m128& b) const { return _mm_min_ps(a,b); }};
|
||||
struct _VMax32f { __m128 operator()(const __m128& a, const __m128& b) const { return _mm_max_ps(a,b); }};
|
||||
static int CV_DECL_ALIGNED(16) v32f_absmask[] = { 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff };
|
||||
static unsigned int CV_DECL_ALIGNED(16) v32f_absmask[] = { 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff };
|
||||
struct _VAbsDiff32f
|
||||
{
|
||||
__m128 operator()(const __m128& a, const __m128& b) const
|
||||
@@ -441,7 +441,7 @@ struct _VSub64f { __m128d operator()(const __m128d& a, const __m128d& b) const {
|
||||
struct _VMin64f { __m128d operator()(const __m128d& a, const __m128d& b) const { return _mm_min_pd(a,b); }};
|
||||
struct _VMax64f { __m128d operator()(const __m128d& a, const __m128d& b) const { return _mm_max_pd(a,b); }};
|
||||
|
||||
static int CV_DECL_ALIGNED(16) v64f_absmask[] = { 0xffffffff, 0x7fffffff, 0xffffffff, 0x7fffffff };
|
||||
static unsigned int CV_DECL_ALIGNED(16) v64f_absmask[] = { 0xffffffff, 0x7fffffff, 0xffffffff, 0x7fffffff };
|
||||
struct _VAbsDiff64f
|
||||
{
|
||||
__m128d operator()(const __m128d& a, const __m128d& b) const
|
||||
|
||||
@@ -346,6 +346,7 @@ CV_IMPL CvString
|
||||
cvMemStorageAllocString( CvMemStorage* storage, const char* ptr, int len )
|
||||
{
|
||||
CvString str;
|
||||
memset(&str, 0, sizeof(CvString));
|
||||
|
||||
str.len = len >= 0 ? len : (int)strlen(ptr);
|
||||
str.ptr = (char*)cvMemStorageAlloc( storage, str.len + 1 );
|
||||
@@ -645,7 +646,7 @@ icvGrowSeq( CvSeq *seq, int in_front_of )
|
||||
/* If there is a free space just after last allocated block
|
||||
and it is big enough then enlarge the last block.
|
||||
This can happen only if the new block is added to the end of sequence: */
|
||||
if( (unsigned)(ICV_FREE_PTR(storage) - seq->block_max) < CV_STRUCT_ALIGN &&
|
||||
if( (size_t)(ICV_FREE_PTR(storage) - seq->block_max) < CV_STRUCT_ALIGN &&
|
||||
storage->free_space >= seq->elem_size && !in_front_of )
|
||||
{
|
||||
int delta = storage->free_space / elem_size;
|
||||
@@ -1688,6 +1689,9 @@ cvSeqRemoveSlice( CvSeq* seq, CvSlice slice )
|
||||
|
||||
slice.end_index = slice.start_index + length;
|
||||
|
||||
if ( slice.start_index == slice.end_index )
|
||||
return;
|
||||
|
||||
if( slice.end_index < total )
|
||||
{
|
||||
CvSeqReader reader_to, reader_from;
|
||||
|
||||
@@ -2215,7 +2215,11 @@ void cv::polylines(InputOutputArray _img, InputArrayOfArrays pts,
|
||||
{
|
||||
Mat p = pts.getMat(manyContours ? i : -1);
|
||||
if( p.total() == 0 )
|
||||
{
|
||||
ptsptr[i] = NULL;
|
||||
npts[i] = 0;
|
||||
continue;
|
||||
}
|
||||
CV_Assert(p.checkVector(2, CV_32S) >= 0);
|
||||
ptsptr[i] = (Point*)p.data;
|
||||
npts[i] = p.rows*p.cols*p.channels()/2;
|
||||
|
||||
@@ -1097,8 +1097,8 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
|
||||
|
||||
size_t minidx = 0, maxidx = 0;
|
||||
int iminval = INT_MAX, imaxval = INT_MIN;
|
||||
float fminval = FLT_MAX, fmaxval = -FLT_MAX;
|
||||
double dminval = DBL_MAX, dmaxval = -DBL_MAX;
|
||||
float fminval = std::numeric_limits<float>::infinity(), fmaxval = -fminval;
|
||||
double dminval = std::numeric_limits<double>::infinity(), dmaxval = -dminval;
|
||||
size_t startidx = 1;
|
||||
int *minval = &iminval, *maxval = &imaxval;
|
||||
int planeSize = (int)it.size*cn;
|
||||
@@ -1111,6 +1111,14 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
|
||||
for( size_t i = 0; i < it.nplanes; i++, ++it, startidx += planeSize )
|
||||
func( ptrs[0], ptrs[1], minval, maxval, &minidx, &maxidx, planeSize, startidx );
|
||||
|
||||
if (!src.empty() && mask.empty())
|
||||
{
|
||||
if( minidx == 0 )
|
||||
minidx = 1;
|
||||
if( maxidx == 0 )
|
||||
maxidx = 1;
|
||||
}
|
||||
|
||||
if( minidx == 0 )
|
||||
dminval = dmaxval = 0;
|
||||
else if( depth == CV_32F )
|
||||
|
||||
@@ -923,7 +923,7 @@ struct Mutex::Impl
|
||||
int refcount;
|
||||
};
|
||||
|
||||
#elif defined __linux__ && !defined ANDROID
|
||||
#elif defined __linux__ && !defined ANDROID && !defined __LINUXTHREADS_OLD__
|
||||
|
||||
struct Mutex::Impl
|
||||
{
|
||||
|
||||
@@ -1792,3 +1792,21 @@ INSTANTIATE_TEST_CASE_P(Arithm, SubtractOutputMatNotEmpty, testing::Combine(
|
||||
testing::Values(perf::MatType(CV_8UC1), CV_8UC3, CV_8UC4, CV_16SC1, CV_16SC3),
|
||||
testing::Values(-1, CV_16S, CV_32S, CV_32F),
|
||||
testing::Bool()));
|
||||
|
||||
TEST(MinMaxLoc, Mat_IntMax_Without_Mask)
|
||||
{
|
||||
Mat_<int> mat(50, 50);
|
||||
int iMaxVal = numeric_limits<int>::max();
|
||||
mat.setTo(iMaxVal);
|
||||
|
||||
double min, max;
|
||||
Point minLoc, maxLoc;
|
||||
|
||||
minMaxLoc(mat, &min, &max, &minLoc, &maxLoc, Mat());
|
||||
|
||||
ASSERT_EQ(iMaxVal, min);
|
||||
ASSERT_EQ(iMaxVal, max);
|
||||
|
||||
ASSERT_EQ(Point(0, 0), minLoc);
|
||||
ASSERT_EQ(Point(0, 0), maxLoc);
|
||||
}
|
||||
|
||||
@@ -493,6 +493,7 @@ class Core_SeqBaseTest : public Core_DynStructBaseTest
|
||||
{
|
||||
public:
|
||||
Core_SeqBaseTest();
|
||||
virtual ~Core_SeqBaseTest();
|
||||
void clear();
|
||||
void run( int );
|
||||
|
||||
@@ -503,11 +504,14 @@ protected:
|
||||
int test_seq_ops( int iters );
|
||||
};
|
||||
|
||||
|
||||
Core_SeqBaseTest::Core_SeqBaseTest()
|
||||
{
|
||||
}
|
||||
|
||||
Core_SeqBaseTest::~Core_SeqBaseTest()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void Core_SeqBaseTest::clear()
|
||||
{
|
||||
@@ -1208,6 +1212,7 @@ class Core_SetTest : public Core_DynStructBaseTest
|
||||
{
|
||||
public:
|
||||
Core_SetTest();
|
||||
virtual ~Core_SetTest();
|
||||
void clear();
|
||||
void run( int );
|
||||
|
||||
@@ -1221,6 +1226,10 @@ Core_SetTest::Core_SetTest()
|
||||
{
|
||||
}
|
||||
|
||||
Core_SetTest::~Core_SetTest()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void Core_SetTest::clear()
|
||||
{
|
||||
@@ -1419,6 +1428,7 @@ class Core_GraphTest : public Core_DynStructBaseTest
|
||||
{
|
||||
public:
|
||||
Core_GraphTest();
|
||||
virtual ~Core_GraphTest();
|
||||
void clear();
|
||||
void run( int );
|
||||
|
||||
@@ -1432,6 +1442,10 @@ Core_GraphTest::Core_GraphTest()
|
||||
{
|
||||
}
|
||||
|
||||
Core_GraphTest::~Core_GraphTest()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void Core_GraphTest::clear()
|
||||
{
|
||||
@@ -2044,6 +2058,8 @@ void Core_GraphScanTest::run( int )
|
||||
CV_TS_SEQ_CHECK_CONDITION( vtx_count == 0 && edge_count == 0,
|
||||
"Not every vertex/edge has been visited" );
|
||||
update_progressbar();
|
||||
|
||||
cvReleaseGraphScanner( &scanner );
|
||||
}
|
||||
|
||||
// for a random graph the test just checks that every graph vertex and
|
||||
@@ -2108,8 +2124,6 @@ void Core_GraphScanTest::run( int )
|
||||
catch(int)
|
||||
{
|
||||
}
|
||||
|
||||
cvReleaseGraphScanner( &scanner );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -144,7 +144,11 @@ protected:
|
||||
|
||||
depth = cvtest::randInt(rng) % (CV_64F+1);
|
||||
cn = cvtest::randInt(rng) % 4 + 1;
|
||||
int sz[] = {cvtest::randInt(rng)%10+1, cvtest::randInt(rng)%10+1, cvtest::randInt(rng)%10+1};
|
||||
int sz[] = {
|
||||
static_cast<int>(cvtest::randInt(rng)%10+1),
|
||||
static_cast<int>(cvtest::randInt(rng)%10+1),
|
||||
static_cast<int>(cvtest::randInt(rng)%10+1),
|
||||
};
|
||||
MatND test_mat_nd(3, sz, CV_MAKETYPE(depth, cn));
|
||||
|
||||
rng0.fill(test_mat_nd, CV_RAND_UNI, Scalar::all(ranges[depth][0]), Scalar::all(ranges[depth][1]));
|
||||
@@ -156,8 +160,12 @@ protected:
|
||||
multiply(test_mat_nd, test_mat_scale, test_mat_nd);
|
||||
}
|
||||
|
||||
int ssz[] = {cvtest::randInt(rng)%10+1, cvtest::randInt(rng)%10+1,
|
||||
cvtest::randInt(rng)%10+1,cvtest::randInt(rng)%10+1};
|
||||
int ssz[] = {
|
||||
static_cast<int>(cvtest::randInt(rng)%10+1),
|
||||
static_cast<int>(cvtest::randInt(rng)%10+1),
|
||||
static_cast<int>(cvtest::randInt(rng)%10+1),
|
||||
static_cast<int>(cvtest::randInt(rng)%10+1),
|
||||
};
|
||||
SparseMat test_sparse_mat = cvTsGetRandomSparseMat(4, ssz, cvtest::randInt(rng)%(CV_64F+1),
|
||||
cvtest::randInt(rng) % 10000, 0, 100, rng);
|
||||
|
||||
|
||||
@@ -48,3 +48,23 @@ TEST(Core_SaturateCast, NegativeNotClipped)
|
||||
|
||||
ASSERT_EQ(0xffffffff, val);
|
||||
}
|
||||
|
||||
TEST(Core_Drawing, polylines_empty)
|
||||
{
|
||||
Mat img(100, 100, CV_8UC1, Scalar(0));
|
||||
vector<Point> pts; // empty
|
||||
polylines(img, pts, false, Scalar(255));
|
||||
int cnt = countNonZero(img);
|
||||
ASSERT_EQ(cnt, 0);
|
||||
}
|
||||
|
||||
TEST(Core_Drawing, polylines)
|
||||
{
|
||||
Mat img(100, 100, CV_8UC1, Scalar(0));
|
||||
vector<Point> pts;
|
||||
pts.push_back(Point(0, 0));
|
||||
pts.push_back(Point(20, 0));
|
||||
polylines(img, pts, false, Scalar(255));
|
||||
int cnt = countNonZero(img);
|
||||
ASSERT_EQ(cnt, 21);
|
||||
}
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "opencv2/gpu/device/transform.hpp"
|
||||
#include "opencv2/gpu/device/functional.hpp"
|
||||
#include "opencv2/gpu/device/type_traits.hpp"
|
||||
#include "opencv2/gpu/device/vec_traits.hpp"
|
||||
|
||||
namespace cv { namespace gpu { namespace device
|
||||
{
|
||||
@@ -105,87 +106,59 @@ namespace cv { namespace gpu { namespace device
|
||||
////////////////////////////////// SetTo //////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__constant__ uchar scalar_8u[4];
|
||||
__constant__ schar scalar_8s[4];
|
||||
__constant__ ushort scalar_16u[4];
|
||||
__constant__ short scalar_16s[4];
|
||||
__constant__ int scalar_32s[4];
|
||||
__constant__ float scalar_32f[4];
|
||||
__constant__ double scalar_64f[4];
|
||||
|
||||
template <typename T> __device__ __forceinline__ T readScalar(int i);
|
||||
template <> __device__ __forceinline__ uchar readScalar<uchar>(int i) {return scalar_8u[i];}
|
||||
template <> __device__ __forceinline__ schar readScalar<schar>(int i) {return scalar_8s[i];}
|
||||
template <> __device__ __forceinline__ ushort readScalar<ushort>(int i) {return scalar_16u[i];}
|
||||
template <> __device__ __forceinline__ short readScalar<short>(int i) {return scalar_16s[i];}
|
||||
template <> __device__ __forceinline__ int readScalar<int>(int i) {return scalar_32s[i];}
|
||||
template <> __device__ __forceinline__ float readScalar<float>(int i) {return scalar_32f[i];}
|
||||
template <> __device__ __forceinline__ double readScalar<double>(int i) {return scalar_64f[i];}
|
||||
|
||||
void writeScalar(const uchar* vals)
|
||||
{
|
||||
cudaSafeCall( cudaMemcpyToSymbol(scalar_8u, vals, sizeof(uchar) * 4) );
|
||||
}
|
||||
void writeScalar(const schar* vals)
|
||||
{
|
||||
cudaSafeCall( cudaMemcpyToSymbol(scalar_8s, vals, sizeof(schar) * 4) );
|
||||
}
|
||||
void writeScalar(const ushort* vals)
|
||||
{
|
||||
cudaSafeCall( cudaMemcpyToSymbol(scalar_16u, vals, sizeof(ushort) * 4) );
|
||||
}
|
||||
void writeScalar(const short* vals)
|
||||
{
|
||||
cudaSafeCall( cudaMemcpyToSymbol(scalar_16s, vals, sizeof(short) * 4) );
|
||||
}
|
||||
void writeScalar(const int* vals)
|
||||
{
|
||||
cudaSafeCall( cudaMemcpyToSymbol(scalar_32s, vals, sizeof(int) * 4) );
|
||||
}
|
||||
void writeScalar(const float* vals)
|
||||
{
|
||||
cudaSafeCall( cudaMemcpyToSymbol(scalar_32f, vals, sizeof(float) * 4) );
|
||||
}
|
||||
void writeScalar(const double* vals)
|
||||
{
|
||||
cudaSafeCall( cudaMemcpyToSymbol(scalar_64f, vals, sizeof(double) * 4) );
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
__global__ void set_to_without_mask(T* mat, int cols, int rows, size_t step, int channels)
|
||||
__global__ void set_to_without_mask(PtrStepSz<T> mat, typename TypeVec<T, 4>::vec_type val, int channels)
|
||||
{
|
||||
size_t x = blockIdx.x * blockDim.x + threadIdx.x;
|
||||
size_t y = blockIdx.y * blockDim.y + threadIdx.y;
|
||||
const int y = blockIdx.x * blockDim.y + threadIdx.y;
|
||||
|
||||
if ((x < cols * channels ) && (y < rows))
|
||||
if (y < mat.rows)
|
||||
{
|
||||
size_t idx = y * ( step >> shift_and_sizeof<T>::shift ) + x;
|
||||
mat[idx] = readScalar<T>(x % channels);
|
||||
const T vals[] = {
|
||||
val.x, val.y, val.z, val.w
|
||||
};
|
||||
|
||||
T* row = mat.ptr(y);
|
||||
|
||||
for (int x = threadIdx.x; x < mat.cols * channels; x += 32)
|
||||
{
|
||||
row[x] = vals[x % channels];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
__global__ void set_to_with_mask(T* mat, const uchar* mask, int cols, int rows, size_t step, int channels, size_t step_mask)
|
||||
__global__ void set_to_with_mask(PtrStepSz<T> mat, const PtrStepb mask, typename TypeVec<T, 4>::vec_type val, int channels)
|
||||
{
|
||||
size_t x = blockIdx.x * blockDim.x + threadIdx.x;
|
||||
size_t y = blockIdx.y * blockDim.y + threadIdx.y;
|
||||
const int y = blockIdx.x * blockDim.y + threadIdx.y;
|
||||
|
||||
if ((x < cols * channels ) && (y < rows))
|
||||
if (mask[y * step_mask + x / channels] != 0)
|
||||
if (y < mat.rows)
|
||||
{
|
||||
const T vals[] = {
|
||||
val.x, val.y, val.z, val.w
|
||||
};
|
||||
|
||||
T* row = mat.ptr(y);
|
||||
const uchar* mask_row = mask.ptr(y);
|
||||
|
||||
for (int x = threadIdx.x; x < mat.cols * channels; x += 32)
|
||||
{
|
||||
size_t idx = y * ( step >> shift_and_sizeof<T>::shift ) + x;
|
||||
mat[idx] = readScalar<T>(x % channels);
|
||||
if (mask_row[x / channels])
|
||||
{
|
||||
row[x] = vals[x % channels];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void set_to_gpu(PtrStepSzb mat, const T* scalar, PtrStepSzb mask, int channels, cudaStream_t stream)
|
||||
{
|
||||
writeScalar(scalar);
|
||||
typedef typename TypeVec<T, 4>::vec_type vec_type;
|
||||
|
||||
dim3 threadsPerBlock(32, 8, 1);
|
||||
dim3 numBlocks (mat.cols * channels / threadsPerBlock.x + 1, mat.rows / threadsPerBlock.y + 1, 1);
|
||||
dim3 block(32, 8);
|
||||
dim3 grid(divUp(mat.rows, block.y));
|
||||
|
||||
set_to_with_mask<T><<<numBlocks, threadsPerBlock, 0, stream>>>((T*)mat.data, (uchar*)mask.data, mat.cols, mat.rows, mat.step, channels, mask.step);
|
||||
set_to_with_mask<T><<<grid, block, 0, stream>>>(PtrStepSz<T>(mat), mask, VecTraits<vec_type>::make(scalar), channels);
|
||||
cudaSafeCall( cudaGetLastError() );
|
||||
|
||||
if (stream == 0)
|
||||
@@ -203,12 +176,12 @@ namespace cv { namespace gpu { namespace device
|
||||
template <typename T>
|
||||
void set_to_gpu(PtrStepSzb mat, const T* scalar, int channels, cudaStream_t stream)
|
||||
{
|
||||
writeScalar(scalar);
|
||||
typedef typename TypeVec<T, 4>::vec_type vec_type;
|
||||
|
||||
dim3 threadsPerBlock(32, 8, 1);
|
||||
dim3 numBlocks (mat.cols * channels / threadsPerBlock.x + 1, mat.rows / threadsPerBlock.y + 1, 1);
|
||||
dim3 block(32, 8);
|
||||
dim3 grid(divUp(mat.rows, block.y));
|
||||
|
||||
set_to_without_mask<T><<<numBlocks, threadsPerBlock, 0, stream>>>((T*)mat.data, mat.cols, mat.rows, mat.step, channels);
|
||||
set_to_without_mask<T><<<grid, block, 0, stream>>>(PtrStepSz<T>(mat), VecTraits<vec_type>::make(scalar), channels);
|
||||
cudaSafeCall( cudaGetLastError() );
|
||||
|
||||
if (stream == 0)
|
||||
|
||||
@@ -879,7 +879,7 @@ CV_EXPORTS Mat windowedMatchingMask( const vector<KeyPoint>& keypoints1, const v
|
||||
/*
|
||||
* OpponentColorDescriptorExtractor
|
||||
*
|
||||
* Adapts a descriptor extractor to compute descripors in Opponent Color Space
|
||||
* Adapts a descriptor extractor to compute descriptors in Opponent Color Space
|
||||
* (refer to van de Sande et al., CGIV 2008 "Color Descriptors for Object Category Recognition").
|
||||
* Input RGB image is transformed in Opponent Color Space. Then unadapted descriptor extractor
|
||||
* (set in constructor) computes descriptors on each of the three channel and concatenate
|
||||
|
||||
@@ -28,7 +28,7 @@ PERF_TEST_P(orb, detect, testing::Values(ORB_IMAGES))
|
||||
TEST_CYCLE() detector(frame, mask, points);
|
||||
|
||||
sort(points.begin(), points.end(), comparators::KeypointGreater());
|
||||
SANITY_CHECK_KEYPOINTS(points);
|
||||
SANITY_CHECK_KEYPOINTS(points, 1e-7, ERROR_RELATIVE);
|
||||
}
|
||||
|
||||
PERF_TEST_P(orb, extract, testing::Values(ORB_IMAGES))
|
||||
@@ -72,6 +72,6 @@ PERF_TEST_P(orb, full, testing::Values(ORB_IMAGES))
|
||||
TEST_CYCLE() detector(frame, mask, points, descriptors, false);
|
||||
|
||||
perf::sort(points, descriptors);
|
||||
SANITY_CHECK_KEYPOINTS(points);
|
||||
SANITY_CHECK_KEYPOINTS(points, 1e-8, ERROR_RELATIVE);
|
||||
SANITY_CHECK(descriptors);
|
||||
}
|
||||
|
||||
@@ -656,7 +656,8 @@ void FREAKImpl::drawPattern()
|
||||
FREAK::FREAK( bool _orientationNormalized, bool _scaleNormalized
|
||||
, float _patternScale, int _nOctaves, const std::vector<int>& _selectedPairs )
|
||||
: orientationNormalized(_orientationNormalized), scaleNormalized(_scaleNormalized),
|
||||
patternScale(_patternScale), nOctaves(_nOctaves), extAll(false), nOctaves0(0), selectedPairs0(_selectedPairs)
|
||||
patternScale(_patternScale), nOctaves(_nOctaves), extAll(false),
|
||||
patternScale0(0.0), nOctaves0(0), selectedPairs0(_selectedPairs)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -531,10 +531,20 @@ void FlannBasedMatcher::clear()
|
||||
|
||||
void FlannBasedMatcher::train()
|
||||
{
|
||||
if( flannIndex.empty() || mergedDescriptors.size() < addedDescCount )
|
||||
int trained = mergedDescriptors.size();
|
||||
if (flannIndex.empty() || trained < addedDescCount)
|
||||
{
|
||||
mergedDescriptors.set( trainDescCollection );
|
||||
flannIndex = new flann::Index( mergedDescriptors.getDescriptors(), *indexParams );
|
||||
|
||||
// construct flannIndex class, if empty or Algorithm not equal FLANN_INDEX_LSH
|
||||
if (flannIndex.empty() || flannIndex->getAlgorithm() != cvflann::FLANN_INDEX_LSH)
|
||||
{
|
||||
flannIndex = new flann::Index(mergedDescriptors.getDescriptors(), *indexParams);
|
||||
}
|
||||
else
|
||||
{
|
||||
flannIndex->build(mergedDescriptors.getDescriptors(), mergedDescriptors.getDescriptors().rowRange(trained, mergedDescriptors.size()), *indexParams, cvflann::FLANN_DIST_HAMMING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ static void writeMatInBin( const Mat& mat, const string& filename )
|
||||
fwrite( (void*)&mat.rows, sizeof(int), 1, f );
|
||||
fwrite( (void*)&mat.cols, sizeof(int), 1, f );
|
||||
fwrite( (void*)&type, sizeof(int), 1, f );
|
||||
int dataSize = (int)(mat.step * mat.rows * mat.channels());
|
||||
int dataSize = (int)(mat.step * mat.rows);
|
||||
fwrite( (void*)&dataSize, sizeof(int), 1, f );
|
||||
fwrite( (void*)mat.data, 1, dataSize, f );
|
||||
fclose(f);
|
||||
@@ -80,12 +80,15 @@ static Mat readMatFromBin( const string& filename )
|
||||
size_t elements_read4 = fread( (void*)&dataSize, sizeof(int), 1, f );
|
||||
CV_Assert(elements_read1 == 1 && elements_read2 == 1 && elements_read3 == 1 && elements_read4 == 1);
|
||||
|
||||
uchar* data = (uchar*)cvAlloc(dataSize);
|
||||
size_t elements_read = fread( (void*)data, 1, dataSize, f );
|
||||
Mat returnMat(rows, cols, type);
|
||||
CV_Assert(returnMat.step * returnMat.rows == (size_t)(dataSize));
|
||||
|
||||
size_t elements_read = fread( (void*)returnMat.data, 1, dataSize, f );
|
||||
CV_Assert(elements_read == (size_t)(dataSize));
|
||||
|
||||
fclose(f);
|
||||
|
||||
return Mat( rows, cols, type, data );
|
||||
return returnMat;
|
||||
}
|
||||
return Mat();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,543 @@
|
||||
/***********************************************************************
|
||||
* Software License Agreement (BSD License)
|
||||
*
|
||||
* Copyright (c) 2015 Ippei Ito. All rights reserved.
|
||||
*
|
||||
* THE BSD LICENSE
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*************************************************************************/
|
||||
|
||||
/*
|
||||
For OpenCV2.4/OpenCV3.0
|
||||
|
||||
Test for Pull Request # 3829
|
||||
https://github.com/Itseez/opencv/pull/3829
|
||||
|
||||
This test code creates brute force matcher for accuracy of reference, and the test target matcher.
|
||||
Then, add() and train() transformed query image descriptors, and some outlier images descriptors to both matchers.
|
||||
Then, compared with the query image by match() and findHomography() to detect outlier and calculate accuracy.
|
||||
And each drawMatches() images are saved, if SAVE_DRAW_MATCHES_IMAGES is true.
|
||||
Finally, compare accuracies between the brute force matcher and the test target matcher.
|
||||
|
||||
The lsh algorithm uses std::random_shuffle in lsh_index.h to make the random indexes table.
|
||||
So, in relation to default random seed value of the execution environment or by using "srand(time(0)) function",
|
||||
the match time and accuracy of the match results are different, each time the code ran.
|
||||
And the match time becomes late in relation to the number of the hash collision times.
|
||||
*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/ts.hpp" // for FilePath::CreateFolder()
|
||||
#include <time.h> // for time()
|
||||
|
||||
// If defined, the match time and accuracy of the match results are a little different, each time the code ran.
|
||||
//#define INIT_RANDOM_SEED
|
||||
|
||||
// If defined, some outlier images descriptors add() the matcher.
|
||||
#define TRAIN_WITH_OUTLIER_IMAGES
|
||||
|
||||
// If true, save drawMatches() images.
|
||||
#define SAVE_DRAW_MATCHES_IMAGES false
|
||||
|
||||
// if true, verbose output
|
||||
#define SHOW_DEBUG_LOG true
|
||||
|
||||
#if CV_MAJOR_VERSION==2
|
||||
#define OrbCreate new cv::ORB(4000)
|
||||
#elif CV_MAJOR_VERSION==3
|
||||
#define OrbCreate cv::ORB::create(4000)
|
||||
#define AKazeCreate cv::AKAZE::create()
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
int testno_for_make_filename = 0;
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Parameter class to transform query image
|
||||
// --------------------------------------------------------------------------------------
|
||||
class testparam
|
||||
{
|
||||
public:
|
||||
string transname;
|
||||
void(*transfunc)(float, const cv::Mat&, cv::Mat&);
|
||||
float from, to, step;
|
||||
testparam(string _transname, void(*_transfunc)(float, const cv::Mat&, cv::Mat&), float _from, float _to, float _step) :
|
||||
transname(_transname),
|
||||
transfunc(_transfunc),
|
||||
from(_from),
|
||||
to(_to),
|
||||
step(_step)
|
||||
{}
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// from matching_to_many_images.cpp
|
||||
// --------------------------------------------------------------------------------------
|
||||
int maskMatchesByTrainImgIdx(const vector<cv::DMatch>& matches, int trainImgIdx, vector<char>& mask)
|
||||
{
|
||||
int matchcnt = 0;
|
||||
mask.resize(matches.size());
|
||||
fill(mask.begin(), mask.end(), 0);
|
||||
for (size_t i = 0; i < matches.size(); i++)
|
||||
{
|
||||
if (matches[i].imgIdx == trainImgIdx)
|
||||
{
|
||||
mask[i] = 1;
|
||||
matchcnt++;
|
||||
}
|
||||
}
|
||||
return matchcnt;
|
||||
}
|
||||
|
||||
int calcHomographyAndInlierCount(const vector<cv::KeyPoint>& query_kp, const vector<cv::KeyPoint>& train_kp, const vector<cv::DMatch>& match, vector<char> &mask, cv::Mat &homography)
|
||||
{
|
||||
// make query and current train image keypoint pairs
|
||||
std::vector<cv::Point2f> srcPoints, dstPoints;
|
||||
for (unsigned int i = 0; i < match.size(); ++i)
|
||||
{
|
||||
if (mask[i] != 0) // is current train image ?
|
||||
{
|
||||
srcPoints.push_back(query_kp[match[i].queryIdx].pt);
|
||||
dstPoints.push_back(train_kp[match[i].trainIdx].pt);
|
||||
}
|
||||
}
|
||||
// calc homography
|
||||
vector<uchar> inlierMask;
|
||||
homography = findHomography(srcPoints, dstPoints, cv::RANSAC, 3.0, inlierMask);
|
||||
|
||||
// update outlier mask
|
||||
int j = 0;
|
||||
for (unsigned int i = 0; i < match.size(); ++i)
|
||||
{
|
||||
if (mask[i] != 0) // is current train image ?
|
||||
{
|
||||
if (inlierMask.size() == 0 || inlierMask[j] == 0) // is outlier ?
|
||||
{
|
||||
mask[i] = 0;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
// count inlier
|
||||
int inlierCnt = 0;
|
||||
for (unsigned int i = 0; i < mask.size(); ++i)
|
||||
{
|
||||
if (mask[i] != 0)
|
||||
{
|
||||
inlierCnt++;
|
||||
}
|
||||
}
|
||||
return inlierCnt;
|
||||
}
|
||||
|
||||
void drawDetectedRectangle(cv::Mat& imgResult, const cv::Mat& homography, const cv::Mat& imgQuery)
|
||||
{
|
||||
std::vector<cv::Point2f> query_corners(4);
|
||||
query_corners[0] = cv::Point(0, 0);
|
||||
query_corners[1] = cv::Point(imgQuery.cols, 0);
|
||||
query_corners[2] = cv::Point(imgQuery.cols, imgQuery.rows);
|
||||
query_corners[3] = cv::Point(0, imgQuery.rows);
|
||||
std::vector<cv::Point2f> train_corners(4);
|
||||
perspectiveTransform(query_corners, train_corners, homography);
|
||||
line(imgResult, train_corners[0] + query_corners[1], train_corners[1] + query_corners[1], cv::Scalar(0, 255, 0), 4);
|
||||
line(imgResult, train_corners[1] + query_corners[1], train_corners[2] + query_corners[1], cv::Scalar(0, 255, 0), 4);
|
||||
line(imgResult, train_corners[2] + query_corners[1], train_corners[3] + query_corners[1], cv::Scalar(0, 255, 0), 4);
|
||||
line(imgResult, train_corners[3] + query_corners[1], train_corners[0] + query_corners[1], cv::Scalar(0, 255, 0), 4);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// transform query image, extract&compute, train, matching and save result image function
|
||||
// --------------------------------------------------------------------------------------
|
||||
typedef struct tagTrainInfo
|
||||
{
|
||||
int traindesccnt;
|
||||
double traintime;
|
||||
double matchtime;
|
||||
double accuracy;
|
||||
}TrainInfo;
|
||||
|
||||
TrainInfo transImgAndTrain(
|
||||
cv::Feature2D *fe,
|
||||
cv::DescriptorMatcher *matcher,
|
||||
const string &matchername,
|
||||
const cv::Mat& imgQuery, const vector<cv::KeyPoint>& query_kp, const cv::Mat& query_desc,
|
||||
const vector<cv::Mat>& imgOutliers, const vector<vector<cv::KeyPoint> >& outliers_kp, const vector<cv::Mat>& outliers_desc, const int totalOutlierDescCnt,
|
||||
const float t, const testparam *tp,
|
||||
const int testno, const bool bVerboseOutput, const bool bSaveDrawMatches)
|
||||
{
|
||||
TrainInfo ti;
|
||||
|
||||
// transform query image
|
||||
cv::Mat imgTransform;
|
||||
(tp->transfunc)(t, imgQuery, imgTransform);
|
||||
|
||||
// extract kp and compute desc from transformed query image
|
||||
vector<cv::KeyPoint> trans_query_kp;
|
||||
cv::Mat trans_query_desc;
|
||||
#if CV_MAJOR_VERSION==2
|
||||
(*fe)(imgTransform, cv::Mat(), trans_query_kp, trans_query_desc);
|
||||
#elif CV_MAJOR_VERSION==3
|
||||
fe->detectAndCompute(imgTransform, Mat(), trans_query_kp, trans_query_desc);
|
||||
#endif
|
||||
// add&train transformed query desc and outlier desc
|
||||
matcher->clear();
|
||||
matcher->add(vector<cv::Mat>(1, trans_query_desc));
|
||||
double s = (double)cv::getTickCount();
|
||||
matcher->train();
|
||||
ti.traintime = 1000.0*((double)cv::getTickCount() - s) / cv::getTickFrequency();
|
||||
ti.traindesccnt = trans_query_desc.rows;
|
||||
#if defined(TRAIN_WITH_OUTLIER_IMAGES)
|
||||
// same as matcher->add(outliers_desc); matcher->train();
|
||||
for (unsigned int i = 0; i < outliers_desc.size(); ++i)
|
||||
{
|
||||
matcher->add(vector<cv::Mat>(1, outliers_desc[i]));
|
||||
s = (double)cv::getTickCount();
|
||||
matcher->train();
|
||||
ti.traintime += 1000.0*((double)cv::getTickCount() - s) / cv::getTickFrequency();
|
||||
}
|
||||
ti.traindesccnt += totalOutlierDescCnt;
|
||||
#endif
|
||||
// matching
|
||||
vector<cv::DMatch> match;
|
||||
s = (double)cv::getTickCount();
|
||||
matcher->match(query_desc, match);
|
||||
ti.matchtime = 1000.0*((double)cv::getTickCount() - s) / cv::getTickFrequency();
|
||||
|
||||
// prepare a directory and variables for save matching images
|
||||
vector<char> mask;
|
||||
cv::Mat imgResult;
|
||||
const char resultDir[] = "result";
|
||||
if (bSaveDrawMatches)
|
||||
{
|
||||
testing::internal::FilePath fp = testing::internal::FilePath(resultDir);
|
||||
fp.CreateFolder();
|
||||
}
|
||||
|
||||
char buff[2048];
|
||||
int matchcnt;
|
||||
|
||||
// save query vs transformed query matching image with detected rectangle
|
||||
matchcnt = maskMatchesByTrainImgIdx(match, (int)0, mask);
|
||||
// calc homography and inlier
|
||||
cv::Mat homography;
|
||||
int inlierCnt = calcHomographyAndInlierCount(query_kp, trans_query_kp, match, mask, homography);
|
||||
ti.accuracy = (double)inlierCnt / (double)mask.size()*100.0;
|
||||
drawMatches(imgQuery, query_kp, imgTransform, trans_query_kp, match, imgResult, cv::Scalar::all(-1), cv::Scalar::all(128), mask, cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
|
||||
if (inlierCnt)
|
||||
{
|
||||
// draw detected rectangle
|
||||
drawDetectedRectangle(imgResult, homography, imgQuery);
|
||||
}
|
||||
// draw status
|
||||
sprintf(buff, "%s accuracy:%-3.2f%% %d descriptors training time:%-3.2fms matching :%-3.2fms", matchername.c_str(), ti.accuracy, ti.traindesccnt, ti.traintime, ti.matchtime);
|
||||
putText(imgResult, buff, cv::Point(0, 12), cv::FONT_HERSHEY_PLAIN, 0.8, cv::Scalar(0., 0., 255.));
|
||||
sprintf(buff, "%s/res%03d_%s_%s%.1f_inlier.png", resultDir, testno, matchername.c_str(), tp->transname.c_str(), t);
|
||||
if (bSaveDrawMatches && !imwrite(buff, imgResult)) cout << "Image " << buff << " can not be saved (may be because directory " << resultDir << " does not exist)." << endl;
|
||||
|
||||
#if defined(TRAIN_WITH_OUTLIER_IMAGES)
|
||||
// save query vs outlier matching image(s)
|
||||
for (unsigned int i = 0; i <imgOutliers.size(); ++i)
|
||||
{
|
||||
matchcnt = maskMatchesByTrainImgIdx(match, (int)i + 1, mask);
|
||||
drawMatches(imgQuery, query_kp, imgOutliers[i], outliers_kp[i], match, imgResult, cv::Scalar::all(-1), cv::Scalar::all(128), mask);// , DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
|
||||
sprintf(buff, "query_num:%d train_num:%d matched:%d %d descriptors training time:%-3.2fms matching :%-3.2fms", (int)query_kp.size(), (int)outliers_kp[i].size(), matchcnt, ti.traindesccnt, ti.traintime, ti.matchtime);
|
||||
putText(imgResult, buff, cv::Point(0, 12), cv::FONT_HERSHEY_PLAIN, 0.8, cv::Scalar(0., 0., 255.));
|
||||
sprintf(buff, "%s/res%03d_%s_%s%.1f_outlier%02d.png", resultDir, testno, matchername.c_str(), tp->transname.c_str(), t, i);
|
||||
if (bSaveDrawMatches && !imwrite(buff, imgResult)) cout << "Image " << buff << " can not be saved (may be because directory " << resultDir << " does not exist)." << endl;
|
||||
}
|
||||
#endif
|
||||
if (bVerboseOutput)
|
||||
{
|
||||
cout << tp->transname <<" image matching accuracy:" << ti.accuracy << "% " << ti.traindesccnt << " train:" << ti.traintime << "ms match:" << ti.matchtime << "ms" << endl;
|
||||
}
|
||||
|
||||
return ti;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Main Test Class
|
||||
// --------------------------------------------------------------------------------------
|
||||
class CV_FeatureDetectorMatcherBaseTest : public cvtest::BaseTest
|
||||
{
|
||||
private:
|
||||
|
||||
testparam *tp;
|
||||
double target_accuracy_margin_from_bfmatcher;
|
||||
cv::Feature2D* fe; // feature detector extractor
|
||||
|
||||
cv::DescriptorMatcher* bfmatcher; // brute force matcher for accuracy of reference
|
||||
cv::DescriptorMatcher* flmatcher; // flann matcher to test
|
||||
cv::Mat imgQuery; // query image
|
||||
vector<cv::Mat> imgOutliers; // outlier image
|
||||
vector<cv::KeyPoint> query_kp; // query key points detect from imgQuery
|
||||
cv::Mat query_desc; // query descriptors extract from imgQuery
|
||||
vector<vector<cv::KeyPoint> > outliers_kp;
|
||||
vector<cv::Mat> outliers_desc;
|
||||
int totalOutlierDescCnt;
|
||||
|
||||
string flmatchername;
|
||||
|
||||
public:
|
||||
|
||||
//
|
||||
// constructor
|
||||
//
|
||||
CV_FeatureDetectorMatcherBaseTest(testparam* _tp, double _accuracy_margin, cv::Feature2D* _fe,
|
||||
cv::DescriptorMatcher *_flmatcher, string _flmatchername, int norm_type_for_bfmatcher) :
|
||||
tp(_tp),
|
||||
target_accuracy_margin_from_bfmatcher(_accuracy_margin),
|
||||
fe(_fe),
|
||||
flmatcher(_flmatcher),
|
||||
flmatchername(_flmatchername)
|
||||
{
|
||||
#if defined(INIT_RANDOM_SEED)
|
||||
// from test/test_eigen.cpp
|
||||
srand((unsigned int)time(0));
|
||||
#endif
|
||||
// create brute force matcher for accuracy of reference
|
||||
bfmatcher = new cv::BFMatcher(norm_type_for_bfmatcher);
|
||||
}
|
||||
|
||||
virtual ~CV_FeatureDetectorMatcherBaseTest()
|
||||
{
|
||||
if (bfmatcher)
|
||||
{
|
||||
delete bfmatcher;
|
||||
bfmatcher = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Main Test method
|
||||
//
|
||||
virtual void run(int)
|
||||
{
|
||||
// load query image
|
||||
string strQueryFile = string(cvtest::TS::ptr()->get_data_path()) + "shared/lena.png";
|
||||
imgQuery = cv::imread(strQueryFile, 0);
|
||||
if (imgQuery.empty())
|
||||
{
|
||||
ts->printf(cvtest::TS::LOG, "Image %s can not be read.\n", strQueryFile.c_str());
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
|
||||
return;
|
||||
}
|
||||
|
||||
// load outlier images
|
||||
char* outliers[] = { (char*)"baboon.png", (char*)"fruits.png", (char*)"airplane.png" };
|
||||
for (unsigned int i = 0; i < sizeof(outliers) / sizeof(char*); i++)
|
||||
{
|
||||
string strOutlierFile = string(cvtest::TS::ptr()->get_data_path()) + "shared/" + outliers[i];
|
||||
cv::Mat imgOutlier = cv::imread(strOutlierFile, 0);
|
||||
if (imgQuery.empty())
|
||||
{
|
||||
ts->printf(cvtest::TS::LOG, "Image %s can not be read.\n", strOutlierFile.c_str());
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
|
||||
return;
|
||||
}
|
||||
imgOutliers.push_back(imgOutlier);
|
||||
}
|
||||
|
||||
// extract and compute keypoints and descriptors from query image
|
||||
#if CV_MAJOR_VERSION==2
|
||||
(*fe)(imgQuery, cv::Mat(), query_kp, query_desc);
|
||||
#elif CV_MAJOR_VERSION==3
|
||||
fe->detectAndCompute(imgQuery, Mat(), query_kp, query_desc);
|
||||
#endif
|
||||
// extract and compute keypoints and descriptors from outlier images
|
||||
fe->detect(imgOutliers, outliers_kp);
|
||||
((cv::DescriptorExtractor*)fe)->compute(imgOutliers, outliers_kp, outliers_desc);
|
||||
totalOutlierDescCnt = 0;
|
||||
for (unsigned int i = 0; i < outliers_desc.size(); ++i) totalOutlierDescCnt += outliers_desc[i].rows;
|
||||
|
||||
if (SHOW_DEBUG_LOG)
|
||||
{
|
||||
cout << query_kp.size() << " keypoints extracted from query image." << endl;
|
||||
#if defined(TRAIN_WITH_OUTLIER_IMAGES)
|
||||
cout << totalOutlierDescCnt << " keypoints extracted from outlier image(s)." << endl;
|
||||
#endif
|
||||
}
|
||||
// compute brute force matcher accuracy for reference
|
||||
double totalTrainTime = 0.;
|
||||
double totalMatchTime = 0.;
|
||||
double totalAccuracy = 0.;
|
||||
int cnt = 0;
|
||||
for (float t = tp->from; t <= tp->to; t += tp->step, ++testno_for_make_filename, ++cnt)
|
||||
{
|
||||
if (SHOW_DEBUG_LOG) cout << "Test No." << testno_for_make_filename << " BFMatcher " << t;
|
||||
|
||||
TrainInfo ti = transImgAndTrain(fe, bfmatcher, "BFMatcher",
|
||||
imgQuery, query_kp, query_desc,
|
||||
imgOutliers, outliers_kp, outliers_desc,
|
||||
totalOutlierDescCnt,
|
||||
t, tp, testno_for_make_filename, SHOW_DEBUG_LOG, SAVE_DRAW_MATCHES_IMAGES);
|
||||
totalTrainTime += ti.traintime;
|
||||
totalMatchTime += ti.matchtime;
|
||||
totalAccuracy += ti.accuracy;
|
||||
}
|
||||
double bf_average_accuracy = totalAccuracy / cnt;
|
||||
if (SHOW_DEBUG_LOG)
|
||||
{
|
||||
cout << "total training time: " << totalTrainTime << "ms" << endl;
|
||||
cout << "total matching time: " << totalMatchTime << "ms" << endl;
|
||||
cout << "average accuracy:" << bf_average_accuracy << "%" << endl;
|
||||
}
|
||||
|
||||
// test the target matcher
|
||||
totalTrainTime = 0.;
|
||||
totalMatchTime = 0.;
|
||||
totalAccuracy = 0.;
|
||||
cnt = 0;
|
||||
for (float t = tp->from; t <= tp->to; t += tp->step, ++testno_for_make_filename, ++cnt)
|
||||
{
|
||||
if (SHOW_DEBUG_LOG) cout << "Test No." << testno_for_make_filename << " " << flmatchername << " " << t;
|
||||
|
||||
TrainInfo ti = transImgAndTrain(fe, flmatcher, flmatchername,
|
||||
imgQuery, query_kp, query_desc,
|
||||
imgOutliers, outliers_kp, outliers_desc,
|
||||
totalOutlierDescCnt,
|
||||
t, tp, testno_for_make_filename, SHOW_DEBUG_LOG, SAVE_DRAW_MATCHES_IMAGES);
|
||||
|
||||
totalTrainTime += ti.traintime;
|
||||
totalMatchTime += ti.matchtime;
|
||||
totalAccuracy += ti.accuracy;
|
||||
}
|
||||
double average_accuracy = totalAccuracy / cnt;
|
||||
double target_average_accuracy = bf_average_accuracy * target_accuracy_margin_from_bfmatcher;
|
||||
|
||||
if (SHOW_DEBUG_LOG)
|
||||
{
|
||||
cout << "total training time: " << totalTrainTime << "ms" << endl;
|
||||
cout << "total matching time: " << totalMatchTime << "ms" << endl;
|
||||
cout << "average accuracy:" << average_accuracy << "%" << endl;
|
||||
cout << "threshold of the target matcher average accuracy as error :" << target_average_accuracy << "%" << endl;
|
||||
cout << "accuracy degraded " << (100.0 - (average_accuracy / bf_average_accuracy *100.0)) << "% from BFMatcher.(lower percentage is better)" << endl;
|
||||
}
|
||||
// compare accuracies between the brute force matcher and the test target matcher
|
||||
if (average_accuracy < target_average_accuracy)
|
||||
{
|
||||
ts->printf(cvtest::TS::LOG, "Bad average accuracy %f < %f while test %s %s query\n", average_accuracy, target_average_accuracy, flmatchername.c_str(), tp->transname.c_str());
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Transform Functions
|
||||
// --------------------------------------------------------------------------------------
|
||||
static void rotate(float deg, const cv::Mat& src, cv::Mat& dst)
|
||||
{
|
||||
cv::warpAffine(src, dst, getRotationMatrix2D(cv::Point2f(src.cols / 2.0f, src.rows / 2.0f), deg, 1), src.size(), cv::INTER_CUBIC);
|
||||
}
|
||||
static void scale(float scale, const cv::Mat& src, cv::Mat& dst)
|
||||
{
|
||||
cv::resize(src, dst, cv::Size((int)(src.cols*scale), (int)(src.rows*scale)), cv::INTER_CUBIC);
|
||||
}
|
||||
static void blur(float k, const cv::Mat& src, cv::Mat& dst)
|
||||
{
|
||||
GaussianBlur(src, dst, cv::Size((int)k, (int)k), 0);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Tests Registrations
|
||||
// --------------------------------------------------------------------------------------
|
||||
#define SHORT_LSH_KEY_ACCURACY_MARGIN 0.72 // The margin for FlannBasedMatcher. 28% degraded from BFMatcher(Actually, about 10..24% measured.lower percentage is better.) for lsh key size=16.
|
||||
#define MIDDLE_LSH_KEY_ACCURACY_MARGIN 0.72 // The margin for FlannBasedMatcher. 28% degraded from BFMatcher(Actually, about 7..24% measured.lower percentage is better.) for lsh key size=24.
|
||||
#define LONG_LSH_KEY_ACCURACY_MARGIN 0.90 // The margin for FlannBasedMatcher. 10% degraded from BFMatcher(Actually, about -29...7% measured.lower percentage is better.) for lsh key size=31.
|
||||
|
||||
TEST(BlurredQueryFlannBasedLshShortKeyMatcherAdditionalTrainTest, accuracy)
|
||||
{
|
||||
cv::Ptr<cv::Feature2D> fe = OrbCreate;
|
||||
cv::Ptr<cv::FlannBasedMatcher> fl = cv::makePtr<cv::FlannBasedMatcher>(cv::makePtr<cv::flann::LshIndexParams>(1, 16, 2));
|
||||
testparam tp("blurred", blur, 1.0f, 11.0f, 2.0f);
|
||||
CV_FeatureDetectorMatcherBaseTest test(&tp, SHORT_LSH_KEY_ACCURACY_MARGIN, fe, fl, "FlannLsh(1, 16, 2)", cv::NORM_HAMMING);
|
||||
test.safe_run();
|
||||
}
|
||||
TEST(BlurredQueryFlannBasedLshMiddleKeyMatcherAdditionalTrainTest, accuracy)
|
||||
{
|
||||
cv::Ptr<cv::Feature2D> fe = OrbCreate;
|
||||
cv::Ptr<cv::FlannBasedMatcher> fl = cv::makePtr<cv::FlannBasedMatcher>(cv::makePtr<cv::flann::LshIndexParams>(1, 24, 2));
|
||||
testparam tp("blurred", blur, 1.0f, 11.0f, 2.0f);
|
||||
CV_FeatureDetectorMatcherBaseTest test(&tp, MIDDLE_LSH_KEY_ACCURACY_MARGIN, fe, fl, "FlannLsh(1, 24, 2)", cv::NORM_HAMMING);
|
||||
test.safe_run();
|
||||
}
|
||||
TEST(BlurredQueryFlannBasedLshLongKeyMatcherAdditionalTrainTest, accuracy)
|
||||
{
|
||||
cv::Ptr<cv::Feature2D> fe = OrbCreate;
|
||||
cv::Ptr<cv::FlannBasedMatcher> fl = cv::makePtr<cv::FlannBasedMatcher>(cv::makePtr<cv::flann::LshIndexParams>(1, 31, 2));
|
||||
testparam tp("blurred", blur, 1.0f, 11.0f, 2.0f);
|
||||
CV_FeatureDetectorMatcherBaseTest test(&tp, LONG_LSH_KEY_ACCURACY_MARGIN, fe, fl, "FlannLsh(1, 31, 2)", cv::NORM_HAMMING);
|
||||
test.safe_run();
|
||||
}
|
||||
|
||||
TEST(ScaledQueryFlannBasedLshShortKeyMatcherAdditionalTrainTest, accuracy)
|
||||
{
|
||||
cv::Ptr<cv::Feature2D> fe = OrbCreate;
|
||||
cv::Ptr<cv::FlannBasedMatcher> fl = cv::makePtr<cv::FlannBasedMatcher>(cv::makePtr<cv::flann::LshIndexParams>(1, 16, 2));
|
||||
testparam tp("scaled", scale, 0.5f, 1.5f, 0.1f);
|
||||
CV_FeatureDetectorMatcherBaseTest test(&tp, SHORT_LSH_KEY_ACCURACY_MARGIN, fe, fl, "FlannLsh(1, 16, 2)", cv::NORM_HAMMING);
|
||||
test.safe_run();
|
||||
}
|
||||
TEST(ScaledQueryFlannBasedLshMiddleKeyMatcherAdditionalTrainTest, accuracy)
|
||||
{
|
||||
cv::Ptr<cv::Feature2D> fe = OrbCreate;
|
||||
cv::Ptr<cv::FlannBasedMatcher> fl = cv::makePtr<cv::FlannBasedMatcher>(cv::makePtr<cv::flann::LshIndexParams>(1, 24, 2));
|
||||
testparam tp("scaled", scale, 0.5f, 1.5f, 0.1f);
|
||||
CV_FeatureDetectorMatcherBaseTest test(&tp, MIDDLE_LSH_KEY_ACCURACY_MARGIN, fe, fl, "FlannLsh(1, 24, 2)", cv::NORM_HAMMING);
|
||||
test.safe_run();
|
||||
}
|
||||
TEST(ScaledQueryFlannBasedLshLongKeyMatcherAdditionalTrainTest, accuracy)
|
||||
{
|
||||
cv::Ptr<cv::Feature2D> fe = OrbCreate;
|
||||
cv::Ptr<cv::FlannBasedMatcher> fl = cv::makePtr<cv::FlannBasedMatcher>(cv::makePtr<cv::flann::LshIndexParams>(1, 31, 2));
|
||||
testparam tp("scaled", scale, 0.5f, 1.5f, 0.1f);
|
||||
CV_FeatureDetectorMatcherBaseTest test(&tp, LONG_LSH_KEY_ACCURACY_MARGIN, fe, fl, "FlannLsh(1, 31, 2)", cv::NORM_HAMMING);
|
||||
test.safe_run();
|
||||
}
|
||||
|
||||
TEST(RotatedQueryFlannBasedLshShortKeyMatcherAdditionalTrainTest, accuracy)
|
||||
{
|
||||
cv::Ptr<cv::Feature2D> fe = OrbCreate;
|
||||
cv::Ptr<cv::FlannBasedMatcher> fl = cv::makePtr<cv::FlannBasedMatcher>(cv::makePtr<cv::flann::LshIndexParams>(1, 16, 2));
|
||||
testparam tp("rotated", rotate, 0.0f, 359.0f, 30.0f);
|
||||
CV_FeatureDetectorMatcherBaseTest test(&tp, SHORT_LSH_KEY_ACCURACY_MARGIN, fe, fl, "FlannLsh(1, 16, 2)", cv::NORM_HAMMING);
|
||||
test.safe_run();
|
||||
}
|
||||
TEST(RotatedQueryFlannBasedLshMiddleKeyMatcherAdditionalTrainTest, accuracy)
|
||||
{
|
||||
cv::Ptr<cv::Feature2D> fe = OrbCreate;
|
||||
cv::Ptr<cv::FlannBasedMatcher> fl = cv::makePtr<cv::FlannBasedMatcher>(cv::makePtr<cv::flann::LshIndexParams>(1, 24, 2));
|
||||
testparam tp("rotated", rotate, 0.0f, 359.0f, 30.0f);
|
||||
CV_FeatureDetectorMatcherBaseTest test(&tp, MIDDLE_LSH_KEY_ACCURACY_MARGIN, fe, fl, "FlannLsh(1, 24, 2)", cv::NORM_HAMMING);
|
||||
test.safe_run();
|
||||
}
|
||||
TEST(RotatedQueryFlannBasedLshLongKeyMatcherAdditionalTrainTest, accuracy)
|
||||
{
|
||||
cv::Ptr<cv::Feature2D> fe = OrbCreate;
|
||||
cv::Ptr<cv::FlannBasedMatcher> fl = cv::makePtr<cv::FlannBasedMatcher>(cv::makePtr<cv::flann::LshIndexParams>(1, 31, 2));
|
||||
testparam tp("rotated", rotate, 0.0f, 359.0f, 30.0f);
|
||||
CV_FeatureDetectorMatcherBaseTest test(&tp, LONG_LSH_KEY_ACCURACY_MARGIN, fe, fl, "FlannLsh(1, 31, 2)", cv::NORM_HAMMING);
|
||||
test.safe_run();
|
||||
}
|
||||
@@ -65,13 +65,13 @@ protected:
|
||||
virtual void run( int start_from );
|
||||
virtual void createModel( const Mat& data ) = 0;
|
||||
virtual int findNeighbors( Mat& points, Mat& neighbors ) = 0;
|
||||
virtual int checkGetPoins( const Mat& data );
|
||||
virtual int checkGetPoints( const Mat& data );
|
||||
virtual int checkFindBoxed();
|
||||
virtual int checkFind( const Mat& data );
|
||||
virtual void releaseModel() = 0;
|
||||
};
|
||||
|
||||
int NearestNeighborTest::checkGetPoins( const Mat& )
|
||||
int NearestNeighborTest::checkGetPoints( const Mat& )
|
||||
{
|
||||
return cvtest::TS::OK;
|
||||
}
|
||||
@@ -125,11 +125,11 @@ int NearestNeighborTest::checkFind( const Mat& data )
|
||||
void NearestNeighborTest::run( int /*start_from*/ ) {
|
||||
int code = cvtest::TS::OK, tempCode;
|
||||
Mat desc( featuresCount, dims, CV_32FC1 );
|
||||
randu( desc, Scalar(minValue), Scalar(maxValue) );
|
||||
ts->get_rng().fill( desc, RNG::UNIFORM, minValue, maxValue );
|
||||
|
||||
createModel( desc );
|
||||
|
||||
tempCode = checkGetPoins( desc );
|
||||
tempCode = checkGetPoints( desc );
|
||||
if( tempCode != cvtest::TS::OK )
|
||||
{
|
||||
ts->printf( cvtest::TS::LOG, "bad accuracy of GetPoints \n" );
|
||||
@@ -159,10 +159,10 @@ void NearestNeighborTest::run( int /*start_from*/ ) {
|
||||
class CV_KDTreeTest_CPP : public NearestNeighborTest
|
||||
{
|
||||
public:
|
||||
CV_KDTreeTest_CPP() {}
|
||||
CV_KDTreeTest_CPP() : NearestNeighborTest(), tr(NULL) {}
|
||||
protected:
|
||||
virtual void createModel( const Mat& data );
|
||||
virtual int checkGetPoins( const Mat& data );
|
||||
virtual int checkGetPoints( const Mat& data );
|
||||
virtual int findNeighbors( Mat& points, Mat& neighbors );
|
||||
virtual int checkFindBoxed();
|
||||
virtual void releaseModel();
|
||||
@@ -175,7 +175,7 @@ void CV_KDTreeTest_CPP::createModel( const Mat& data )
|
||||
tr = new KDTree( data, false );
|
||||
}
|
||||
|
||||
int CV_KDTreeTest_CPP::checkGetPoins( const Mat& data )
|
||||
int CV_KDTreeTest_CPP::checkGetPoints( const Mat& data )
|
||||
{
|
||||
Mat res1( data.size(), data.type() ),
|
||||
res3( data.size(), data.type() );
|
||||
@@ -244,7 +244,7 @@ void CV_KDTreeTest_CPP::releaseModel()
|
||||
class CV_FlannTest : public NearestNeighborTest
|
||||
{
|
||||
public:
|
||||
CV_FlannTest() {}
|
||||
CV_FlannTest() : NearestNeighborTest(), index(NULL) { }
|
||||
protected:
|
||||
void createIndex( const Mat& data, const IndexParams& params );
|
||||
int knnSearch( Mat& points, Mat& neighbors );
|
||||
@@ -255,6 +255,9 @@ protected:
|
||||
|
||||
void CV_FlannTest::createIndex( const Mat& data, const IndexParams& params )
|
||||
{
|
||||
// release previously allocated index
|
||||
releaseModel();
|
||||
|
||||
index = new Index( data, params );
|
||||
}
|
||||
|
||||
@@ -321,7 +324,11 @@ int CV_FlannTest::radiusSearch( Mat& points, Mat& neighbors )
|
||||
|
||||
void CV_FlannTest::releaseModel()
|
||||
{
|
||||
delete index;
|
||||
if (index)
|
||||
{
|
||||
delete index;
|
||||
index = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/calib3d/calib3d.hpp"
|
||||
#include <iostream>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -94,6 +94,13 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dummy implementation for other algorithms of addable indexes after that.
|
||||
*/
|
||||
void addIndex(const Matrix<ElementType>& /*wholeData*/, const Matrix<ElementType>& /*additionalData*/)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Method responsible with building the index.
|
||||
*/
|
||||
@@ -377,6 +384,7 @@ private:
|
||||
// evaluate kdtree for all parameter combinations
|
||||
for (size_t i = 0; i < FLANN_ARRAY_LEN(testTrees); ++i) {
|
||||
CostData cost;
|
||||
cost.params["algorithm"] = FLANN_INDEX_KDTREE;
|
||||
cost.params["trees"] = testTrees[i];
|
||||
|
||||
evaluate_kdtree(cost);
|
||||
|
||||
@@ -130,6 +130,13 @@ public:
|
||||
return kmeans_index_->usedMemory() + kdtree_index_->usedMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Dummy implementation for other algorithms of addable indexes after that.
|
||||
*/
|
||||
void addIndex(const Matrix<ElementType>& /*wholeData*/, const Matrix<ElementType>& /*additionalData*/)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Builds the index
|
||||
*/
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user