mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 06:03:15 +08:00
Merge remote-tracking branch 'refs/remotes/opencv/master' into FileStorageBase64DocsTests
# Conflicts: # modules/core/test/test_io.cpp
This commit is contained in:
commit
3935855365
2
.github/ISSUE_TEMPLATE.md
vendored
2
.github/ISSUE_TEMPLATE.md
vendored
@ -1,6 +1,6 @@
|
|||||||
<!--
|
<!--
|
||||||
If you have a question rather than reporting a bug please go to http://answers.opencv.org where you get much faster responses.
|
If you have a question rather than reporting a bug please go to http://answers.opencv.org where you get much faster responses.
|
||||||
If you need further assistance please read [How To Contribute](https://github.com/Itseez/opencv/wiki/How_to_contribute).
|
If you need further assistance please read [How To Contribute](https://github.com/opencv/opencv/wiki/How_to_contribute).
|
||||||
|
|
||||||
This is a template helping you to create an issue which can be processed as quickly as possible. This is the bug reporting section for the OpenCV library.
|
This is a template helping you to create an issue which can be processed as quickly as possible. This is the bug reporting section for the OpenCV library.
|
||||||
-->
|
-->
|
||||||
|
4
3rdparty/carotene/src/resize.cpp
vendored
4
3rdparty/carotene/src/resize.cpp
vendored
@ -432,7 +432,7 @@ inline void resizeAreaRounding(const Size2D &ssize, const Size2D &dsize,
|
|||||||
vSum = vaddq_u16(vSum, vaddl_u8(vLane4.val[0], vLane4.val[1]));
|
vSum = vaddq_u16(vSum, vaddl_u8(vLane4.val[0], vLane4.val[1]));
|
||||||
vSum = vaddq_u16(vSum, vaddl_u8(vLane4.val[2], vLane4.val[3]));
|
vSum = vaddq_u16(vSum, vaddl_u8(vLane4.val[2], vLane4.val[3]));
|
||||||
|
|
||||||
vst1_u8(dst_row + dj, areaDownsamplingDivision<opencv_like,4>(vSum));
|
vst1_u8(dst_row + dj, (areaDownsamplingDivision<opencv_like,4>(vSum)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( ; dj < dsize.width; ++dj, sj += 4)
|
for ( ; dj < dsize.width; ++dj, sj += 4)
|
||||||
@ -706,7 +706,7 @@ inline void resizeAreaRounding(const Size2D &ssize, const Size2D &dsize,
|
|||||||
uint16x8_t v_sum = vcombine_u16(vadd_u16(vget_low_u16(v_sum0), vget_high_u16(v_sum0)),
|
uint16x8_t v_sum = vcombine_u16(vadd_u16(vget_low_u16(v_sum0), vget_high_u16(v_sum0)),
|
||||||
vadd_u16(vget_low_u16(v_sum1), vget_high_u16(v_sum1)));
|
vadd_u16(vget_low_u16(v_sum1), vget_high_u16(v_sum1)));
|
||||||
|
|
||||||
vst1_u8(dst_row + dj, areaDownsamplingDivision<opencv_like,4>(v_sum));
|
vst1_u8(dst_row + dj, (areaDownsamplingDivision<opencv_like,4>(v_sum)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t dwidth = dsize.width << 2; dj < dwidth; dj += 4, sj += 16)
|
for (size_t dwidth = dsize.width << 2; dj < dwidth; dj += 4, sj += 16)
|
||||||
|
14
3rdparty/ffmpeg/ffmpeg.cmake
vendored
14
3rdparty/ffmpeg/ffmpeg.cmake
vendored
@ -1,11 +1,11 @@
|
|||||||
# Binary branch name: ffmpeg/master_20150703
|
# Binary branch name: ffmpeg/master_20160715
|
||||||
# Binaries were created for OpenCV: e379ea6ed60b0caad4d4e3eea096e9d850cb8c86
|
# Binaries were created for OpenCV: 0e6aa189cb9a9642b0ae7983d301693516faad5d
|
||||||
set(FFMPEG_BINARIES_COMMIT "8aeefc4efe3215de89d8c7e114ae6f7a6091b8eb")
|
set(FFMPEG_BINARIES_COMMIT "7eef9080d3271c7547d303fa839a62e1124ff1e6")
|
||||||
set(FFMPEG_FILE_HASH_BIN32 "89c783eee1c47bfc733f08334ec2e31c")
|
set(FFMPEG_FILE_HASH_BIN32 "3bb2a8388af90adf6c762210e696400d")
|
||||||
set(FFMPEG_FILE_HASH_BIN64 "35fe6ccdda6d7a04e9056b0d73b98e76")
|
set(FFMPEG_FILE_HASH_BIN64 "ebcfc963f0a94f7e83d58d60eaf23849")
|
||||||
set(FFMPEG_FILE_HASH_CMAKE "8606f947a780071f8fcce8cbf39ceef5")
|
set(FFMPEG_FILE_HASH_CMAKE "f99941d10c1e87bf16b9055e8fc91ab2")
|
||||||
|
|
||||||
set(FFMPEG_DOWNLOAD_URL ${OPENCV_FFMPEG_URL};$ENV{OPENCV_FFMPEG_URL};https://raw.githubusercontent.com/Itseez/opencv_3rdparty/${FFMPEG_BINARIES_COMMIT}/ffmpeg/)
|
set(FFMPEG_DOWNLOAD_URL ${OPENCV_FFMPEG_URL};$ENV{OPENCV_FFMPEG_URL};https://raw.githubusercontent.com/opencv/opencv_3rdparty/${FFMPEG_BINARIES_COMMIT}/ffmpeg/)
|
||||||
|
|
||||||
ocv_download(PACKAGE opencv_ffmpeg.dll
|
ocv_download(PACKAGE opencv_ffmpeg.dll
|
||||||
HASH ${FFMPEG_FILE_HASH_BIN32}
|
HASH ${FFMPEG_FILE_HASH_BIN32}
|
||||||
|
2
3rdparty/ippicv/downloader.cmake
vendored
2
3rdparty/ippicv/downloader.cmake
vendored
@ -64,7 +64,7 @@ function(_icv_downloader)
|
|||||||
if(DEFINED ENV{OPENCV_ICV_URL})
|
if(DEFINED ENV{OPENCV_ICV_URL})
|
||||||
set(OPENCV_ICV_URL $ENV{OPENCV_ICV_URL})
|
set(OPENCV_ICV_URL $ENV{OPENCV_ICV_URL})
|
||||||
else()
|
else()
|
||||||
set(OPENCV_ICV_URL "https://raw.githubusercontent.com/Itseez/opencv_3rdparty/${IPPICV_BINARIES_COMMIT}/ippicv")
|
set(OPENCV_ICV_URL "https://raw.githubusercontent.com/opencv/opencv_3rdparty/${IPPICV_BINARIES_COMMIT}/ippicv")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -191,6 +191,7 @@ OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF
|
|||||||
OCV_OPTION(WITH_OPENNI "Include OpenNI support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
OCV_OPTION(WITH_OPENNI "Include OpenNI support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
||||||
OCV_OPTION(WITH_OPENNI2 "Include OpenNI2 support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
OCV_OPTION(WITH_OPENNI2 "Include OpenNI2 support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
||||||
OCV_OPTION(WITH_PNG "Include PNG support" ON)
|
OCV_OPTION(WITH_PNG "Include PNG support" ON)
|
||||||
|
OCV_OPTION(WITH_GDCM "Include DICOM support" OFF)
|
||||||
OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
||||||
OCV_OPTION(WITH_GIGEAPI "Include Smartek GigE support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
OCV_OPTION(WITH_GIGEAPI "Include Smartek GigE support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
||||||
OCV_OPTION(WITH_QT "Build with Qt Backend support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
OCV_OPTION(WITH_QT "Build with Qt Backend support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
||||||
@ -1008,6 +1009,7 @@ if(WITH_PNG)
|
|||||||
else()
|
else()
|
||||||
status(" PNG:" "NO")
|
status(" PNG:" "NO")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WITH_TIFF)
|
if(WITH_TIFF)
|
||||||
if(TIFF_VERSION_STRING AND TIFF_FOUND)
|
if(TIFF_VERSION_STRING AND TIFF_FOUND)
|
||||||
status(" TIFF:" "${TIFF_LIBRARY} (ver ${TIFF_VERSION} - ${TIFF_VERSION_STRING})")
|
status(" TIFF:" "${TIFF_LIBRARY} (ver ${TIFF_VERSION} - ${TIFF_VERSION_STRING})")
|
||||||
@ -1034,6 +1036,12 @@ else()
|
|||||||
status(" GDAL:" "NO")
|
status(" GDAL:" "NO")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(WITH_GDCM)
|
||||||
|
status(" GDCM:" GDCM_FOUND THEN "YES (ver ${GDCM_VERSION})" ELSE "NO")
|
||||||
|
else()
|
||||||
|
status(" GDCM:" "NO")
|
||||||
|
endif()
|
||||||
|
|
||||||
# ========================== VIDEO IO ==========================
|
# ========================== VIDEO IO ==========================
|
||||||
status("")
|
status("")
|
||||||
status(" Video I/O:")
|
status(" Video I/O:")
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
## Contributing guidelines
|
## Contributing guidelines
|
||||||
|
|
||||||
All guidelines for contributing to the OpenCV repository can be found at [`How to contribute guideline`](https://github.com/Itseez/opencv/wiki/How_to_contribute).
|
All guidelines for contributing to the OpenCV repository can be found at [`How to contribute guideline`](https://github.com/opencv/opencv/wiki/How_to_contribute).
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
* Homepage: <http://opencv.org>
|
* Homepage: <http://opencv.org>
|
||||||
* Docs: <http://docs.opencv.org/master/>
|
* Docs: <http://docs.opencv.org/master/>
|
||||||
* Q&A forum: <http://answers.opencv.org>
|
* Q&A forum: <http://answers.opencv.org>
|
||||||
* Issue tracking: <https://github.com/Itseez/opencv/issues>
|
* Issue tracking: <https://github.com/opencv/opencv/issues>
|
||||||
|
|
||||||
#### Contributing
|
#### Contributing
|
||||||
|
|
||||||
Please read before starting work on a pull request: <https://github.com/Itseez/opencv/wiki/How_to_contribute>
|
Please read before starting work on a pull request: <https://github.com/opencv/opencv/wiki/How_to_contribute>
|
||||||
|
|
||||||
Summary of guidelines:
|
Summary of guidelines:
|
||||||
|
|
||||||
|
@ -224,28 +224,24 @@ vector<Rect> get_annotations(Mat input_image)
|
|||||||
|
|
||||||
int main( int argc, const char** argv )
|
int main( int argc, const char** argv )
|
||||||
{
|
{
|
||||||
// If no arguments are given, then supply some information on how this tool works
|
// Use the cmdlineparser to process input arguments
|
||||||
if( argc == 1 ){
|
CommandLineParser parser(argc, argv,
|
||||||
cout << "Usage: " << argv[0] << endl;
|
"{ help h usage ? | | show this message }"
|
||||||
cout << " -images <folder_location> [example - /data/testimages/]" << endl;
|
"{ images i | | (required) path to image folder [example - /data/testimages/] }"
|
||||||
cout << " -annotations <ouput_file> [example - /data/annotations.txt]" << endl;
|
"{ annotations a | | (required) path to annotations txt file [example - /data/annotations.txt] }"
|
||||||
cout << "TIP: Use absolute paths to avoid any problems with the software!" << endl;
|
);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read in the input arguments
|
// Read in the input arguments
|
||||||
string image_folder;
|
if (parser.has("help")){
|
||||||
string annotations_file;
|
parser.printMessage();
|
||||||
for(int i = 1; i < argc; ++i )
|
cerr << "TIP: Use absolute paths to avoid any problems with the software!" << endl;
|
||||||
{
|
return 0;
|
||||||
if( !strcmp( argv[i], "-images" ) )
|
}
|
||||||
{
|
string image_folder(parser.get<string>("images"));
|
||||||
image_folder = argv[++i];
|
string annotations_file(parser.get<string>("annotations"));
|
||||||
}
|
if (image_folder.empty() || annotations_file.empty()){
|
||||||
else if( !strcmp( argv[i], "-annotations" ) )
|
parser.printMessage();
|
||||||
{
|
cerr << "TIP: Use absolute paths to avoid any problems with the software!" << endl;
|
||||||
annotations_file = argv[++i];
|
return -1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the folder actually exists
|
// Check if the folder actually exists
|
||||||
|
@ -76,6 +76,7 @@ int main( int argc, char* argv[] )
|
|||||||
double scale = 4.0;
|
double scale = 4.0;
|
||||||
int width = 24;
|
int width = 24;
|
||||||
int height = 24;
|
int height = 24;
|
||||||
|
double maxscale = -1.0;
|
||||||
|
|
||||||
srand((unsigned int)time(0));
|
srand((unsigned int)time(0));
|
||||||
|
|
||||||
@ -92,9 +93,10 @@ int main( int argc, char* argv[] )
|
|||||||
" [-maxyangle <max_y_rotation_angle = %f>]\n"
|
" [-maxyangle <max_y_rotation_angle = %f>]\n"
|
||||||
" [-maxzangle <max_z_rotation_angle = %f>]\n"
|
" [-maxzangle <max_z_rotation_angle = %f>]\n"
|
||||||
" [-show [<scale = %f>]]\n"
|
" [-show [<scale = %f>]]\n"
|
||||||
" [-w <sample_width = %d>]\n [-h <sample_height = %d>]\n",
|
" [-w <sample_width = %d>]\n [-h <sample_height = %d>]\n"
|
||||||
|
" [-maxscale <max sample scale = %f>]\n",
|
||||||
argv[0], num, bgcolor, bgthreshold, maxintensitydev,
|
argv[0], num, bgcolor, bgthreshold, maxintensitydev,
|
||||||
maxxangle, maxyangle, maxzangle, scale, width, height );
|
maxxangle, maxyangle, maxzangle, scale, width, height, maxscale );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -172,6 +174,10 @@ int main( int argc, char* argv[] )
|
|||||||
{
|
{
|
||||||
height = atoi( argv[++i] );
|
height = atoi( argv[++i] );
|
||||||
}
|
}
|
||||||
|
else if( !strcmp( argv[i], "-maxscale" ) )
|
||||||
|
{
|
||||||
|
maxscale = atof( argv[++i] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf( "Info file name: %s\n", ((infoname == NULL) ? nullname : infoname ) );
|
printf( "Info file name: %s\n", ((infoname == NULL) ? nullname : infoname ) );
|
||||||
@ -194,6 +200,7 @@ int main( int argc, char* argv[] )
|
|||||||
}
|
}
|
||||||
printf( "Width: %d\n", width );
|
printf( "Width: %d\n", width );
|
||||||
printf( "Height: %d\n", height );
|
printf( "Height: %d\n", height );
|
||||||
|
printf( "Max Scale: %g\n", maxscale);
|
||||||
|
|
||||||
/* determine action */
|
/* determine action */
|
||||||
if( imagename && vecname )
|
if( imagename && vecname )
|
||||||
@ -213,7 +220,7 @@ int main( int argc, char* argv[] )
|
|||||||
|
|
||||||
cvCreateTestSamples( infoname, imagename, bgcolor, bgthreshold, bgfilename, num,
|
cvCreateTestSamples( infoname, imagename, bgcolor, bgthreshold, bgfilename, num,
|
||||||
invert, maxintensitydev,
|
invert, maxintensitydev,
|
||||||
maxxangle, maxyangle, maxzangle, showsamples, width, height );
|
maxxangle, maxyangle, maxzangle, showsamples, width, height, maxscale);
|
||||||
|
|
||||||
printf( "Done\n" );
|
printf( "Done\n" );
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,6 @@
|
|||||||
// the use of this software, even if advised of the possibility of such damage.
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
//
|
//
|
||||||
//M*/
|
//M*/
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
@ -1308,7 +1307,7 @@ void cvCreateTestSamples( const char* infoname,
|
|||||||
int invert, int maxintensitydev,
|
int invert, int maxintensitydev,
|
||||||
double maxxangle, double maxyangle, double maxzangle,
|
double maxxangle, double maxyangle, double maxzangle,
|
||||||
int showsamples,
|
int showsamples,
|
||||||
int winwidth, int winheight )
|
int winwidth, int winheight, double maxscale )
|
||||||
{
|
{
|
||||||
CvSampleDistortionData data;
|
CvSampleDistortionData data;
|
||||||
|
|
||||||
@ -1337,7 +1336,6 @@ void cvCreateTestSamples( const char* infoname,
|
|||||||
int i;
|
int i;
|
||||||
int x, y, width, height;
|
int x, y, width, height;
|
||||||
float scale;
|
float scale;
|
||||||
float maxscale;
|
|
||||||
int inverse;
|
int inverse;
|
||||||
|
|
||||||
if( showsamples )
|
if( showsamples )
|
||||||
@ -1366,12 +1364,16 @@ void cvCreateTestSamples( const char* infoname,
|
|||||||
for( i = 0; i < count; i++ )
|
for( i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
icvGetNextFromBackgroundData( cvbgdata, cvbgreader );
|
icvGetNextFromBackgroundData( cvbgdata, cvbgreader );
|
||||||
|
if( maxscale < 0.0 )
|
||||||
maxscale = MIN( 0.7F * cvbgreader->src.cols / winwidth,
|
{
|
||||||
|
maxscale = MIN( 0.7F * cvbgreader->src.cols / winwidth,
|
||||||
0.7F * cvbgreader->src.rows / winheight );
|
0.7F * cvbgreader->src.rows / winheight );
|
||||||
|
}
|
||||||
|
|
||||||
if( maxscale < 1.0F ) continue;
|
if( maxscale < 1.0F ) continue;
|
||||||
|
|
||||||
scale = (maxscale - 1.0F) * rand() / RAND_MAX + 1.0F;
|
scale = ((float)maxscale - 1.0F) * rand() / RAND_MAX + 1.0F;
|
||||||
|
|
||||||
width = (int) (scale * winwidth);
|
width = (int) (scale * winwidth);
|
||||||
height = (int) (scale * winheight);
|
height = (int) (scale * winheight);
|
||||||
x = (int) ((0.1+0.8 * rand()/RAND_MAX) * (cvbgreader->src.cols - width));
|
x = (int) ((0.1+0.8 * rand()/RAND_MAX) * (cvbgreader->src.cols - width));
|
||||||
|
@ -86,7 +86,7 @@ void cvCreateTestSamples( const char* infoname,
|
|||||||
int invert, int maxintensitydev,
|
int invert, int maxintensitydev,
|
||||||
double maxxangle, double maxyangle, double maxzangle,
|
double maxxangle, double maxyangle, double maxzangle,
|
||||||
int showsamples,
|
int showsamples,
|
||||||
int winwidth, int winheight );
|
int winwidth, int winheight, double maxscale );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* cvCreateTrainingSamplesFromInfo
|
* cvCreateTrainingSamplesFromInfo
|
||||||
|
@ -310,7 +310,8 @@ bool CvCascadeClassifier::updateTrainingSet( double minimumAcceptanceRatio, doub
|
|||||||
int proNumNeg = cvRound( ( ((double)numNeg) * ((double)posCount) ) / numPos ); // apply only a fraction of negative samples. double is required since overflow is possible
|
int proNumNeg = cvRound( ( ((double)numNeg) * ((double)posCount) ) / numPos ); // apply only a fraction of negative samples. double is required since overflow is possible
|
||||||
int negCount = fillPassedSamples( posCount, proNumNeg, false, minimumAcceptanceRatio, negConsumed );
|
int negCount = fillPassedSamples( posCount, proNumNeg, false, minimumAcceptanceRatio, negConsumed );
|
||||||
if ( !negCount )
|
if ( !negCount )
|
||||||
return false;
|
if ( !(negConsumed > 0 && ((double)negCount+1)/(double)negConsumed <= minimumAcceptanceRatio) )
|
||||||
|
return false;
|
||||||
|
|
||||||
curNumSamples = posCount + negCount;
|
curNumSamples = posCount + negCount;
|
||||||
acceptanceRatio = negConsumed == 0 ? 0 : ( (double)negCount/(double)(int64)negConsumed );
|
acceptanceRatio = negConsumed == 0 ? 0 : ( (double)negCount/(double)(int64)negConsumed );
|
||||||
|
@ -49,13 +49,6 @@ understanding of the used features.
|
|||||||
USAGE:
|
USAGE:
|
||||||
./opencv_visualisation --model=<model.xml> --image=<ref.png> --data=<video output folder>
|
./opencv_visualisation --model=<model.xml> --image=<ref.png> --data=<video output folder>
|
||||||
|
|
||||||
LIMITS
|
|
||||||
- Use an absolute path for the output folder to ensure the tool works
|
|
||||||
- Only handles cascade classifier models
|
|
||||||
- Handles stumps only for the moment
|
|
||||||
- Needs a valid training/test sample window with the original model dimensions, passed as `ref.png`
|
|
||||||
- Can handle HAAR and LBP features
|
|
||||||
|
|
||||||
Created by: Puttemans Steven - April 2016
|
Created by: Puttemans Steven - April 2016
|
||||||
*****************************************************************************************************/
|
*****************************************************************************************************/
|
||||||
|
|
||||||
@ -79,6 +72,13 @@ struct rect_data{
|
|||||||
float weight;
|
float weight;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void printLimits(){
|
||||||
|
cerr << "Limits of the current interface:" << endl;
|
||||||
|
cerr << " - Only handles cascade classifier models, trained with the opencv_traincascade tool, containing stumps as decision trees [default settings]." << endl;
|
||||||
|
cerr << " - The image provided needs to be a sample window with the original model dimensions, passed to the --image parameter." << endl;
|
||||||
|
cerr << " - ONLY handles HAAR and LBP features." << endl;
|
||||||
|
}
|
||||||
|
|
||||||
int main( int argc, const char** argv )
|
int main( int argc, const char** argv )
|
||||||
{
|
{
|
||||||
CommandLineParser parser(argc, argv,
|
CommandLineParser parser(argc, argv,
|
||||||
@ -90,6 +90,7 @@ int main( int argc, const char** argv )
|
|||||||
// Read in the input arguments
|
// Read in the input arguments
|
||||||
if (parser.has("help")){
|
if (parser.has("help")){
|
||||||
parser.printMessage();
|
parser.printMessage();
|
||||||
|
printLimits();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
string model(parser.get<string>("model"));
|
string model(parser.get<string>("model"));
|
||||||
@ -97,6 +98,7 @@ int main( int argc, const char** argv )
|
|||||||
string image_ref = (parser.get<string>("image"));
|
string image_ref = (parser.get<string>("image"));
|
||||||
if (model.empty() || image_ref.empty()){
|
if (model.empty() || image_ref.empty()){
|
||||||
parser.printMessage();
|
parser.printMessage();
|
||||||
|
printLimits();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,8 +146,11 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
|||||||
elseif(X86 OR X86_64)
|
elseif(X86 OR X86_64)
|
||||||
add_extra_compiler_option(-mno-sse2)
|
add_extra_compiler_option(-mno-sse2)
|
||||||
endif()
|
endif()
|
||||||
|
if(ARM)
|
||||||
|
add_extra_compiler_option("-mfp16-format=ieee")
|
||||||
|
endif(ARM)
|
||||||
if(ENABLE_NEON)
|
if(ENABLE_NEON)
|
||||||
add_extra_compiler_option("-mfpu=neon")
|
add_extra_compiler_option("-mfpu=neon-fp16")
|
||||||
endif()
|
endif()
|
||||||
if(ENABLE_VFPV3 AND NOT ENABLE_NEON)
|
if(ENABLE_VFPV3 AND NOT ENABLE_NEON)
|
||||||
add_extra_compiler_option("-mfpu=vfpv3")
|
add_extra_compiler_option("-mfpu=vfpv3")
|
||||||
@ -366,3 +369,18 @@ if(MSVC)
|
|||||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4589) # Constructor of abstract class 'cv::ORB' ignores initializer for virtual base class 'cv::Algorithm'
|
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4589) # Constructor of abstract class 'cv::ORB' ignores initializer for virtual base class 'cv::Algorithm'
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT OPENCV_FP16_DISABLE)
|
||||||
|
try_compile(__VALID_FP16
|
||||||
|
"${OpenCV_BINARY_DIR}"
|
||||||
|
"${OpenCV_SOURCE_DIR}/cmake/checks/fp16.cpp"
|
||||||
|
COMPILE_DEFINITIONS "-DCHECK_FP16"
|
||||||
|
OUTPUT_VARIABLE TRY_OUT
|
||||||
|
)
|
||||||
|
if(NOT __VALID_FP16)
|
||||||
|
message(STATUS "FP16: Compiler support is not available")
|
||||||
|
else()
|
||||||
|
message(STATUS "FP16: Compiler support is available")
|
||||||
|
set(HAVE_FP16 1)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
@ -75,10 +75,10 @@ if(NOT ${found})
|
|||||||
|
|
||||||
if(NOT ANDROID AND NOT APPLE_FRAMEWORK)
|
if(NOT ANDROID AND NOT APPLE_FRAMEWORK)
|
||||||
ocv_check_environment_variables(${library_env} ${include_dir_env})
|
ocv_check_environment_variables(${library_env} ${include_dir_env})
|
||||||
if(NOT ${${library_env}} EQUAL "")
|
if(NOT ${${library_env}} STREQUAL "")
|
||||||
set(PYTHON_LIBRARY "${${library_env}}")
|
set(PYTHON_LIBRARY "${${library_env}}")
|
||||||
endif()
|
endif()
|
||||||
if(NOT ${${include_dir_env}} EQUAL "")
|
if(NOT ${${include_dir_env}} STREQUAL "")
|
||||||
set(PYTHON_INCLUDE_DIR "${${include_dir_env}}")
|
set(PYTHON_INCLUDE_DIR "${${include_dir_env}}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -162,10 +162,10 @@ if(NOT ${found})
|
|||||||
message(STATUS "Cannot probe for Python/Numpy support (because we are cross-compiling OpenCV)")
|
message(STATUS "Cannot probe for Python/Numpy support (because we are cross-compiling OpenCV)")
|
||||||
message(STATUS "If you want to enable Python/Numpy support, set the following variables:")
|
message(STATUS "If you want to enable Python/Numpy support, set the following variables:")
|
||||||
message(STATUS " PYTHON2_INCLUDE_PATH")
|
message(STATUS " PYTHON2_INCLUDE_PATH")
|
||||||
message(STATUS " PYTHON2_LIBRARIES")
|
message(STATUS " PYTHON2_LIBRARIES (optional on Unix-like systems)")
|
||||||
message(STATUS " PYTHON2_NUMPY_INCLUDE_DIRS")
|
message(STATUS " PYTHON2_NUMPY_INCLUDE_DIRS")
|
||||||
message(STATUS " PYTHON3_INCLUDE_PATH")
|
message(STATUS " PYTHON3_INCLUDE_PATH")
|
||||||
message(STATUS " PYTHON3_LIBRARIES")
|
message(STATUS " PYTHON3_LIBRARIES (optional on Unix-like systems)")
|
||||||
message(STATUS " PYTHON3_NUMPY_INCLUDE_DIRS")
|
message(STATUS " PYTHON3_NUMPY_INCLUDE_DIRS")
|
||||||
else()
|
else()
|
||||||
# Attempt to discover the NumPy include directory. If this succeeds, then build python API with NumPy
|
# Attempt to discover the NumPy include directory. If this succeeds, then build python API with NumPy
|
||||||
|
@ -212,3 +212,15 @@ if(WITH_GDAL)
|
|||||||
ocv_include_directories(${GDAL_INCLUDE_DIR})
|
ocv_include_directories(${GDAL_INCLUDE_DIR})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (WITH_GDCM)
|
||||||
|
find_package(GDCM)
|
||||||
|
if(NOT GDCM_FOUND)
|
||||||
|
set(HAVE_GDCM NO)
|
||||||
|
ocv_clear_vars(GDCM_VERSION GDCM_LIBRARIES)
|
||||||
|
else()
|
||||||
|
set(HAVE_GDCM YES)
|
||||||
|
# include(${GDCM_USE_FILE})
|
||||||
|
set(GDCM_LIBRARIES gdcmMSFF) # GDCM does not set this variable for some reason
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
33
cmake/checks/fp16.cpp
Normal file
33
cmake/checks/fp16.cpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#if defined __F16C__ || (defined _MSC_VER && _MSC_VER >= 1700)
|
||||||
|
#include <immintrin.h>
|
||||||
|
int test()
|
||||||
|
{
|
||||||
|
const float src[] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
|
short dst[8];
|
||||||
|
__m128 v_src = _mm_load_ps(src);
|
||||||
|
__m128i v_dst = _mm_cvtps_ph(v_src, 0);
|
||||||
|
_mm_storel_epi64((__m128i*)dst, v_dst);
|
||||||
|
return (int)dst[0];
|
||||||
|
}
|
||||||
|
#elif defined __GNUC__ && (defined __arm__ || defined __aarch64__)
|
||||||
|
#include "arm_neon.h"
|
||||||
|
int test()
|
||||||
|
{
|
||||||
|
const float src[] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
|
short dst[8];
|
||||||
|
float32x4_t v_src = *(float32x4_t*)src;
|
||||||
|
float16x4_t v_dst = vcvt_f16_f32(v_src);
|
||||||
|
*(float16x4_t*)dst = v_dst;
|
||||||
|
return (int)dst[0];
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#error "FP16 is not supported"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
printf("%d\n", test());
|
||||||
|
return 0;
|
||||||
|
}
|
@ -111,6 +111,9 @@
|
|||||||
/* libpng/png.h needs to be included */
|
/* libpng/png.h needs to be included */
|
||||||
#cmakedefine HAVE_LIBPNG_PNG_H
|
#cmakedefine HAVE_LIBPNG_PNG_H
|
||||||
|
|
||||||
|
/* GDCM DICOM codec */
|
||||||
|
#cmakedefine HAVE_GDCM
|
||||||
|
|
||||||
/* V4L/V4L2 capturing support via libv4l */
|
/* V4L/V4L2 capturing support via libv4l */
|
||||||
#cmakedefine HAVE_LIBV4L
|
#cmakedefine HAVE_LIBV4L
|
||||||
|
|
||||||
@ -200,3 +203,6 @@
|
|||||||
|
|
||||||
/* Lapack */
|
/* Lapack */
|
||||||
#cmakedefine HAVE_LAPACK
|
#cmakedefine HAVE_LAPACK
|
||||||
|
|
||||||
|
/* FP16 */
|
||||||
|
#cmakedefine HAVE_FP16
|
||||||
|
@ -150,7 +150,7 @@ BINARY_TOC = NO
|
|||||||
TOC_EXPAND = NO
|
TOC_EXPAND = NO
|
||||||
GENERATE_QHP = @CMAKE_DOXYGEN_GENERATE_QHP@
|
GENERATE_QHP = @CMAKE_DOXYGEN_GENERATE_QHP@
|
||||||
QCH_FILE = ../opencv-@OPENCV_VERSION@.qch
|
QCH_FILE = ../opencv-@OPENCV_VERSION@.qch
|
||||||
QHP_NAMESPACE = org.itseez.opencv.@OPENCV_VERSION@
|
QHP_NAMESPACE = org.opencv.@OPENCV_VERSION@
|
||||||
QHP_VIRTUAL_FOLDER = opencv
|
QHP_VIRTUAL_FOLDER = opencv
|
||||||
QHP_CUST_FILTER_NAME =
|
QHP_CUST_FILTER_NAME =
|
||||||
QHP_CUST_FILTER_ATTRS =
|
QHP_CUST_FILTER_ATTRS =
|
||||||
|
@ -750,7 +750,7 @@
|
|||||||
organization = {ACM}
|
organization = {ACM}
|
||||||
}
|
}
|
||||||
@INPROCEEDINGS{Viola01,
|
@INPROCEEDINGS{Viola01,
|
||||||
author = {Viola, Paul and Jones, Michael},
|
author = {Viola, Paul and Jones, Michael J.},
|
||||||
title = {Rapid object detection using a boosted cascade of simple features},
|
title = {Rapid object detection using a boosted cascade of simple features},
|
||||||
booktitle = {Computer Vision and Pattern Recognition, 2001. CVPR 2001. Proceedings of the 2001 IEEE Computer Society Conference on},
|
booktitle = {Computer Vision and Pattern Recognition, 2001. CVPR 2001. Proceedings of the 2001 IEEE Computer Society Conference on},
|
||||||
year = {2001},
|
year = {2001},
|
||||||
@ -758,6 +758,16 @@
|
|||||||
volume = {1},
|
volume = {1},
|
||||||
organization = {IEEE}
|
organization = {IEEE}
|
||||||
}
|
}
|
||||||
|
@ARTICLE{Viola04,
|
||||||
|
author = {Viola, Paul and Jones, Michael J.},
|
||||||
|
title = {Robust real-time face detection},
|
||||||
|
journal = {International Journal of Computer Vision},
|
||||||
|
year = {2004},
|
||||||
|
volume = {57},
|
||||||
|
number = {2},
|
||||||
|
pages = {137--154},
|
||||||
|
publisher = {Kluwer Academic Publishers}
|
||||||
|
}
|
||||||
@INPROCEEDINGS{WJ10,
|
@INPROCEEDINGS{WJ10,
|
||||||
author = {Xu, Wei and Mulligan, Jane},
|
author = {Xu, Wei and Mulligan, Jane},
|
||||||
title = {Performance evaluation of color correction approaches for automatic multi-view image and video stitching},
|
title = {Performance evaluation of color correction approaches for automatic multi-view image and video stitching},
|
||||||
|
@ -130,11 +130,11 @@ for fname in images:
|
|||||||
if ret == True:
|
if ret == True:
|
||||||
objpoints.append(objp)
|
objpoints.append(objp)
|
||||||
|
|
||||||
cv2.cornerSubPix(gray,corners, (11,11), (-1,-1), criteria)
|
corners2=cv2.cornerSubPix(gray,corners, (11,11), (-1,-1), criteria)
|
||||||
imgpoints.append(corners)
|
imgpoints.append(corners)
|
||||||
|
|
||||||
# Draw and display the corners
|
# Draw and display the corners
|
||||||
cv2.drawChessboardCorners(img, (7,6), corners, ret)
|
cv2.drawChessboardCorners(img, (7,6), corners2, ret)
|
||||||
cv2.imshow('img', img)
|
cv2.imshow('img', img)
|
||||||
cv2.waitKey(500)
|
cv2.waitKey(500)
|
||||||
|
|
||||||
|
@ -70,15 +70,15 @@ for fname in glob.glob('left*.jpg'):
|
|||||||
corners2 = cv2.cornerSubPix(gray,corners,(11,11),(-1,-1),criteria)
|
corners2 = cv2.cornerSubPix(gray,corners,(11,11),(-1,-1),criteria)
|
||||||
|
|
||||||
# Find the rotation and translation vectors.
|
# Find the rotation and translation vectors.
|
||||||
rvecs, tvecs, inliers = cv2.solvePnPRansac(objp, corners2, mtx, dist)
|
ret,rvecs, tvecs, inliers = cv2.solvePnP(objp, corners2, mtx, dist)
|
||||||
|
|
||||||
# project 3D points to image plane
|
# project 3D points to image plane
|
||||||
imgpts, jac = cv2.projectPoints(axis, rvecs, tvecs, mtx, dist)
|
imgpts, jac = cv2.projectPoints(axis, rvecs, tvecs, mtx, dist)
|
||||||
|
|
||||||
img = draw(img,corners2,imgpts)
|
img = draw(img,corners2,imgpts)
|
||||||
cv2.imshow('img',img)
|
cv2.imshow('img',img)
|
||||||
k = cv2.waitKey(0) & 0xff
|
k = cv2.waitKey(0) & 0xFF
|
||||||
if k == 's':
|
if k == ord('s'):
|
||||||
cv2.imwrite(fname[:6]+'.png', img)
|
cv2.imwrite(fname[:6]+'.png', img)
|
||||||
|
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
|
@ -49,7 +49,7 @@ BRIEF in OpenCV
|
|||||||
Below code shows the computation of BRIEF descriptors with the help of CenSurE detector. (CenSurE
|
Below code shows the computation of BRIEF descriptors with the help of CenSurE detector. (CenSurE
|
||||||
detector is called STAR detector in OpenCV)
|
detector is called STAR detector in OpenCV)
|
||||||
|
|
||||||
note, that you need [opencv contrib](https://github.com/Itseez/opencv_contrib)) to use this.
|
note, that you need [opencv contrib](https://github.com/opencv/opencv_contrib)) to use this.
|
||||||
@code{.py}
|
@code{.py}
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
|
@ -22,61 +22,61 @@ Well, the questions and imaginations continue. But it all depends on the most ba
|
|||||||
you play jigsaw puzzles? How do you arrange lots of scrambled image pieces into a big single image?
|
you play jigsaw puzzles? How do you arrange lots of scrambled image pieces into a big single image?
|
||||||
How can you stitch a lot of natural images to a single image?
|
How can you stitch a lot of natural images to a single image?
|
||||||
|
|
||||||
The answer is, we are looking for specific patterns or specific features which are unique, which can
|
The answer is, we are looking for specific patterns or specific features which are unique, can
|
||||||
be easily tracked, which can be easily compared. If we go for a definition of such a feature, we may
|
be easily tracked and can be easily compared. If we go for a definition of such a feature, we may
|
||||||
find it difficult to express it in words, but we know what are they. If some one asks you to point
|
find it difficult to express it in words, but we know what they are. If someone asks you to point
|
||||||
out one good feature which can be compared across several images, you can point out one. That is
|
out one good feature which can be compared across several images, you can point out one. That is
|
||||||
why, even small children can simply play these games. We search for these features in an image, we
|
why even small children can simply play these games. We search for these features in an image,
|
||||||
find them, we find the same features in other images, we align them. That's it. (In jigsaw puzzle,
|
find them, look for the same features in other images and align them. That's it. (In jigsaw puzzle,
|
||||||
we look more into continuity of different images). All these abilities are present in us inherently.
|
we look more into continuity of different images). All these abilities are present in us inherently.
|
||||||
|
|
||||||
So our one basic question expands to more in number, but becomes more specific. **What are these
|
So our one basic question expands to more in number, but becomes more specific. **What are these
|
||||||
features?**. *(The answer should be understandable to a computer also.)*
|
features?**. (The answer should be understandable also to a computer.)
|
||||||
|
|
||||||
Well, it is difficult to say how humans find these features. It is already programmed in our brain.
|
It is difficult to say how humans find these features. This is already programmed in our brain.
|
||||||
But if we look deep into some pictures and search for different patterns, we will find something
|
But if we look deep into some pictures and search for different patterns, we will find something
|
||||||
interesting. For example, take below image:
|
interesting. For example, take below image:
|
||||||
|
|
||||||
![image](images/feature_building.jpg)
|
![image](images/feature_building.jpg)
|
||||||
|
|
||||||
Image is very simple. At the top of image, six small image patches are given. Question for you is to
|
The image is very simple. At the top of image, six small image patches are given. Question for you is to
|
||||||
find the exact location of these patches in the original image. How many correct results you can
|
find the exact location of these patches in the original image. How many correct results can you
|
||||||
find ?
|
find?
|
||||||
|
|
||||||
A and B are flat surfaces, and they are spread in a lot of area. It is difficult to find the exact
|
A and B are flat surfaces and they are spread over a lot of area. It is difficult to find the exact
|
||||||
location of these patches.
|
location of these patches.
|
||||||
|
|
||||||
C and D are much more simpler. They are edges of the building. You can find an approximate location,
|
C and D are much more simple. They are edges of the building. You can find an approximate location,
|
||||||
but exact location is still difficult. It is because, along the edge, it is same everywhere. Normal
|
but exact location is still difficult. This is because the pattern is same everywhere along the edge.
|
||||||
to the edge, it is different. So edge is a much better feature compared to flat area, but not good
|
At the edge, however, it is different. An edge is therefore better feature compared to flat area, but
|
||||||
enough (It is good in jigsaw puzzle for comparing continuity of edges).
|
not good enough (It is good in jigsaw puzzle for comparing continuity of edges).
|
||||||
|
|
||||||
Finally, E and F are some corners of the building. And they can be easily found out. Because at
|
Finally, E and F are some corners of the building. And they can be easily found. Because at the
|
||||||
corners, wherever you move this patch, it will look different. So they can be considered as a good
|
corners, wherever you move this patch, it will look different. So they can be considered as good
|
||||||
feature. So now we move into more simpler (and widely used image) for better understanding.
|
features. So now we move into simpler (and widely used image) for better understanding.
|
||||||
|
|
||||||
![image](images/feature_simple.png)
|
![image](images/feature_simple.png)
|
||||||
|
|
||||||
Just like above, blue patch is flat area and difficult to find and track. Wherever you move the blue
|
Just like above, the blue patch is flat area and difficult to find and track. Wherever you move the blue
|
||||||
patch, it looks the same. For black patch, it is an edge. If you move it in vertical direction (i.e.
|
patch it looks the same. The black patch has an edge. If you move it in vertical direction (i.e.
|
||||||
along the gradient) it changes. Put along the edge (parallel to edge), it looks the same. And for
|
along the gradient) it changes. Moved along the edge (parallel to edge), it looks the same. And for
|
||||||
red patch, it is a corner. Wherever you move the patch, it looks different, means it is unique. So
|
red patch, it is a corner. Wherever you move the patch, it looks different, means it is unique. So
|
||||||
basically, corners are considered to be good features in an image. (Not just corners, in some cases
|
basically, corners are considered to be good features in an image. (Not just corners, in some cases
|
||||||
blobs are considered good features).
|
blobs are considered good features).
|
||||||
|
|
||||||
So now we answered our question, "what are these features?". But next question arises. How do we
|
So now we answered our question, "what are these features?". But next question arises. How do we
|
||||||
find them? Or how do we find the corners?. That also we answered in an intuitive way, i.e., look for
|
find them? Or how do we find the corners?. We answered that in an intuitive way, i.e., look for
|
||||||
the regions in images which have maximum variation when moved (by a small amount) in all regions
|
the regions in images which have maximum variation when moved (by a small amount) in all regions
|
||||||
around it. This would be projected into computer language in coming chapters. So finding these image
|
around it. This would be projected into computer language in coming chapters. So finding these image
|
||||||
features is called **Feature Detection**.
|
features is called **Feature Detection**.
|
||||||
|
|
||||||
So we found the features in image (Assume you did it). Once you found it, you should find the same
|
We found the features in the images. Once you have found it, you should be able to find the same
|
||||||
in the other images. What we do? We take a region around the feature, we explain it in our own
|
in the other images. How is this done? We take a region around the feature, we explain it in our own
|
||||||
words, like "upper part is blue sky, lower part is building region, on that building there are some
|
words, like "upper part is blue sky, lower part is region from a building, on that building there is
|
||||||
glasses etc" and you search for the same area in other images. Basically, you are describing the
|
glass etc" and you search for the same area in the other images. Basically, you are describing the
|
||||||
feature. Similar way, computer also should describe the region around the feature so that it can
|
feature. Similarly, a computer also should describe the region around the feature so that it can
|
||||||
find it in other images. So called description is called **Feature Description**. Once you have the
|
find it in other images. So called description is called **Feature Description**. Once you have the
|
||||||
features and its description, you can find same features in all images and align them, stitch them
|
features and its description, you can find same features in all images and align them, stitch them together
|
||||||
or do whatever you want.
|
or do whatever you want.
|
||||||
|
|
||||||
So in this module, we are looking to different algorithms in OpenCV to find features, describe them,
|
So in this module, we are looking to different algorithms in OpenCV to find features, describe them,
|
||||||
|
@ -104,7 +104,7 @@ greater than 0.8, they are rejected. It eliminaters around 90% of false matches
|
|||||||
|
|
||||||
So this is a summary of SIFT algorithm. For more details and understanding, reading the original
|
So this is a summary of SIFT algorithm. For more details and understanding, reading the original
|
||||||
paper is highly recommended. Remember one thing, this algorithm is patented. So this algorithm is
|
paper is highly recommended. Remember one thing, this algorithm is patented. So this algorithm is
|
||||||
included in [the opencv contrib repo](https://github.com/Itseez/opencv_contrib)
|
included in [the opencv contrib repo](https://github.com/opencv/opencv_contrib)
|
||||||
|
|
||||||
SIFT in OpenCV
|
SIFT in OpenCV
|
||||||
--------------
|
--------------
|
||||||
|
@ -58,7 +58,7 @@ OpenCV Needs You !!!
|
|||||||
Since OpenCV is an open source initiative, all are welcome to make contributions to the library,
|
Since OpenCV is an open source initiative, all are welcome to make contributions to the library,
|
||||||
documentation, and tutorials. If you find any mistake in this tutorial (from a small spelling
|
documentation, and tutorials. If you find any mistake in this tutorial (from a small spelling
|
||||||
mistake to an egregious error in code or concept), feel free to correct it by cloning OpenCV in
|
mistake to an egregious error in code or concept), feel free to correct it by cloning OpenCV in
|
||||||
[GitHub](https://github.com/Itseez/opencv) and submitting a pull request. OpenCV developers will
|
[GitHub](https://github.com/opencv/opencv) and submitting a pull request. OpenCV developers will
|
||||||
check your pull request, give you important feedback and (once it passes the approval of the
|
check your pull request, give you important feedback and (once it passes the approval of the
|
||||||
reviewer) it will be merged into OpenCV. You will then become an open source contributor :-)
|
reviewer) it will be merged into OpenCV. You will then become an open source contributor :-)
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ Or you can download latest source from OpenCV's github repo. (If you want to con
|
|||||||
choose this. It always keeps your OpenCV up-to-date). For that, you need to install **Git** first.
|
choose this. It always keeps your OpenCV up-to-date). For that, you need to install **Git** first.
|
||||||
@code{.sh}
|
@code{.sh}
|
||||||
yum install git
|
yum install git
|
||||||
git clone https://github.com/Itseez/opencv.git
|
git clone https://github.com/opencv/opencv.git
|
||||||
@endcode
|
@endcode
|
||||||
It will create a folder OpenCV in home directory (or the directory you specify). The cloning may
|
It will create a folder OpenCV in home directory (or the directory you specify). The cloning may
|
||||||
take some time depending upon your internet connection.
|
take some time depending upon your internet connection.
|
||||||
|
@ -76,7 +76,7 @@ Building OpenCV from source
|
|||||||
|
|
||||||
-# Download OpenCV source. It can be from
|
-# Download OpenCV source. It can be from
|
||||||
[Sourceforge](http://sourceforge.net/projects/opencvlibrary/) (for official release version) or
|
[Sourceforge](http://sourceforge.net/projects/opencvlibrary/) (for official release version) or
|
||||||
from [Github](https://github.com/Itseez/opencv) (for latest source).
|
from [Github](https://github.com/opencv/opencv) (for latest source).
|
||||||
-# Extract it to a folder, opencv and create a new folder build in it.
|
-# Extract it to a folder, opencv and create a new folder build in it.
|
||||||
-# Open CMake-gui (*Start \> All Programs \> CMake-gui*)
|
-# Open CMake-gui (*Start \> All Programs \> CMake-gui*)
|
||||||
-# Fill the fields as follows (see the image below):
|
-# Fill the fields as follows (see the image below):
|
||||||
|
@ -77,13 +77,13 @@ Source code
|
|||||||
|
|
||||||
You may also find the source code in the `samples/cpp/tutorial_code/calib3d/camera_calibration/`
|
You may also find the source code in the `samples/cpp/tutorial_code/calib3d/camera_calibration/`
|
||||||
folder of the OpenCV source library or [download it from here
|
folder of the OpenCV source library or [download it from here
|
||||||
](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp). The program has a
|
](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp). The program has a
|
||||||
single argument: the name of its configuration file. If none is given then it will try to open the
|
single argument: the name of its configuration file. If none is given then it will try to open the
|
||||||
one named "default.xml". [Here's a sample configuration file
|
one named "default.xml". [Here's a sample configuration file
|
||||||
](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/calib3d/camera_calibration/in_VID5.xml) in XML format. In the
|
](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/calib3d/camera_calibration/in_VID5.xml) in XML format. In the
|
||||||
configuration file you may choose to use camera as an input, a video file or an image list. If you
|
configuration file you may choose to use camera as an input, a video file or an image list. If you
|
||||||
opt for the last one, you will need to create a configuration file where you enumerate the images to
|
opt for the last one, you will need to create a configuration file where you enumerate the images to
|
||||||
use. Here's [an example of this ](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/calib3d/camera_calibration/VID5.xml).
|
use. Here's [an example of this ](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/calib3d/camera_calibration/VID5.xml).
|
||||||
The important part to remember is that the images need to be specified using the absolute path or
|
The important part to remember is that the images need to be specified using the absolute path or
|
||||||
the relative one from your application's working directory. You may find all this in the samples
|
the relative one from your application's working directory. You may find all this in the samples
|
||||||
directory mentioned above.
|
directory mentioned above.
|
||||||
|
@ -92,7 +92,7 @@ QR faster than SVD, but potentially less precise
|
|||||||
- *camera_resolution*: resolution of camera which is used for calibration
|
- *camera_resolution*: resolution of camera which is used for calibration
|
||||||
|
|
||||||
**Note:** *charuco_dict*, *charuco_square_lenght* and *charuco_marker_size* are used for chAruco pattern generation
|
**Note:** *charuco_dict*, *charuco_square_lenght* and *charuco_marker_size* are used for chAruco pattern generation
|
||||||
(see Aruco module description for details: [Aruco tutorials](https://github.com/Itseez/opencv_contrib/tree/master/modules/aruco/tutorials))
|
(see Aruco module description for details: [Aruco tutorials](https://github.com/opencv/opencv_contrib/tree/master/modules/aruco/tutorials))
|
||||||
|
|
||||||
Default chAruco pattern:
|
Default chAruco pattern:
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ Code
|
|||||||
----
|
----
|
||||||
|
|
||||||
- This code is in your OpenCV sample folder. Otherwise you can grab it from
|
- This code is in your OpenCV sample folder. Otherwise you can grab it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/core/Matrix/Drawing_1.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/core/Matrix/Drawing_1.cpp)
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
-----------
|
-----------
|
||||||
|
@ -15,7 +15,7 @@ Source code
|
|||||||
-----------
|
-----------
|
||||||
|
|
||||||
You can [download this from here
|
You can [download this from here
|
||||||
](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/core/discrete_fourier_transform/discrete_fourier_transform.cpp) or
|
](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/core/discrete_fourier_transform/discrete_fourier_transform.cpp) or
|
||||||
find it in the
|
find it in the
|
||||||
`samples/cpp/tutorial_code/core/discrete_fourier_transform/discrete_fourier_transform.cpp` of the
|
`samples/cpp/tutorial_code/core/discrete_fourier_transform/discrete_fourier_transform.cpp` of the
|
||||||
OpenCV source code library.
|
OpenCV source code library.
|
||||||
@ -140,7 +140,7 @@ An application idea would be to determine the geometrical orientation present in
|
|||||||
example, let us find out if a text is horizontal or not? Looking at some text you'll notice that the
|
example, let us find out if a text is horizontal or not? Looking at some text you'll notice that the
|
||||||
text lines sort of form also horizontal lines and the letters form sort of vertical lines. These two
|
text lines sort of form also horizontal lines and the letters form sort of vertical lines. These two
|
||||||
main components of a text snippet may be also seen in case of the Fourier transform. Let us use
|
main components of a text snippet may be also seen in case of the Fourier transform. Let us use
|
||||||
[this horizontal ](https://github.com/Itseez/opencv/tree/master/samples/data/imageTextN.png) and [this rotated](https://github.com/Itseez/opencv/tree/master/samples/data/imageTextR.png)
|
[this horizontal ](https://github.com/opencv/opencv/tree/master/samples/data/imageTextN.png) and [this rotated](https://github.com/opencv/opencv/tree/master/samples/data/imageTextR.png)
|
||||||
image about a text.
|
image about a text.
|
||||||
|
|
||||||
In case of the horizontal text:
|
In case of the horizontal text:
|
||||||
|
@ -16,7 +16,7 @@ Source code
|
|||||||
-----------
|
-----------
|
||||||
|
|
||||||
You can [download this from here
|
You can [download this from here
|
||||||
](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/core/file_input_output/file_input_output.cpp) or find it in the
|
](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/core/file_input_output/file_input_output.cpp) or find it in the
|
||||||
`samples/cpp/tutorial_code/core/file_input_output/file_input_output.cpp` of the OpenCV source code
|
`samples/cpp/tutorial_code/core/file_input_output/file_input_output.cpp` of the OpenCV source code
|
||||||
library.
|
library.
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ three major ways of going through an image pixel by pixel. To make things a litt
|
|||||||
will make the scanning for each image using all of these methods, and print out how long it took.
|
will make the scanning for each image using all of these methods, and print out how long it took.
|
||||||
|
|
||||||
You can download the full source code [here
|
You can download the full source code [here
|
||||||
](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp) or look it up in
|
](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp) or look it up in
|
||||||
the samples directory of OpenCV at the cpp tutorial code for the core section. Its basic usage is:
|
the samples directory of OpenCV at the cpp tutorial code for the core section. Its basic usage is:
|
||||||
@code{.bash}
|
@code{.bash}
|
||||||
how_to_scan_images imageName.jpg intValueToReduce [G]
|
how_to_scan_images imageName.jpg intValueToReduce [G]
|
||||||
|
@ -16,7 +16,7 @@ Code
|
|||||||
|
|
||||||
You may also find the source code in the
|
You may also find the source code in the
|
||||||
`samples/cpp/tutorial_code/core/ippasync/ippasync_sample.cpp` file of the OpenCV source library or
|
`samples/cpp/tutorial_code/core/ippasync/ippasync_sample.cpp` file of the OpenCV source library or
|
||||||
download it from [here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/core/ippasync/ippasync_sample.cpp).
|
download it from [here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/core/ippasync/ippasync_sample.cpp).
|
||||||
|
|
||||||
@include cpp/tutorial_code/core/ippasync/ippasync_sample.cpp
|
@include cpp/tutorial_code/core/ippasync/ippasync_sample.cpp
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ L = Mat(pI);
|
|||||||
A case study
|
A case study
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Now that you have the basics done [here's](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp)
|
Now that you have the basics done [here's](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp)
|
||||||
an example that mixes the usage of the C interface with the C++ one. You will also find it in the
|
an example that mixes the usage of the C interface with the C++ one. You will also find it in the
|
||||||
sample directory of the OpenCV source code library at the
|
sample directory of the OpenCV source code library at the
|
||||||
`samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp` .
|
`samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp` .
|
||||||
@ -132,7 +132,7 @@ output:
|
|||||||
|
|
||||||
You may observe a runtime instance of this on the [YouTube
|
You may observe a runtime instance of this on the [YouTube
|
||||||
here](https://www.youtube.com/watch?v=qckm-zvo31w) and you can [download the source code from here
|
here](https://www.youtube.com/watch?v=qckm-zvo31w) and you can [download the source code from here
|
||||||
](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp)
|
](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp)
|
||||||
or find it in the
|
or find it in the
|
||||||
`samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp`
|
`samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp`
|
||||||
of the OpenCV source code library.
|
of the OpenCV source code library.
|
||||||
|
@ -133,7 +133,7 @@ For example:
|
|||||||
![](images/resultMatMaskFilter2D.png)
|
![](images/resultMatMaskFilter2D.png)
|
||||||
|
|
||||||
You can download this source code from [here
|
You can download this source code from [here
|
||||||
](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp) or look in the
|
](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp) or look in the
|
||||||
OpenCV source code libraries sample directory at
|
OpenCV source code libraries sample directory at
|
||||||
`samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp`.
|
`samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp`.
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ OpenCV offers support for output of other common OpenCV data structures too via
|
|||||||
![](images/MatBasicContainerOut15.png)
|
![](images/MatBasicContainerOut15.png)
|
||||||
|
|
||||||
Most of the samples here have been included in a small console application. You can download it from
|
Most of the samples here have been included in a small console application. You can download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp)
|
||||||
or in the core section of the cpp samples.
|
or in the core section of the cpp samples.
|
||||||
|
|
||||||
You can also find a quick video demonstration of this on
|
You can also find a quick video demonstration of this on
|
||||||
|
@ -16,7 +16,7 @@ Code
|
|||||||
----
|
----
|
||||||
|
|
||||||
This tutorial code's is shown lines below. You can also download it from
|
This tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/TrackingMotion/cornerSubPix_Demo.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/TrackingMotion/cornerSubPix_Demo.cpp)
|
||||||
@code{.cpp}
|
@code{.cpp}
|
||||||
#include "opencv2/highgui.hpp"
|
#include "opencv2/highgui.hpp"
|
||||||
#include "opencv2/imgproc.hpp"
|
#include "opencv2/imgproc.hpp"
|
||||||
|
@ -20,7 +20,7 @@ Code
|
|||||||
----
|
----
|
||||||
|
|
||||||
This tutorial code's is shown lines below. You can also download it from
|
This tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/TrackingMotion/cornerDetector_Demo.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/TrackingMotion/cornerDetector_Demo.cpp)
|
||||||
|
|
||||||
@include cpp/tutorial_code/TrackingMotion/cornerDetector_Demo.cpp
|
@include cpp/tutorial_code/TrackingMotion/cornerDetector_Demo.cpp
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ Code
|
|||||||
----
|
----
|
||||||
|
|
||||||
This tutorial code's is shown lines below. You can also download it from
|
This tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/TrackingMotion/goodFeaturesToTrack_Demo.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/TrackingMotion/goodFeaturesToTrack_Demo.cpp)
|
||||||
@code{.cpp}
|
@code{.cpp}
|
||||||
#include "opencv2/highgui.hpp"
|
#include "opencv2/highgui.hpp"
|
||||||
#include "opencv2/imgproc.hpp"
|
#include "opencv2/imgproc.hpp"
|
||||||
|
@ -119,7 +119,7 @@ Code
|
|||||||
----
|
----
|
||||||
|
|
||||||
This tutorial code's is shown lines below. You can also download it from
|
This tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/TrackingMotion/cornerHarris_Demo.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/TrackingMotion/cornerHarris_Demo.cpp)
|
||||||
@code{.cpp}
|
@code{.cpp}
|
||||||
#include "opencv2/highgui.hpp"
|
#include "opencv2/highgui.hpp"
|
||||||
#include "opencv2/imgproc.hpp"
|
#include "opencv2/imgproc.hpp"
|
||||||
|
@ -24,7 +24,7 @@ The source code
|
|||||||
|
|
||||||
You may also find the source code and these video file in the
|
You may also find the source code and these video file in the
|
||||||
`samples/cpp/tutorial_code/gpu/gpu-basics-similarity/gpu-basics-similarity` folder of the OpenCV
|
`samples/cpp/tutorial_code/gpu/gpu-basics-similarity/gpu-basics-similarity` folder of the OpenCV
|
||||||
source library or download it from [here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/gpu/gpu-basics-similarity/gpu-basics-similarity.cpp).
|
source library or download it from [here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/gpu/gpu-basics-similarity/gpu-basics-similarity.cpp).
|
||||||
The full source code is quite long (due to the controlling of the application via the command line
|
The full source code is quite long (due to the controlling of the application via the command line
|
||||||
arguments and performance measurement). Therefore, to avoid cluttering up these sections with those
|
arguments and performance measurement). Therefore, to avoid cluttering up these sections with those
|
||||||
you'll find here only the functions itself.
|
you'll find here only the functions itself.
|
||||||
|
@ -60,7 +60,7 @@ Code
|
|||||||
----
|
----
|
||||||
|
|
||||||
This tutorial code's is shown lines below. You can also download it from
|
This tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ImgProc/Morphology_1.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgProc/Morphology_1.cpp)
|
||||||
@include samples/cpp/tutorial_code/ImgProc/Morphology_1.cpp
|
@include samples/cpp/tutorial_code/ImgProc/Morphology_1.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -94,7 +94,7 @@ Code
|
|||||||
- Applies 4 different kinds of filters (explained in Theory) and show the filtered images
|
- Applies 4 different kinds of filters (explained in Theory) and show the filtered images
|
||||||
sequentially
|
sequentially
|
||||||
- **Downloadable code**: Click
|
- **Downloadable code**: Click
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ImgProc/Smoothing.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgProc/Smoothing.cpp)
|
||||||
- **Code at glance:**
|
- **Code at glance:**
|
||||||
@code{.cpp}
|
@code{.cpp}
|
||||||
#include "opencv2/imgproc.hpp"
|
#include "opencv2/imgproc.hpp"
|
||||||
|
@ -70,13 +70,13 @@ Code
|
|||||||
- **Downloadable code**:
|
- **Downloadable code**:
|
||||||
|
|
||||||
-# Click
|
-# Click
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/Histograms_Matching/calcBackProject_Demo1.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/Histograms_Matching/calcBackProject_Demo1.cpp)
|
||||||
for the basic version (explained in this tutorial).
|
for the basic version (explained in this tutorial).
|
||||||
-# For stuff slightly fancier (using H-S histograms and floodFill to define a mask for the
|
-# For stuff slightly fancier (using H-S histograms and floodFill to define a mask for the
|
||||||
skin area) you can check the [improved
|
skin area) you can check the [improved
|
||||||
demo](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/Histograms_Matching/calcBackProject_Demo2.cpp)
|
demo](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/Histograms_Matching/calcBackProject_Demo2.cpp)
|
||||||
-# ...or you can always check out the classical
|
-# ...or you can always check out the classical
|
||||||
[camshiftdemo](https://github.com/Itseez/opencv/tree/master/samples/cpp/camshiftdemo.cpp)
|
[camshiftdemo](https://github.com/opencv/opencv/tree/master/samples/cpp/camshiftdemo.cpp)
|
||||||
in samples.
|
in samples.
|
||||||
|
|
||||||
- **Code at glance:**
|
- **Code at glance:**
|
||||||
|
@ -66,7 +66,7 @@ Code
|
|||||||
- Calculate the Histogram of each 1-channel plane by calling the function @ref cv::calcHist
|
- Calculate the Histogram of each 1-channel plane by calling the function @ref cv::calcHist
|
||||||
- Plot the three histograms in a window
|
- Plot the three histograms in a window
|
||||||
- **Downloadable code**: Click
|
- **Downloadable code**: Click
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/Histograms_Matching/calcHist_Demo.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/Histograms_Matching/calcHist_Demo.cpp)
|
||||||
- **Code at glance:**
|
- **Code at glance:**
|
||||||
@include samples/cpp/tutorial_code/Histograms_Matching/calcHist_Demo.cpp
|
@include samples/cpp/tutorial_code/Histograms_Matching/calcHist_Demo.cpp
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ Code
|
|||||||
histogram of the lower half base image and with the same base image histogram.
|
histogram of the lower half base image and with the same base image histogram.
|
||||||
- Display the numerical matching parameters obtained.
|
- Display the numerical matching parameters obtained.
|
||||||
- **Downloadable code**: Click
|
- **Downloadable code**: Click
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/Histograms_Matching/compareHist_Demo.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/Histograms_Matching/compareHist_Demo.cpp)
|
||||||
- **Code at glance:**
|
- **Code at glance:**
|
||||||
|
|
||||||
@include cpp/tutorial_code/Histograms_Matching/compareHist_Demo.cpp
|
@include cpp/tutorial_code/Histograms_Matching/compareHist_Demo.cpp
|
||||||
|
@ -62,7 +62,7 @@ Code
|
|||||||
- Equalize the Histogram by using the OpenCV function @ref cv::equalizeHist
|
- Equalize the Histogram by using the OpenCV function @ref cv::equalizeHist
|
||||||
- Display the source and equalized images in a window.
|
- Display the source and equalized images in a window.
|
||||||
- **Downloadable code**: Click
|
- **Downloadable code**: Click
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/Histograms_Matching/EqualizeHist_Demo.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/Histograms_Matching/EqualizeHist_Demo.cpp)
|
||||||
- **Code at glance:**
|
- **Code at glance:**
|
||||||
@include samples/cpp/tutorial_code/Histograms_Matching/EqualizeHist_Demo.cpp
|
@include samples/cpp/tutorial_code/Histograms_Matching/EqualizeHist_Demo.cpp
|
||||||
|
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 77 KiB |
@ -19,6 +19,10 @@ Theory
|
|||||||
Template matching is a technique for finding areas of an image that match (are similar) to a
|
Template matching is a technique for finding areas of an image that match (are similar) to a
|
||||||
template image (patch).
|
template image (patch).
|
||||||
|
|
||||||
|
While the patch must be a rectangle it may be that not all of the
|
||||||
|
rectangle is relevant. In such a case, a mask can be used to isolate the portion of the patch
|
||||||
|
that should be used to find the match.
|
||||||
|
|
||||||
### How does it work?
|
### How does it work?
|
||||||
|
|
||||||
- We need two primary components:
|
- We need two primary components:
|
||||||
@ -51,6 +55,30 @@ template image (patch).
|
|||||||
- In practice, we use the function @ref cv::minMaxLoc to locate the highest value (or lower,
|
- In practice, we use the function @ref cv::minMaxLoc to locate the highest value (or lower,
|
||||||
depending of the type of matching method) in the *R* matrix.
|
depending of the type of matching method) in the *R* matrix.
|
||||||
|
|
||||||
|
### How does the mask work?
|
||||||
|
- If masking is needed for the match, three components are required:
|
||||||
|
|
||||||
|
-# **Source image (I):** The image in which we expect to find a match to the template image
|
||||||
|
-# **Template image (T):** The patch image which will be compared to the template image
|
||||||
|
-# **Mask image (M):** The mask, a grayscale image that masks the template
|
||||||
|
|
||||||
|
|
||||||
|
- Only two matching methods currently accept a mask: CV_TM_SQDIFF and CV_TM_CCORR_NORMED (see
|
||||||
|
below for explanation of all the matching methods available in opencv).
|
||||||
|
|
||||||
|
|
||||||
|
- The mask must have the same dimensions as the template
|
||||||
|
|
||||||
|
|
||||||
|
- The mask should have a CV_8U or CV_32F depth and the same number of channels
|
||||||
|
as the template image. In CV_8U case, the mask values are treated as binary,
|
||||||
|
i.e. zero and non-zero. In CV_32F case, the values should fall into [0..1]
|
||||||
|
range and the template pixels will be multiplied by the corresponding mask pixel
|
||||||
|
values. Since the input images in the sample have the CV_8UC3 type, the mask
|
||||||
|
is also read as color image.
|
||||||
|
|
||||||
|
![](images/Template_Matching_Mask_Example.jpg)
|
||||||
|
|
||||||
### Which are the matching methods available in OpenCV?
|
### Which are the matching methods available in OpenCV?
|
||||||
|
|
||||||
Good question. OpenCV implements Template matching in the function @ref cv::matchTemplate . The
|
Good question. OpenCV implements Template matching in the function @ref cv::matchTemplate . The
|
||||||
@ -88,15 +116,16 @@ Code
|
|||||||
----
|
----
|
||||||
|
|
||||||
- **What does this program do?**
|
- **What does this program do?**
|
||||||
- Loads an input image and a image patch (*template*)
|
- Loads an input image, an image patch (*template*), and optionally a mask
|
||||||
- Perform a template matching procedure by using the OpenCV function @ref cv::matchTemplate
|
- Perform a template matching procedure by using the OpenCV function @ref cv::matchTemplate
|
||||||
with any of the 6 matching methods described before. The user can choose the method by
|
with any of the 6 matching methods described before. The user can choose the method by
|
||||||
entering its selection in the Trackbar.
|
entering its selection in the Trackbar. If a mask is supplied, it will only be used for
|
||||||
|
the methods that support masking
|
||||||
- Normalize the output of the matching procedure
|
- Normalize the output of the matching procedure
|
||||||
- Localize the location with higher matching probability
|
- Localize the location with higher matching probability
|
||||||
- Draw a rectangle around the area corresponding to the highest match
|
- Draw a rectangle around the area corresponding to the highest match
|
||||||
- **Downloadable code**: Click
|
- **Downloadable code**: Click
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp)
|
||||||
- **Code at glance:**
|
- **Code at glance:**
|
||||||
@include samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp
|
@include samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp
|
||||||
|
|
||||||
@ -113,10 +142,14 @@ Explanation
|
|||||||
int match_method;
|
int match_method;
|
||||||
int max_Trackbar = 5;
|
int max_Trackbar = 5;
|
||||||
@endcode
|
@endcode
|
||||||
-# Load the source image and template:
|
-# Load the source image, template, and optionally, if supported for the matching method, a mask:
|
||||||
@code{.cpp}
|
@code{.cpp}
|
||||||
img = imread( argv[1], 1 );
|
bool method_accepts_mask = (CV_TM_SQDIFF == match_method || match_method == CV_TM_CCORR_NORMED);
|
||||||
templ = imread( argv[2], 1 );
|
if (use_mask && method_accepts_mask)
|
||||||
|
{ matchTemplate( img, templ, result, match_method, mask); }
|
||||||
|
else
|
||||||
|
{ matchTemplate( img, templ, result, match_method); }
|
||||||
|
|
||||||
@endcode
|
@endcode
|
||||||
-# Create the windows to show the results:
|
-# Create the windows to show the results:
|
||||||
@code{.cpp}
|
@code{.cpp}
|
||||||
@ -150,10 +183,14 @@ Explanation
|
|||||||
@endcode
|
@endcode
|
||||||
-# Perform the template matching operation:
|
-# Perform the template matching operation:
|
||||||
@code{.cpp}
|
@code{.cpp}
|
||||||
matchTemplate( img, templ, result, match_method );
|
bool method_accepts_mask = (CV_TM_SQDIFF == match_method || match_method == CV_TM_CCORR_NORMED);
|
||||||
|
if (use_mask && method_accepts_mask)
|
||||||
|
{ matchTemplate( img, templ, result, match_method, mask); }
|
||||||
|
else
|
||||||
|
{ matchTemplate( img, templ, result, match_method); }
|
||||||
@endcode
|
@endcode
|
||||||
the arguments are naturally the input image **I**, the template **T**, the result **R** and the
|
the arguments are naturally the input image **I**, the template **T**, the result **R**, the
|
||||||
match_method (given by the Trackbar)
|
match_method (given by the Trackbar), and optionally the mask image **M**
|
||||||
|
|
||||||
-# We normalize the results:
|
-# We normalize the results:
|
||||||
@code{.cpp}
|
@code{.cpp}
|
||||||
|
@ -74,7 +74,7 @@ Code
|
|||||||
- Applies the mask obtained on the original image and display it in a window.
|
- Applies the mask obtained on the original image and display it in a window.
|
||||||
|
|
||||||
-# The tutorial code's is shown lines below. You can also download it from
|
-# The tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/CannyDetector_Demo.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/CannyDetector_Demo.cpp)
|
||||||
@include samples/cpp/tutorial_code/ImgTrans/CannyDetector_Demo.cpp
|
@include samples/cpp/tutorial_code/ImgTrans/CannyDetector_Demo.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -46,7 +46,7 @@ Code
|
|||||||
- The program finishes when the user presses 'ESC'
|
- The program finishes when the user presses 'ESC'
|
||||||
|
|
||||||
-# The tutorial code's is shown lines below. You can also download it from
|
-# The tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp)
|
||||||
@include samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp
|
@include samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -17,7 +17,7 @@ Code
|
|||||||
----
|
----
|
||||||
|
|
||||||
This tutorial code's is shown lines below. You can also download it from
|
This tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp).
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp).
|
||||||
@include samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp
|
@include samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp
|
||||||
|
|
||||||
Explanation / Result
|
Explanation / Result
|
||||||
|
@ -62,7 +62,7 @@ Code
|
|||||||
- The filter output (with each kernel) will be shown during 500 milliseconds
|
- The filter output (with each kernel) will be shown during 500 milliseconds
|
||||||
|
|
||||||
-# The tutorial code's is shown lines below. You can also download it from
|
-# The tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/filter2D_demo.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/filter2D_demo.cpp)
|
||||||
@code{.cpp}
|
@code{.cpp}
|
||||||
#include "opencv2/imgproc.hpp"
|
#include "opencv2/imgproc.hpp"
|
||||||
#include "opencv2/highgui.hpp"
|
#include "opencv2/highgui.hpp"
|
||||||
|
@ -39,9 +39,9 @@ Code
|
|||||||
- Applies the *Hough Circle Transform* to the blurred image .
|
- Applies the *Hough Circle Transform* to the blurred image .
|
||||||
- Display the detected circle in a window.
|
- Display the detected circle in a window.
|
||||||
|
|
||||||
-# The sample code that we will explain can be downloaded from [here](https://github.com/Itseez/opencv/tree/master/samples/cpp/houghcircles.cpp).
|
-# The sample code that we will explain can be downloaded from [here](https://github.com/opencv/opencv/tree/master/samples/cpp/houghcircles.cpp).
|
||||||
A slightly fancier version (which shows trackbars for
|
A slightly fancier version (which shows trackbars for
|
||||||
changing the threshold values) can be found [here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/HoughCircle_Demo.cpp).
|
changing the threshold values) can be found [here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/HoughCircle_Demo.cpp).
|
||||||
@include samples/cpp/houghcircles.cpp
|
@include samples/cpp/houghcircles.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -95,9 +95,9 @@ Code
|
|||||||
- Applies either a *Standard Hough Line Transform* or a *Probabilistic Line Transform*.
|
- Applies either a *Standard Hough Line Transform* or a *Probabilistic Line Transform*.
|
||||||
- Display the original image and the detected line in two windows.
|
- Display the original image and the detected line in two windows.
|
||||||
|
|
||||||
-# The sample code that we will explain can be downloaded from [here](https://github.com/Itseez/opencv/tree/master/samples/cpp/houghlines.cpp). A slightly fancier version
|
-# The sample code that we will explain can be downloaded from [here](https://github.com/opencv/opencv/tree/master/samples/cpp/houghlines.cpp). A slightly fancier version
|
||||||
(which shows both Hough standard and probabilistic with trackbars for changing the threshold
|
(which shows both Hough standard and probabilistic with trackbars for changing the threshold
|
||||||
values) can be found [here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp).
|
values) can be found [here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp).
|
||||||
@include samples/cpp/houghlines.cpp
|
@include samples/cpp/houghlines.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -51,7 +51,7 @@ Code
|
|||||||
- Display the result in a window
|
- Display the result in a window
|
||||||
|
|
||||||
-# The tutorial code's is shown lines below. You can also download it from
|
-# The tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/Laplace_Demo.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/Laplace_Demo.cpp)
|
||||||
@include samples/cpp/tutorial_code/ImgTrans/Laplace_Demo.cpp
|
@include samples/cpp/tutorial_code/ImgTrans/Laplace_Demo.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -52,7 +52,7 @@ Code
|
|||||||
- Wait for the user to exit the program
|
- Wait for the user to exit the program
|
||||||
|
|
||||||
-# The tutorial code's is shown lines below. You can also download it from
|
-# The tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/Remap_Demo.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/Remap_Demo.cpp)
|
||||||
@include samples/cpp/tutorial_code/ImgTrans/Remap_Demo.cpp
|
@include samples/cpp/tutorial_code/ImgTrans/Remap_Demo.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -108,7 +108,7 @@ Code
|
|||||||
bright on a darker background.
|
bright on a darker background.
|
||||||
|
|
||||||
-# The tutorial code's is shown lines below. You can also download it from
|
-# The tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp)
|
||||||
@include samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp
|
@include samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -89,7 +89,7 @@ Code
|
|||||||
- Waits until the user exits the program
|
- Waits until the user exits the program
|
||||||
|
|
||||||
-# The tutorial code's is shown lines below. You can also download it from
|
-# The tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/Geometric_Transforms_Demo.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/Geometric_Transforms_Demo.cpp)
|
||||||
@include samples/cpp/tutorial_code/ImgTrans/Geometric_Transforms_Demo.cpp
|
@include samples/cpp/tutorial_code/ImgTrans/Geometric_Transforms_Demo.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -48,7 +48,7 @@ A structuring element can have many common shapes, such as lines, diamonds, disk
|
|||||||
Code
|
Code
|
||||||
----
|
----
|
||||||
|
|
||||||
This tutorial code's is shown lines below. You can also download it from [here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ImgProc/Morphology_3.cpp).
|
This tutorial code's is shown lines below. You can also download it from [here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgProc/Morphology_3.cpp).
|
||||||
@include samples/cpp/tutorial_code/ImgProc/Morphology_3.cpp
|
@include samples/cpp/tutorial_code/ImgProc/Morphology_3.cpp
|
||||||
|
|
||||||
Explanation / Result
|
Explanation / Result
|
||||||
|
@ -80,7 +80,7 @@ Code
|
|||||||
----
|
----
|
||||||
|
|
||||||
This tutorial code's is shown lines below. You can also download it from
|
This tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ImgProc/Morphology_2.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgProc/Morphology_2.cpp)
|
||||||
@code{.cpp}
|
@code{.cpp}
|
||||||
#include "opencv2/imgproc.hpp"
|
#include "opencv2/imgproc.hpp"
|
||||||
#include "opencv2/highgui.hpp"
|
#include "opencv2/highgui.hpp"
|
||||||
|
@ -66,7 +66,7 @@ Code
|
|||||||
----
|
----
|
||||||
|
|
||||||
This tutorial code's is shown lines below. You can also download it from
|
This tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ImgProc/Pyramids.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgProc/Pyramids.cpp)
|
||||||
|
|
||||||
@include samples/cpp/tutorial_code/ImgProc/Pyramids.cpp
|
@include samples/cpp/tutorial_code/ImgProc/Pyramids.cpp
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ Code
|
|||||||
----
|
----
|
||||||
|
|
||||||
This tutorial code's is shown lines below. You can also download it from
|
This tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ShapeDescriptors/generalContours_demo1.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ShapeDescriptors/generalContours_demo1.cpp)
|
||||||
@include samples/cpp/tutorial_code/ShapeDescriptors/generalContours_demo1.cpp
|
@include samples/cpp/tutorial_code/ShapeDescriptors/generalContours_demo1.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -16,7 +16,7 @@ Code
|
|||||||
----
|
----
|
||||||
|
|
||||||
This tutorial code's is shown lines below. You can also download it from
|
This tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ShapeDescriptors/generalContours_demo2.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ShapeDescriptors/generalContours_demo2.cpp)
|
||||||
@include samples/cpp/tutorial_code/ShapeDescriptors/generalContours_demo2.cpp
|
@include samples/cpp/tutorial_code/ShapeDescriptors/generalContours_demo2.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -16,7 +16,7 @@ Code
|
|||||||
----
|
----
|
||||||
|
|
||||||
This tutorial code's is shown lines below. You can also download it from
|
This tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ShapeDescriptors/findContours_demo.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ShapeDescriptors/findContours_demo.cpp)
|
||||||
@include samples/cpp/tutorial_code/ShapeDescriptors/findContours_demo.cpp
|
@include samples/cpp/tutorial_code/ShapeDescriptors/findContours_demo.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -15,7 +15,7 @@ Code
|
|||||||
----
|
----
|
||||||
|
|
||||||
This tutorial code's is shown lines below. You can also download it from
|
This tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ShapeDescriptors/hull_demo.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ShapeDescriptors/hull_demo.cpp)
|
||||||
|
|
||||||
@include samples/cpp/tutorial_code/ShapeDescriptors/hull_demo.cpp
|
@include samples/cpp/tutorial_code/ShapeDescriptors/hull_demo.cpp
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ Code
|
|||||||
----
|
----
|
||||||
|
|
||||||
This tutorial code's is shown lines below. You can also download it from
|
This tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ShapeDescriptors/moments_demo.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ShapeDescriptors/moments_demo.cpp)
|
||||||
@include samples/cpp/tutorial_code/ShapeDescriptors/moments_demo.cpp
|
@include samples/cpp/tutorial_code/ShapeDescriptors/moments_demo.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -15,7 +15,7 @@ Code
|
|||||||
----
|
----
|
||||||
|
|
||||||
This tutorial code's is shown lines below. You can also download it from
|
This tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ShapeDescriptors/pointPolygonTest_demo.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ShapeDescriptors/pointPolygonTest_demo.cpp)
|
||||||
@include samples/cpp/tutorial_code/ShapeDescriptors/pointPolygonTest_demo.cpp
|
@include samples/cpp/tutorial_code/ShapeDescriptors/pointPolygonTest_demo.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -97,7 +97,7 @@ Code
|
|||||||
----
|
----
|
||||||
|
|
||||||
The tutorial code's is shown lines below. You can also download it from
|
The tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ImgProc/Threshold.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgProc/Threshold.cpp)
|
||||||
@include samples/cpp/tutorial_code/ImgProc/Threshold.cpp
|
@include samples/cpp/tutorial_code/ImgProc/Threshold.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -19,7 +19,7 @@ Code
|
|||||||
----
|
----
|
||||||
|
|
||||||
The tutorial code's is shown lines below. You can also download it from
|
The tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ImgProc/Threshold_inRange.cpp)
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgProc/Threshold_inRange.cpp)
|
||||||
@include samples/cpp/tutorial_code/ImgProc/Threshold_inRange.cpp
|
@include samples/cpp/tutorial_code/ImgProc/Threshold_inRange.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -17,7 +17,7 @@ If you need help with anything of the above, you may refer to our @ref tutorial_
|
|||||||
This tutorial also assumes you have an Android operated device with OpenCL enabled.
|
This tutorial also assumes you have an Android operated device with OpenCL enabled.
|
||||||
|
|
||||||
The related source code is located within OpenCV samples at
|
The related source code is located within OpenCV samples at
|
||||||
[opencv/samples/android/tutorial-4-opencl](https://github.com/Itseez/opencv/tree/master/samples/android/tutorial-4-opencl/) directory.
|
[opencv/samples/android/tutorial-4-opencl](https://github.com/opencv/opencv/tree/master/samples/android/tutorial-4-opencl/) directory.
|
||||||
|
|
||||||
Preface
|
Preface
|
||||||
-------
|
-------
|
||||||
@ -244,7 +244,7 @@ As you can see, inheritors for `Camera` and `Camera2` APIs should implement the
|
|||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
Let's leave the details of their implementation beyond of this tutorial, please refer the
|
Let's leave the details of their implementation beyond of this tutorial, please refer the
|
||||||
[source code](https://github.com/Itseez/opencv/tree/master/samples/android/tutorial-4-opencl/) to see them.
|
[source code](https://github.com/opencv/opencv/tree/master/samples/android/tutorial-4-opencl/) to see them.
|
||||||
|
|
||||||
Preview Frames modification
|
Preview Frames modification
|
||||||
---------------------------
|
---------------------------
|
||||||
|
@ -40,7 +40,7 @@ I'm assuming you already installed [xcode](https://developer.apple.com/xcode/),
|
|||||||
@code{.bash}
|
@code{.bash}
|
||||||
cd ~/
|
cd ~/
|
||||||
mkdir opt
|
mkdir opt
|
||||||
git clone https://github.com/Itseez/opencv.git
|
git clone https://github.com/opencv/opencv.git
|
||||||
cd opencv
|
cd opencv
|
||||||
git checkout 2.4
|
git checkout 2.4
|
||||||
mkdir build
|
mkdir build
|
||||||
|
@ -33,7 +33,7 @@ Getting OpenCV Source Code
|
|||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
You can use the latest stable OpenCV version available in *sourceforge* or you can grab the latest
|
You can use the latest stable OpenCV version available in *sourceforge* or you can grab the latest
|
||||||
snapshot from our [Git repository](https://github.com/Itseez/opencv.git).
|
snapshot from our [Git repository](https://github.com/opencv/opencv.git).
|
||||||
|
|
||||||
### Getting the Latest Stable OpenCV Version
|
### Getting the Latest Stable OpenCV Version
|
||||||
|
|
||||||
@ -42,12 +42,12 @@ snapshot from our [Git repository](https://github.com/Itseez/opencv.git).
|
|||||||
|
|
||||||
### Getting the Cutting-edge OpenCV from the Git Repository
|
### Getting the Cutting-edge OpenCV from the Git Repository
|
||||||
|
|
||||||
Launch Git client and clone [OpenCV repository](http://github.com/itseez/opencv)
|
Launch Git client and clone [OpenCV repository](http://github.com/opencv/opencv)
|
||||||
|
|
||||||
In Linux it can be achieved with the following command in Terminal:
|
In Linux it can be achieved with the following command in Terminal:
|
||||||
@code{.bash}
|
@code{.bash}
|
||||||
cd ~/<my_working _directory>
|
cd ~/<my_working _directory>
|
||||||
git clone https://github.com/Itseez/opencv.git
|
git clone https://github.com/opencv/opencv.git
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
Building OpenCV
|
Building OpenCV
|
||||||
|
@ -36,7 +36,7 @@ from the [OpenCV SourceForge repository](http://sourceforge.net/projects/opencvl
|
|||||||
sources.
|
sources.
|
||||||
|
|
||||||
Another option to get OpenCV sources is to clone [OpenCV git
|
Another option to get OpenCV sources is to clone [OpenCV git
|
||||||
repository](https://github.com/Itseez/opencv/). In order to build OpenCV with Java bindings you need
|
repository](https://github.com/opencv/opencv/). In order to build OpenCV with Java bindings you need
|
||||||
JDK (Java Development Kit) (we recommend [Oracle/Sun JDK 6 or
|
JDK (Java Development Kit) (we recommend [Oracle/Sun JDK 6 or
|
||||||
7](http://www.oracle.com/technetwork/java/javase/downloads/)), [Apache Ant](http://ant.apache.org/)
|
7](http://www.oracle.com/technetwork/java/javase/downloads/)), [Apache Ant](http://ant.apache.org/)
|
||||||
and Python v2.6 or higher to be installed.
|
and Python v2.6 or higher to be installed.
|
||||||
@ -45,7 +45,7 @@ and Python v2.6 or higher to be installed.
|
|||||||
|
|
||||||
Let's build OpenCV:
|
Let's build OpenCV:
|
||||||
@code{.bash}
|
@code{.bash}
|
||||||
git clone git://github.com/Itseez/opencv.git
|
git clone git://github.com/opencv/opencv.git
|
||||||
cd opencv
|
cd opencv
|
||||||
git checkout 2.4
|
git checkout 2.4
|
||||||
mkdir build
|
mkdir build
|
||||||
|
@ -14,7 +14,7 @@ Source Code
|
|||||||
-----------
|
-----------
|
||||||
|
|
||||||
Download the source code from
|
Download the source code from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/introduction/display_image/display_image.cpp).
|
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/introduction/display_image/display_image.cpp).
|
||||||
|
|
||||||
@include cpp/tutorial_code/introduction/display_image/display_image.cpp
|
@include cpp/tutorial_code/introduction/display_image/display_image.cpp
|
||||||
|
|
||||||
|
@ -9,13 +9,13 @@ Required Packages
|
|||||||
|
|
||||||
### Getting the Cutting-edge OpenCV from Git Repository
|
### Getting the Cutting-edge OpenCV from Git Repository
|
||||||
|
|
||||||
Launch GIT client and clone OpenCV repository from [here](http://github.com/itseez/opencv)
|
Launch GIT client and clone OpenCV repository from [here](http://github.com/opencv/opencv)
|
||||||
|
|
||||||
In MacOS it can be done using the following command in Terminal:
|
In MacOS it can be done using the following command in Terminal:
|
||||||
|
|
||||||
@code{.bash}
|
@code{.bash}
|
||||||
cd ~/<my_working _directory>
|
cd ~/<my_working _directory>
|
||||||
git clone https://github.com/Itseez/opencv.git
|
git clone https://github.com/opencv/opencv.git
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
Building OpenCV from Source, using CMake and Command Line
|
Building OpenCV from Source, using CMake and Command Line
|
||||||
|
@ -16,6 +16,7 @@ Required Packages
|
|||||||
- [optional] libtbb2 libtbb-dev
|
- [optional] libtbb2 libtbb-dev
|
||||||
- [optional] libdc1394 2.x
|
- [optional] libdc1394 2.x
|
||||||
- [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev, libdc1394-22-dev
|
- [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev, libdc1394-22-dev
|
||||||
|
- [optional] CUDA Toolkit 6.5 or higher
|
||||||
|
|
||||||
The packages can be installed using a terminal and the following commands or by using Synaptic
|
The packages can be installed using a terminal and the following commands or by using Synaptic
|
||||||
Manager:
|
Manager:
|
||||||
@ -28,7 +29,7 @@ Getting OpenCV Source Code
|
|||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
You can use the latest stable OpenCV version or you can grab the latest snapshot from our [Git
|
You can use the latest stable OpenCV version or you can grab the latest snapshot from our [Git
|
||||||
repository](https://github.com/Itseez/opencv.git).
|
repository](https://github.com/opencv/opencv.git).
|
||||||
|
|
||||||
### Getting the Latest Stable OpenCV Version
|
### Getting the Latest Stable OpenCV Version
|
||||||
|
|
||||||
@ -37,14 +38,14 @@ repository](https://github.com/Itseez/opencv.git).
|
|||||||
|
|
||||||
### Getting the Cutting-edge OpenCV from the Git Repository
|
### Getting the Cutting-edge OpenCV from the Git Repository
|
||||||
|
|
||||||
Launch Git client and clone [OpenCV repository](http://github.com/itseez/opencv). If you need
|
Launch Git client and clone [OpenCV repository](http://github.com/opencv/opencv). If you need
|
||||||
modules from [OpenCV contrib repository](http://github.com/itseez/opencv_contrib) then clone it too.
|
modules from [OpenCV contrib repository](http://github.com/opencv/opencv_contrib) then clone it too.
|
||||||
|
|
||||||
For example
|
For example
|
||||||
@code{.bash}
|
@code{.bash}
|
||||||
cd ~/<my_working_directory>
|
cd ~/<my_working_directory>
|
||||||
git clone https://github.com/Itseez/opencv.git
|
git clone https://github.com/opencv/opencv.git
|
||||||
git clone https://github.com/Itseez/opencv_contrib.git
|
git clone https://github.com/opencv/opencv_contrib.git
|
||||||
@endcode
|
@endcode
|
||||||
Building OpenCV from Source Using CMake
|
Building OpenCV from Source Using CMake
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
@ -114,11 +115,11 @@ Building OpenCV from Source Using CMake
|
|||||||
-# [optional] Running tests
|
-# [optional] Running tests
|
||||||
|
|
||||||
- Get the required test data from [OpenCV extra
|
- Get the required test data from [OpenCV extra
|
||||||
repository](https://github.com/Itseez/opencv_extra).
|
repository](https://github.com/opencv/opencv_extra).
|
||||||
|
|
||||||
For example
|
For example
|
||||||
@code{.bash}
|
@code{.bash}
|
||||||
git clone https://github.com/Itseez/opencv_extra.git
|
git clone https://github.com/opencv/opencv_extra.git
|
||||||
@endcode
|
@endcode
|
||||||
- set OPENCV_TEST_DATA_PATH environment variable to \<path to opencv_extra/testdata\>.
|
- set OPENCV_TEST_DATA_PATH environment variable to \<path to opencv_extra/testdata\>.
|
||||||
- execute tests from build directory.
|
- execute tests from build directory.
|
||||||
|
@ -12,7 +12,7 @@ OpenCV 3.0 introduced many new algorithms and features comparing to version 2.4.
|
|||||||
This section describes most notable changes in general, all details and examples of transition actions are in the next part of the document.
|
This section describes most notable changes in general, all details and examples of transition actions are in the next part of the document.
|
||||||
|
|
||||||
##### Contrib repository
|
##### Contrib repository
|
||||||
<https://github.com/Itseez/opencv_contrib>
|
<https://github.com/opencv/opencv_contrib>
|
||||||
|
|
||||||
This is a place for all new, experimental and non-free algorithms. It does not receive so much attention from the support team comparing to main repository, but the community makes an effort to keep it in a good shape.
|
This is a place for all new, experimental and non-free algorithms. It does not receive so much attention from the support team comparing to main repository, but the community makes an effort to keep it in a good shape.
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ These videos above are long-obsolete and contain inaccurate information. Be care
|
|||||||
solutions described in those videos are no longer supported and may even break your install.
|
solutions described in those videos are no longer supported and may even break your install.
|
||||||
|
|
||||||
If you are building your own libraries you can take the source files from our [Git
|
If you are building your own libraries you can take the source files from our [Git
|
||||||
repository](https://github.com/Itseez/opencv.git).
|
repository](https://github.com/opencv/opencv.git).
|
||||||
|
|
||||||
Building the OpenCV library from scratch requires a couple of tools installed beforehand:
|
Building the OpenCV library from scratch requires a couple of tools installed beforehand:
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ libraries). If you do not need the support for some of these you can just freely
|
|||||||
you're doing -- it's OK.
|
you're doing -- it's OK.
|
||||||
-# Clone the repository to the selected directory. After clicking *Clone* button, a window will
|
-# Clone the repository to the selected directory. After clicking *Clone* button, a window will
|
||||||
appear where you can select from what repository you want to download source files
|
appear where you can select from what repository you want to download source files
|
||||||
(<https://github.com/Itseez/opencv.git>) and to what directory (`D:/OpenCV`).
|
(<https://github.com/opencv/opencv.git>) and to what directory (`D:/OpenCV`).
|
||||||
-# Push the OK button and be patient as the repository is quite a heavy download. It will take
|
-# Push the OK button and be patient as the repository is quite a heavy download. It will take
|
||||||
some time depending on your Internet connection.
|
some time depending on your Internet connection.
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ Test it!
|
|||||||
--------
|
--------
|
||||||
|
|
||||||
Now to try this out download our little test [source code
|
Now to try this out download our little test [source code
|
||||||
](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/introduction/windows_visual_studio_Opencv/introduction_windows_vs.cpp)
|
](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/introduction/windows_visual_studio_Opencv/introduction_windows_vs.cpp)
|
||||||
or get it from the sample code folder of the OpenCV sources. Add this to your project and build it.
|
or get it from the sample code folder of the OpenCV sources. Add this to your project and build it.
|
||||||
Here's its content:
|
Here's its content:
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ the *IDE* the console window will not close once finished. It will wait for a ke
|
|||||||
This is important to remember when you code inside the code open and save commands. You're resources
|
This is important to remember when you code inside the code open and save commands. You're resources
|
||||||
will be saved ( and queried for at opening!!!) relatively to your working directory. This is unless
|
will be saved ( and queried for at opening!!!) relatively to your working directory. This is unless
|
||||||
you give a full, explicit path as parameter for the I/O functions. In the code above we open [this
|
you give a full, explicit path as parameter for the I/O functions. In the code above we open [this
|
||||||
OpenCV logo](https://github.com/Itseez/opencv/tree/master/samples/data/opencv-logo.png). Before starting up the application make sure you place
|
OpenCV logo](https://github.com/opencv/opencv/tree/master/samples/data/opencv-logo.png). Before starting up the application make sure you place
|
||||||
the image file in your current working directory. Modify the image file name inside the code to try
|
the image file in your current working directory. Modify the image file name inside the code to try
|
||||||
it out on other images too. Run it and voil á:
|
it out on other images too. Run it and voil á:
|
||||||
|
|
||||||
|
@ -92,10 +92,10 @@ Source Code
|
|||||||
-----------
|
-----------
|
||||||
|
|
||||||
This tutorial code's is shown lines below. You can also download it from
|
This tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp).
|
[here](https://github.com/opencv/tree/master/samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp).
|
||||||
@include cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp
|
@include cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp
|
||||||
|
|
||||||
@note Another example using PCA for dimensionality reduction while maintaining an amount of variance can be found at [opencv_source_code/samples/cpp/pca.cpp](https://github.com/Itseez/opencv/tree/master/samples/cpp/pca.cpp)
|
@note Another example using PCA for dimensionality reduction while maintaining an amount of variance can be found at [opencv_source_code/samples/cpp/pca.cpp](https://github.com/opencv/tree/master/samples/cpp/pca.cpp)
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
-----------
|
-----------
|
||||||
|
@ -87,7 +87,7 @@ Source Code
|
|||||||
-----------
|
-----------
|
||||||
|
|
||||||
You may also find the source code in `samples/cpp/tutorial_code/ml/non_linear_svms` folder of the OpenCV source library or
|
You may also find the source code in `samples/cpp/tutorial_code/ml/non_linear_svms` folder of the OpenCV source library or
|
||||||
[download it from here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp).
|
[download it from here](https://github.com/opencv/tree/master/samples/cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp).
|
||||||
|
|
||||||
@note The following code has been implemented with OpenCV 3.0 classes and functions. An equivalent version of the code
|
@note The following code has been implemented with OpenCV 3.0 classes and functions. An equivalent version of the code
|
||||||
using OpenCV 2.4 can be found in [this page.](http://docs.opencv.org/2.4/doc/tutorials/ml/non_linear_svms/non_linear_svms.html#nonlinearsvms)
|
using OpenCV 2.4 can be found in [this page.](http://docs.opencv.org/2.4/doc/tutorials/ml/non_linear_svms/non_linear_svms.html#nonlinearsvms)
|
||||||
|
@ -18,9 +18,9 @@ Code
|
|||||||
----
|
----
|
||||||
|
|
||||||
This tutorial code's is shown lines below. You can also download it from
|
This tutorial code's is shown lines below. You can also download it from
|
||||||
[here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/objectDetection/objectDetection.cpp)
|
[here](https://github.com/opencv/tree/master/samples/cpp/tutorial_code/objectDetection/objectDetection.cpp)
|
||||||
. The second version (using LBP for face detection) can be [found
|
. The second version (using LBP for face detection) can be [found
|
||||||
here](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/objectDetection/objectDetection2.cpp)
|
here](https://github.com/opencv/tree/master/samples/cpp/tutorial_code/objectDetection/objectDetection2.cpp)
|
||||||
@code{.cpp}
|
@code{.cpp}
|
||||||
#include "opencv2/objdetect.hpp"
|
#include "opencv2/objdetect.hpp"
|
||||||
#include "opencv2/highgui.hpp"
|
#include "opencv2/highgui.hpp"
|
||||||
|
@ -6,7 +6,7 @@ Introduction
|
|||||||
|
|
||||||
The work with a cascade classifier inlcudes two major stages: training and detection. Detection
|
The work with a cascade classifier inlcudes two major stages: training and detection. Detection
|
||||||
stage is described in a documentation of objdetect module of general OpenCV documentation.
|
stage is described in a documentation of objdetect module of general OpenCV documentation.
|
||||||
Documentation gives some basic information about cascade classifier. Current guide is describing how
|
This documentation gives some basic information about cascade classifier. Current guide is describing how
|
||||||
to train a cascade classifier: preparation of the training data and running the training application.
|
to train a cascade classifier: preparation of the training data and running the training application.
|
||||||
|
|
||||||
### Important notes
|
### Important notes
|
||||||
@ -14,7 +14,7 @@ to train a cascade classifier: preparation of the training data and running the
|
|||||||
There are two applications in OpenCV to train cascade classifier: opencv_haartraining and
|
There are two applications in OpenCV to train cascade classifier: opencv_haartraining and
|
||||||
opencv_traincascade. opencv_traincascade is a newer version, written in C++ in accordance to
|
opencv_traincascade. opencv_traincascade is a newer version, written in C++ in accordance to
|
||||||
OpenCV 2.x API. But the main difference between this two applications is that opencv_traincascade
|
OpenCV 2.x API. But the main difference between this two applications is that opencv_traincascade
|
||||||
supports both Haar @cite Viola01 and @cite Liao2007 (Local Binary Patterns) features. LBP features
|
supports both Haar @cite Viola01 and LBP (Local Binary Patterns) @cite Liao2007 features. LBP features
|
||||||
are integer in contrast to Haar features, so both training and detection with LBP are several times
|
are integer in contrast to Haar features, so both training and detection with LBP are several times
|
||||||
faster then with Haar features. Regarding the LBP and Haar detection quality, it depends on
|
faster then with Haar features. Regarding the LBP and Haar detection quality, it depends on
|
||||||
training: the quality of training dataset first of all and training parameters too. It's possible to
|
training: the quality of training dataset first of all and training parameters too. It's possible to
|
||||||
@ -152,7 +152,7 @@ Command line arguments:
|
|||||||
Height (in pixels) of the output samples.
|
Height (in pixels) of the output samples.
|
||||||
|
|
||||||
For following procedure is used to create a sample object instance: The source image is rotated
|
For following procedure is used to create a sample object instance: The source image is rotated
|
||||||
randomly around all three axes. The chosen angle is limited my -max?angle. Then pixels having the
|
randomly around all three axes. The chosen angle is limited by -maxxangle, -maxyangle and maxzangle. Then pixels having the
|
||||||
intensity from [bg_color-bg_color_threshold; bg_color+bg_color_threshold] range are
|
intensity from [bg_color-bg_color_threshold; bg_color+bg_color_threshold] range are
|
||||||
interpreted as transparent. White noise is added to the intensities of the foreground. If the -inv
|
interpreted as transparent. White noise is added to the intensities of the foreground. If the -inv
|
||||||
key is specified then foreground pixel intensities are inverted. If -randinv key is specified then
|
key is specified then foreground pixel intensities are inverted. If -randinv key is specified then
|
||||||
@ -288,12 +288,12 @@ Command line arguments of opencv_traincascade application grouped by purposes:
|
|||||||
- -minHitRate \<min_hit_rate\>
|
- -minHitRate \<min_hit_rate\>
|
||||||
|
|
||||||
Minimal desired hit rate for each stage of the classifier. Overall hit rate may be estimated
|
Minimal desired hit rate for each stage of the classifier. Overall hit rate may be estimated
|
||||||
as (min_hit_rate\^number_of_stages).
|
as (min_hit_rate ^ number_of_stages), @cite Viola04 §4.1.
|
||||||
|
|
||||||
- -maxFalseAlarmRate \<max_false_alarm_rate\>
|
- -maxFalseAlarmRate \<max_false_alarm_rate\>
|
||||||
|
|
||||||
Maximal desired false alarm rate for each stage of the classifier. Overall false alarm rate
|
Maximal desired false alarm rate for each stage of the classifier. Overall false alarm rate
|
||||||
may be estimated as (max_false_alarm_rate\^number_of_stages).
|
may be estimated as (max_false_alarm_rate ^ number_of_stages), @cite Viola04 §4.1.
|
||||||
|
|
||||||
- -weightTrimRate \<weight_trim_rate\>
|
- -weightTrimRate \<weight_trim_rate\>
|
||||||
|
|
||||||
@ -326,4 +326,4 @@ in cascade.xml file in the folder, which was passed as -data parameter. Other fi
|
|||||||
are created for the case of interrupted training, so you may delete them after completion of
|
are created for the case of interrupted training, so you may delete them after completion of
|
||||||
training.
|
training.
|
||||||
|
|
||||||
Training is finished and you can test you cascade classifier!
|
Training is finished and you can test your cascade classifier!
|
||||||
|
@ -45,7 +45,7 @@ Two different methods are used to generate two foreground masks:
|
|||||||
-# @ref cv::BackgroundSubtractorMOG2
|
-# @ref cv::BackgroundSubtractorMOG2
|
||||||
|
|
||||||
The results as well as the input data are shown on the screen.
|
The results as well as the input data are shown on the screen.
|
||||||
The source file can be downloaded [here ](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/video/bg_sub.cpp).
|
The source file can be downloaded [here ](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/video/bg_sub.cpp).
|
||||||
|
|
||||||
@include samples/cpp/tutorial_code/video/bg_sub.cpp
|
@include samples/cpp/tutorial_code/video/bg_sub.cpp
|
||||||
|
|
||||||
|
@ -78,5 +78,5 @@ there are two flags that should be used to set/get property of the needed genera
|
|||||||
flag value is assumed by default if neither of the two possible values of the property is set.
|
flag value is assumed by default if neither of the two possible values of the property is set.
|
||||||
|
|
||||||
For more information please refer to the example of usage
|
For more information please refer to the example of usage
|
||||||
[intelperc_capture.cpp](https://github.com/Itseez/opencv/tree/master/samples/cpp/intelperc_capture.cpp)
|
[intelperc_capture.cpp](https://github.com/opencv/tree/master/samples/cpp/intelperc_capture.cpp)
|
||||||
in opencv/samples/cpp folder.
|
in opencv/samples/cpp folder.
|
||||||
|
@ -134,5 +134,5 @@ property. The following properties of cameras available through OpenNI interface
|
|||||||
- CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_REGISTRATION
|
- CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_REGISTRATION
|
||||||
|
|
||||||
For more information please refer to the example of usage
|
For more information please refer to the example of usage
|
||||||
[openni_capture.cpp](https://github.com/Itseez/opencv/tree/master/samples/cpp/openni_capture.cpp) in
|
[openni_capture.cpp](https://github.com/opencv/tree/master/samples/cpp/openni_capture.cpp) in
|
||||||
opencv/samples/cpp folder.
|
opencv/samples/cpp folder.
|
||||||
|
@ -20,8 +20,8 @@ As a test case where to show off these using OpenCV I've created a small program
|
|||||||
video files and performs a similarity check between them. This is something you could use to check
|
video files and performs a similarity check between them. This is something you could use to check
|
||||||
just how well a new video compressing algorithms works. Let there be a reference (original) video
|
just how well a new video compressing algorithms works. Let there be a reference (original) video
|
||||||
like [this small Megamind clip
|
like [this small Megamind clip
|
||||||
](https://github.com/Itseez/opencv/tree/master/samples/data/Megamind.avi) and [a compressed
|
](https://github.com/opencv/opencv/tree/master/samples/data/Megamind.avi) and [a compressed
|
||||||
version of it ](https://github.com/Itseez/opencv/tree/master/samples/data/Megamind_bugy.avi).
|
version of it ](https://github.com/opencv/opencv/tree/master/samples/data/Megamind_bugy.avi).
|
||||||
You may also find the source code and these video file in the
|
You may also find the source code and these video file in the
|
||||||
`samples/data` folder of the OpenCV source library.
|
`samples/data` folder of the OpenCV source library.
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ The source code
|
|||||||
|
|
||||||
You may also find the source code and these video file in the
|
You may also find the source code and these video file in the
|
||||||
`samples/cpp/tutorial_code/videoio/video-write/` folder of the OpenCV source library or [download it
|
`samples/cpp/tutorial_code/videoio/video-write/` folder of the OpenCV source library or [download it
|
||||||
from here ](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/videoio/video-write/video-write.cpp).
|
from here ](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/videoio/video-write/video-write.cpp).
|
||||||
|
|
||||||
@include cpp/tutorial_code/videoio/video-write/video-write.cpp
|
@include cpp/tutorial_code/videoio/video-write/video-write.cpp
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ In this tutorial you will learn how to
|
|||||||
Code
|
Code
|
||||||
----
|
----
|
||||||
|
|
||||||
You can download the code from [here ](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/viz/creating_widgets.cpp).
|
You can download the code from [here ](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/viz/creating_widgets.cpp).
|
||||||
@include samples/cpp/tutorial_code/viz/creating_widgets.cpp
|
@include samples/cpp/tutorial_code/viz/creating_widgets.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -14,7 +14,7 @@ In this tutorial you will learn how to
|
|||||||
Code
|
Code
|
||||||
----
|
----
|
||||||
|
|
||||||
You can download the code from [here ](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/viz/launching_viz.cpp).
|
You can download the code from [here ](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/viz/launching_viz.cpp).
|
||||||
@include samples/cpp/tutorial_code/viz/launching_viz.cpp
|
@include samples/cpp/tutorial_code/viz/launching_viz.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -13,7 +13,7 @@ In this tutorial you will learn how to
|
|||||||
Code
|
Code
|
||||||
----
|
----
|
||||||
|
|
||||||
You can download the code from [here ](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/viz/transformations.cpp).
|
You can download the code from [here ](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/viz/transformations.cpp).
|
||||||
@include samples/cpp/tutorial_code/viz/transformations.cpp
|
@include samples/cpp/tutorial_code/viz/transformations.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -13,7 +13,7 @@ In this tutorial you will learn how to
|
|||||||
Code
|
Code
|
||||||
----
|
----
|
||||||
|
|
||||||
You can download the code from [here ](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/viz/widget_pose.cpp).
|
You can download the code from [here ](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/viz/widget_pose.cpp).
|
||||||
@include samples/cpp/tutorial_code/viz/widget_pose.cpp
|
@include samples/cpp/tutorial_code/viz/widget_pose.cpp
|
||||||
|
|
||||||
Explanation
|
Explanation
|
||||||
|
@ -59,23 +59,27 @@
|
|||||||
|
|
||||||
\************************************************************************************/
|
\************************************************************************************/
|
||||||
|
|
||||||
|
/************************************************************************************\
|
||||||
|
This version adds a new and improved variant of chessboard corner detection
|
||||||
|
that works better in poor lighting condition. It is based on work from
|
||||||
|
Oliver Schreer and Stefano Masneri. This method works faster than the previous
|
||||||
|
one and reverts back to the older method in case no chessboard detection is
|
||||||
|
possible. Overall performance improves also because now the method avoids
|
||||||
|
performing the same computation multiple times when not necessary.
|
||||||
|
|
||||||
|
\************************************************************************************/
|
||||||
|
|
||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
#include "opencv2/imgproc/imgproc_c.h"
|
#include "opencv2/imgproc/imgproc_c.h"
|
||||||
#include "opencv2/calib3d/calib3d_c.h"
|
#include "opencv2/calib3d/calib3d_c.h"
|
||||||
#include "circlesgrid.hpp"
|
#include "circlesgrid.hpp"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
//#define ENABLE_TRIM_COL_ROW
|
//#define ENABLE_TRIM_COL_ROW
|
||||||
|
|
||||||
//#define DEBUG_CHESSBOARD
|
//#define DEBUG_CHESSBOARD
|
||||||
#ifdef DEBUG_CHESSBOARD
|
|
||||||
# include "opencv2/opencv_modules.hpp"
|
|
||||||
# ifdef HAVE_OPENCV_HIGHGUI
|
|
||||||
# include "opencv2/highgui.hpp"
|
|
||||||
# else
|
|
||||||
# undef DEBUG_CHESSBOARD
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#ifdef DEBUG_CHESSBOARD
|
#ifdef DEBUG_CHESSBOARD
|
||||||
static int PRINTF( const char* fmt, ... )
|
static int PRINTF( const char* fmt, ... )
|
||||||
{
|
{
|
||||||
@ -191,38 +195,204 @@ static void icvRemoveQuadFromGroup(CvCBQuad **quads, int count, CvCBQuad *q0);
|
|||||||
|
|
||||||
static int icvCheckBoardMonotony( CvPoint2D32f* corners, CvSize pattern_size );
|
static int icvCheckBoardMonotony( CvPoint2D32f* corners, CvSize pattern_size );
|
||||||
|
|
||||||
#if 0
|
int cvCheckChessboardBinary(IplImage* src, CvSize size);
|
||||||
static void
|
|
||||||
icvCalcAffineTranf2D32f(CvPoint2D32f* pts1, CvPoint2D32f* pts2, int count, CvMat* affine_trans)
|
/***************************************************************************************************/
|
||||||
|
//COMPUTE INTENSITY HISTOGRAM OF INPUT IMAGE
|
||||||
|
static int icvGetIntensityHistogram( unsigned char* pucImage, int iSizeCols, int iSizeRows, std::vector<int>& piHist );
|
||||||
|
//SMOOTH HISTOGRAM USING WINDOW OF SIZE 2*iWidth+1
|
||||||
|
static int icvSmoothHistogram( const std::vector<int>& piHist, std::vector<int>& piHistSmooth, int iWidth );
|
||||||
|
//COMPUTE FAST HISTOGRAM GRADIENT
|
||||||
|
static int icvGradientOfHistogram( const std::vector<int>& piHist, std::vector<int>& piHistGrad );
|
||||||
|
//PERFORM SMART IMAGE THRESHOLDING BASED ON ANALYSIS OF INTENSTY HISTOGRAM
|
||||||
|
static bool icvBinarizationHistogramBased( unsigned char* pucImg, int iCols, int iRows );
|
||||||
|
/***************************************************************************************************/
|
||||||
|
int icvGetIntensityHistogram( unsigned char* pucImage, int iSizeCols, int iSizeRows, std::vector<int>& piHist )
|
||||||
{
|
{
|
||||||
int i, j;
|
int iVal;
|
||||||
int real_count = 0;
|
|
||||||
for( j = 0; j < count; j++ )
|
// sum up all pixel in row direction and divide by number of columns
|
||||||
|
for ( int j=0; j<iSizeRows; j++ )
|
||||||
|
{
|
||||||
|
for ( int i=0; i<iSizeCols; i++ )
|
||||||
{
|
{
|
||||||
if( pts1[j].x >= 0 ) real_count++;
|
iVal = (int)pucImage[j*iSizeCols+i];
|
||||||
|
piHist[iVal]++;
|
||||||
}
|
}
|
||||||
if(real_count < 3) return;
|
}
|
||||||
cv::Ptr<CvMat> xy = cvCreateMat( 2*real_count, 6, CV_32FC1 );
|
return 0;
|
||||||
cv::Ptr<CvMat> uv = cvCreateMat( 2*real_count, 1, CV_32FC1 );
|
}
|
||||||
//estimate affine transfromation
|
/***************************************************************************************************/
|
||||||
for( i = 0, j = 0; j < count; j++ )
|
int icvSmoothHistogram( const std::vector<int>& piHist, std::vector<int>& piHistSmooth, int iWidth )
|
||||||
|
{
|
||||||
|
int iIdx;
|
||||||
|
for ( int i=0; i<256; i++)
|
||||||
|
{
|
||||||
|
int iSmooth = 0;
|
||||||
|
for ( int ii=-iWidth; ii<=iWidth; ii++)
|
||||||
{
|
{
|
||||||
if( pts1[j].x >= 0 )
|
iIdx = i+ii;
|
||||||
{
|
if (iIdx > 0 && iIdx < 256)
|
||||||
CV_MAT_ELEM( *xy, float, i*2+1, 2 ) = CV_MAT_ELEM( *xy, float, i*2, 0 ) = pts2[j].x;
|
{
|
||||||
CV_MAT_ELEM( *xy, float, i*2+1, 3 ) = CV_MAT_ELEM( *xy, float, i*2, 1 ) = pts2[j].y;
|
iSmooth += piHist[iIdx];
|
||||||
CV_MAT_ELEM( *xy, float, i*2, 2 ) = CV_MAT_ELEM( *xy, float, i*2, 3 ) = CV_MAT_ELEM( *xy, float, i*2, 5 ) = \
|
}
|
||||||
CV_MAT_ELEM( *xy, float, i*2+1, 0 ) = CV_MAT_ELEM( *xy, float, i*2+1, 1 ) = CV_MAT_ELEM( *xy, float, i*2+1, 4 ) = 0;
|
}
|
||||||
CV_MAT_ELEM( *xy, float, i*2, 4 ) = CV_MAT_ELEM( *xy, float, i*2+1, 5 ) = 1;
|
piHistSmooth[i] = iSmooth/(2*iWidth+1);
|
||||||
CV_MAT_ELEM( *uv, float, i*2, 0 ) = pts1[j].x;
|
}
|
||||||
CV_MAT_ELEM( *uv, float, i*2+1, 0 ) = pts1[j].y;
|
return 0;
|
||||||
i++;
|
}
|
||||||
}
|
/***************************************************************************************************/
|
||||||
|
int icvGradientOfHistogram( const std::vector<int>& piHist, std::vector<int>& piHistGrad )
|
||||||
|
{
|
||||||
|
piHistGrad[0] = 0;
|
||||||
|
for ( int i=1; i<255; i++)
|
||||||
|
{
|
||||||
|
piHistGrad[i] = piHist[i-1] - piHist[i+1];
|
||||||
|
if ( abs(piHistGrad[i]) < 100 )
|
||||||
|
{
|
||||||
|
if ( piHistGrad[i-1] == 0)
|
||||||
|
piHistGrad[i] = -100;
|
||||||
|
else
|
||||||
|
piHistGrad[i] = piHistGrad[i-1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/***************************************************************************************************/
|
||||||
|
bool icvBinarizationHistogramBased( unsigned char* pucImg, int iCols, int iRows )
|
||||||
|
{
|
||||||
|
int iMaxPix = iCols*iRows;
|
||||||
|
int iMaxPix1 = iMaxPix/100;
|
||||||
|
const int iNumBins = 256;
|
||||||
|
std::vector<int> piHistIntensity(iNumBins, 0);
|
||||||
|
std::vector<int> piHistSmooth(iNumBins, 0);
|
||||||
|
std::vector<int> piHistGrad(iNumBins, 0);
|
||||||
|
std::vector<int> piAccumSum(iNumBins, 0);
|
||||||
|
std::vector<int> piMaxPos(20, 0);
|
||||||
|
int iThresh = 0;
|
||||||
|
int iIdx;
|
||||||
|
int iWidth = 1;
|
||||||
|
|
||||||
|
icvGetIntensityHistogram( pucImg, iCols, iRows, piHistIntensity );
|
||||||
|
|
||||||
|
// get accumulated sum starting from bright
|
||||||
|
piAccumSum[iNumBins-1] = piHistIntensity[iNumBins-1];
|
||||||
|
for ( int i=iNumBins-2; i>=0; i-- )
|
||||||
|
{
|
||||||
|
piAccumSum[i] = piHistIntensity[i] + piAccumSum[i+1];
|
||||||
|
}
|
||||||
|
|
||||||
|
// first smooth the distribution
|
||||||
|
icvSmoothHistogram( piHistIntensity, piHistSmooth, iWidth );
|
||||||
|
|
||||||
|
// compute gradient
|
||||||
|
icvGradientOfHistogram( piHistSmooth, piHistGrad );
|
||||||
|
|
||||||
|
// check for zeros
|
||||||
|
int iCntMaxima = 0;
|
||||||
|
for ( int i=iNumBins-2; (i>2) && (iCntMaxima<20); i--)
|
||||||
|
{
|
||||||
|
if ( (piHistGrad[i-1] < 0) && (piHistGrad[i] > 0) )
|
||||||
|
{
|
||||||
|
piMaxPos[iCntMaxima] = i;
|
||||||
|
iCntMaxima++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
iIdx = 0;
|
||||||
|
int iSumAroundMax = 0;
|
||||||
|
for ( int i=0; i<iCntMaxima; i++ )
|
||||||
|
{
|
||||||
|
iIdx = piMaxPos[i];
|
||||||
|
iSumAroundMax = piHistSmooth[iIdx-1] + piHistSmooth[iIdx] + piHistSmooth[iIdx+1];
|
||||||
|
if ( iSumAroundMax < iMaxPix1 && iIdx < 64 )
|
||||||
|
{
|
||||||
|
for ( int j=i; j<iCntMaxima-1; j++ )
|
||||||
|
{
|
||||||
|
piMaxPos[j] = piMaxPos[j+1];
|
||||||
|
}
|
||||||
|
iCntMaxima--;
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( iCntMaxima == 1)
|
||||||
|
{
|
||||||
|
iThresh = piMaxPos[0]/2;
|
||||||
|
}
|
||||||
|
else if ( iCntMaxima == 2)
|
||||||
|
{
|
||||||
|
iThresh = (piMaxPos[0] + piMaxPos[1])/2;
|
||||||
|
}
|
||||||
|
else // iCntMaxima >= 3
|
||||||
|
{
|
||||||
|
// CHECKING THRESHOLD FOR WHITE
|
||||||
|
int iIdxAccSum = 0, iAccum = 0;
|
||||||
|
for (int i=iNumBins-1; i>0; i--)
|
||||||
|
{
|
||||||
|
iAccum += piHistIntensity[i];
|
||||||
|
// iMaxPix/18 is about 5,5%, minimum required number of pixels required for white part of chessboard
|
||||||
|
if ( iAccum > (iMaxPix/18) )
|
||||||
|
{
|
||||||
|
iIdxAccSum = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cvSolve( xy, uv, affine_trans, CV_SVD );
|
int iIdxBGMax = 0;
|
||||||
|
int iBrightMax = piMaxPos[0];
|
||||||
|
// printf("iBrightMax = %d\n", iBrightMax);
|
||||||
|
for ( int n=0; n<iCntMaxima-1; n++)
|
||||||
|
{
|
||||||
|
iIdxBGMax = n+1;
|
||||||
|
if ( piMaxPos[n] < iIdxAccSum )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
iBrightMax = piMaxPos[n];
|
||||||
|
}
|
||||||
|
|
||||||
|
// CHECKING THRESHOLD FOR BLACK
|
||||||
|
int iMaxVal = piHistIntensity[piMaxPos[iIdxBGMax]];
|
||||||
|
|
||||||
|
//IF TOO CLOSE TO 255, jump to next maximum
|
||||||
|
if ( piMaxPos[iIdxBGMax] >= 250 && iIdxBGMax < iCntMaxima )
|
||||||
|
{
|
||||||
|
iIdxBGMax++;
|
||||||
|
iMaxVal = piHistIntensity[piMaxPos[iIdxBGMax]];
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( int n=iIdxBGMax + 1; n<iCntMaxima; n++)
|
||||||
|
{
|
||||||
|
if ( piHistIntensity[piMaxPos[n]] >= iMaxVal )
|
||||||
|
{
|
||||||
|
iMaxVal = piHistIntensity[piMaxPos[n]];
|
||||||
|
iIdxBGMax = n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//SETTING THRESHOLD FOR BINARIZATION
|
||||||
|
int iDist2 = (iBrightMax - piMaxPos[iIdxBGMax])/2;
|
||||||
|
iThresh = iBrightMax - iDist2;
|
||||||
|
PRINTF("THRESHOLD SELECTED = %d, BRIGHTMAX = %d, DARKMAX = %d\n", iThresh, iBrightMax, piMaxPos[iIdxBGMax]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ( iThresh > 0 )
|
||||||
|
{
|
||||||
|
for ( int jj=0; jj<iRows; jj++)
|
||||||
|
{
|
||||||
|
for ( int ii=0; ii<iCols; ii++)
|
||||||
|
{
|
||||||
|
if ( pucImg[jj*iCols+ii]< iThresh )
|
||||||
|
pucImg[jj*iCols+ii] = 0;
|
||||||
|
else
|
||||||
|
pucImg[jj*iCols+ii] = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
CV_IMPL
|
CV_IMPL
|
||||||
int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
|
int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
|
||||||
@ -232,6 +402,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
|
|||||||
int found = 0;
|
int found = 0;
|
||||||
CvCBQuad *quads = 0, **quad_group = 0;
|
CvCBQuad *quads = 0, **quad_group = 0;
|
||||||
CvCBCorner *corners = 0, **corner_group = 0;
|
CvCBCorner *corners = 0, **corner_group = 0;
|
||||||
|
IplImage* cImgSeg = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -239,14 +410,14 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
|
|||||||
const int min_dilations = 0;
|
const int min_dilations = 0;
|
||||||
const int max_dilations = 7;
|
const int max_dilations = 7;
|
||||||
cv::Ptr<CvMat> norm_img, thresh_img;
|
cv::Ptr<CvMat> norm_img, thresh_img;
|
||||||
#ifdef DEBUG_CHESSBOARD
|
|
||||||
cv::Ptr<IplImage> dbg_img;
|
|
||||||
cv::Ptr<IplImage> dbg1_img;
|
|
||||||
cv::Ptr<IplImage> dbg2_img;
|
|
||||||
#endif
|
|
||||||
cv::Ptr<CvMemStorage> storage;
|
cv::Ptr<CvMemStorage> storage;
|
||||||
|
|
||||||
CvMat stub, *img = (CvMat*)arr;
|
CvMat stub, *img = (CvMat*)arr;
|
||||||
|
cImgSeg = cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 1 );
|
||||||
|
memcpy( cImgSeg->imageData, cvPtr1D( img, 0), img->rows*img->cols );
|
||||||
|
|
||||||
|
CvMat stub2, *thresh_img_new;
|
||||||
|
thresh_img_new = cvGetMat( cImgSeg, &stub2, 0, 0 );
|
||||||
|
|
||||||
int expected_corners_num = (pattern_size.width/2+1)*(pattern_size.height/2+1);
|
int expected_corners_num = (pattern_size.width/2+1)*(pattern_size.height/2+1);
|
||||||
|
|
||||||
@ -255,7 +426,6 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
|
|||||||
if( out_corner_count )
|
if( out_corner_count )
|
||||||
*out_corner_count = 0;
|
*out_corner_count = 0;
|
||||||
|
|
||||||
IplImage _img;
|
|
||||||
int quad_count = 0, group_idx = 0, dilations = 0;
|
int quad_count = 0, group_idx = 0, dilations = 0;
|
||||||
|
|
||||||
img = cvGetMat( img, &stub );
|
img = cvGetMat( img, &stub );
|
||||||
@ -273,12 +443,6 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
|
|||||||
storage.reset(cvCreateMemStorage(0));
|
storage.reset(cvCreateMemStorage(0));
|
||||||
thresh_img.reset(cvCreateMat( img->rows, img->cols, CV_8UC1 ));
|
thresh_img.reset(cvCreateMat( img->rows, img->cols, CV_8UC1 ));
|
||||||
|
|
||||||
#ifdef DEBUG_CHESSBOARD
|
|
||||||
dbg_img = cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 3 );
|
|
||||||
dbg1_img = cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 3 );
|
|
||||||
dbg2_img = cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 3 );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( CV_MAT_CN(img->type) != 1 || (flags & CV_CALIB_CB_NORMALIZE_IMAGE) )
|
if( CV_MAT_CN(img->type) != 1 || (flags & CV_CALIB_CB_NORMALIZE_IMAGE) )
|
||||||
{
|
{
|
||||||
// equalize the input image histogram -
|
// equalize the input image histogram -
|
||||||
@ -300,11 +464,19 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
|
|||||||
|
|
||||||
if( flags & CV_CALIB_CB_FAST_CHECK)
|
if( flags & CV_CALIB_CB_FAST_CHECK)
|
||||||
{
|
{
|
||||||
cvGetImage(img, &_img);
|
//perform new method for checking chessboard using a binary image.
|
||||||
int check_chessboard_result = cvCheckChessboard(&_img, pattern_size);
|
//image is binarised using a threshold dependent on the image histogram
|
||||||
if(check_chessboard_result <= 0)
|
icvBinarizationHistogramBased( (unsigned char*) cImgSeg->imageData, cImgSeg->width, cImgSeg->height );
|
||||||
|
int check_chessboard_result = cvCheckChessboardBinary(cImgSeg, pattern_size);
|
||||||
|
if(check_chessboard_result <= 0) //fall back to the old method
|
||||||
{
|
{
|
||||||
return 0;
|
IplImage _img;
|
||||||
|
cvGetImage(img, &_img);
|
||||||
|
check_chessboard_result = cvCheckChessboard(&_img, pattern_size);
|
||||||
|
if(check_chessboard_result <= 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,201 +484,238 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
|
|||||||
// This is necessary because some squares simply do not separate properly with a single dilation. However,
|
// This is necessary because some squares simply do not separate properly with a single dilation. However,
|
||||||
// we want to use the minimum number of dilations possible since dilations cause the squares to become smaller,
|
// we want to use the minimum number of dilations possible since dilations cause the squares to become smaller,
|
||||||
// making it difficult to detect smaller squares.
|
// making it difficult to detect smaller squares.
|
||||||
for( k = 0; k < 6; k++ )
|
for( dilations = min_dilations; dilations <= max_dilations; dilations++ )
|
||||||
{
|
{
|
||||||
|
if (found)
|
||||||
|
break; // already found it
|
||||||
|
|
||||||
|
cvFree(&quads);
|
||||||
|
cvFree(&corners);
|
||||||
|
|
||||||
|
int max_quad_buf_size = 0;
|
||||||
|
|
||||||
|
//USE BINARY IMAGE COMPUTED USING icvBinarizationHistogramBased METHOD
|
||||||
|
cvDilate( thresh_img_new, thresh_img_new, 0, 1 );
|
||||||
|
|
||||||
|
// So we can find rectangles that go to the edge, we draw a white line around the image edge.
|
||||||
|
// Otherwise FindContours will miss those clipped rectangle contours.
|
||||||
|
// The border color will be the image mean, because otherwise we risk screwing up filters like cvSmooth()...
|
||||||
|
cvRectangle( thresh_img_new, cvPoint(0,0), cvPoint(thresh_img_new->cols-1, thresh_img_new->rows-1), CV_RGB(255,255,255), 3, 8);
|
||||||
|
quad_count = icvGenerateQuads( &quads, &corners, storage, thresh_img_new, flags, &max_quad_buf_size );
|
||||||
|
PRINTF("Quad count: %d/%d\n", quad_count, expected_corners_num);
|
||||||
|
|
||||||
|
if( quad_count <= 0 )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find quad's neighbors
|
||||||
|
icvFindQuadNeighbors( quads, quad_count );
|
||||||
|
|
||||||
|
// allocate extra for adding in icvOrderFoundQuads
|
||||||
|
cvFree(&quad_group);
|
||||||
|
cvFree(&corner_group);
|
||||||
|
quad_group = (CvCBQuad**)cvAlloc( sizeof(quad_group[0]) * max_quad_buf_size);
|
||||||
|
corner_group = (CvCBCorner**)cvAlloc( sizeof(corner_group[0]) * max_quad_buf_size * 4 );
|
||||||
|
|
||||||
|
for( group_idx = 0; ; group_idx++ )
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
count = icvFindConnectedQuads( quads, quad_count, quad_group, group_idx, storage );
|
||||||
|
|
||||||
|
int icount = count;
|
||||||
|
if( count == 0 )
|
||||||
|
break;
|
||||||
|
|
||||||
|
// order the quad corners globally
|
||||||
|
// maybe delete or add some
|
||||||
|
PRINTF("Starting ordering of inner quads\n");
|
||||||
|
count = icvOrderFoundConnectedQuads(count, quad_group, &quad_count, &quads, &corners, pattern_size, max_quad_buf_size, storage );
|
||||||
|
PRINTF("Orig count: %d After ordering: %d\n", icount, count);
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
continue; // haven't found inner quads
|
||||||
|
|
||||||
|
// If count is more than it should be, this will remove those quads
|
||||||
|
// which cause maximum deviation from a nice square pattern.
|
||||||
|
count = icvCleanFoundConnectedQuads( count, quad_group, pattern_size );
|
||||||
|
PRINTF("Connected group: %d orig count: %d cleaned: %d\n", group_idx, icount, count);
|
||||||
|
|
||||||
|
count = icvCheckQuadGroup( quad_group, count, corner_group, pattern_size );
|
||||||
|
PRINTF("Connected group: %d count: %d cleaned: %d\n", group_idx, icount, count);
|
||||||
|
|
||||||
|
int n = count > 0 ? pattern_size.width * pattern_size.height : -count;
|
||||||
|
n = MIN( n, pattern_size.width * pattern_size.height );
|
||||||
|
float sum_dist = 0;
|
||||||
|
int total = 0;
|
||||||
|
|
||||||
|
for(int i = 0; i < n; i++ )
|
||||||
|
{
|
||||||
|
int ni = 0;
|
||||||
|
float avgi = corner_group[i]->meanDist(&ni);
|
||||||
|
sum_dist += avgi*ni;
|
||||||
|
total += ni;
|
||||||
|
}
|
||||||
|
prev_sqr_size = cvRound(sum_dist/MAX(total, 1));
|
||||||
|
|
||||||
|
if( count > 0 || (out_corner_count && -count > *out_corner_count) )
|
||||||
|
{
|
||||||
|
// copy corners to output array
|
||||||
|
for(int i = 0; i < n; i++ )
|
||||||
|
out_corners[i] = corner_group[i]->pt;
|
||||||
|
|
||||||
|
if( out_corner_count )
|
||||||
|
*out_corner_count = n;
|
||||||
|
|
||||||
|
if( count == pattern_size.width*pattern_size.height &&
|
||||||
|
icvCheckBoardMonotony( out_corners, pattern_size ))
|
||||||
|
{
|
||||||
|
found = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//dilations
|
||||||
|
|
||||||
|
PRINTF("Chessboard detection result 0: %d\n", found);
|
||||||
|
|
||||||
|
// revert to old, slower, method if detection failed
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
PRINTF("Fallback to old algorithm\n");
|
||||||
|
// empiric threshold level
|
||||||
|
// thresholding performed here and not inside the cycle to save processing time
|
||||||
|
int thresh_level;
|
||||||
|
if ( !(flags & CV_CALIB_CB_ADAPTIVE_THRESH) )
|
||||||
|
{
|
||||||
|
double mean = cvAvg( img ).val[0];
|
||||||
|
thresh_level = cvRound( mean - 10 );
|
||||||
|
thresh_level = MAX( thresh_level, 10 );
|
||||||
|
cvThreshold( img, thresh_img, thresh_level, 255, CV_THRESH_BINARY );
|
||||||
|
}
|
||||||
|
for( k = 0; k < 6; k++ )
|
||||||
|
{
|
||||||
int max_quad_buf_size = 0;
|
int max_quad_buf_size = 0;
|
||||||
for( dilations = min_dilations; dilations <= max_dilations; dilations++ )
|
for( dilations = min_dilations; dilations <= max_dilations; dilations++ )
|
||||||
{
|
{
|
||||||
if (found)
|
if (found)
|
||||||
break; // already found it
|
break; // already found it
|
||||||
|
|
||||||
cvFree(&quads);
|
cvFree(&quads);
|
||||||
cvFree(&corners);
|
cvFree(&corners);
|
||||||
|
|
||||||
/*if( k == 1 )
|
// convert the input grayscale image to binary (black-n-white)
|
||||||
|
if( flags & CV_CALIB_CB_ADAPTIVE_THRESH )
|
||||||
|
{
|
||||||
|
int block_size = cvRound(prev_sqr_size == 0 ?
|
||||||
|
MIN(img->cols,img->rows)*(k%2 == 0 ? 0.2 : 0.1): prev_sqr_size*2)|1;
|
||||||
|
|
||||||
|
// convert to binary
|
||||||
|
cvAdaptiveThreshold( img, thresh_img, 255,
|
||||||
|
CV_ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY, block_size, (k/2)*5 );
|
||||||
|
if (dilations > 0)
|
||||||
|
cvDilate( thresh_img, thresh_img, 0, dilations-1 );
|
||||||
|
}
|
||||||
|
//if flag CV_CALIB_CB_ADAPTIVE_THRESH is not set it doesn't make sense
|
||||||
|
//to iterate over k
|
||||||
|
else
|
||||||
|
{
|
||||||
|
k = 6;
|
||||||
|
cvDilate( thresh_img, thresh_img, 0, 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
// So we can find rectangles that go to the edge, we draw a white line around the image edge.
|
||||||
|
// Otherwise FindContours will miss those clipped rectangle contours.
|
||||||
|
// The border color will be the image mean, because otherwise we risk screwing up filters like cvSmooth()...
|
||||||
|
cvRectangle( thresh_img, cvPoint(0,0), cvPoint(thresh_img->cols-1,
|
||||||
|
thresh_img->rows-1), CV_RGB(255,255,255), 3, 8);
|
||||||
|
|
||||||
|
quad_count = icvGenerateQuads( &quads, &corners, storage, thresh_img, flags, &max_quad_buf_size);
|
||||||
|
PRINTF("Quad count: %d/%d\n", quad_count, expected_corners_num);
|
||||||
|
|
||||||
|
if( quad_count <= 0 )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find quad's neighbors
|
||||||
|
icvFindQuadNeighbors( quads, quad_count );
|
||||||
|
|
||||||
|
// allocate extra for adding in icvOrderFoundQuads
|
||||||
|
cvFree(&quad_group);
|
||||||
|
cvFree(&corner_group);
|
||||||
|
quad_group = (CvCBQuad**)cvAlloc( sizeof(quad_group[0]) * max_quad_buf_size);
|
||||||
|
corner_group = (CvCBCorner**)cvAlloc( sizeof(corner_group[0]) * max_quad_buf_size * 4 );
|
||||||
|
|
||||||
|
for( group_idx = 0; ; group_idx++ )
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
count = icvFindConnectedQuads( quads, quad_count, quad_group, group_idx, storage );
|
||||||
|
|
||||||
|
int icount = count;
|
||||||
|
if( count == 0 )
|
||||||
|
break;
|
||||||
|
|
||||||
|
// order the quad corners globally
|
||||||
|
// maybe delete or add some
|
||||||
|
PRINTF("Starting ordering of inner quads\n");
|
||||||
|
count = icvOrderFoundConnectedQuads(count, quad_group, &quad_count, &quads, &corners, pattern_size, max_quad_buf_size, storage );
|
||||||
|
|
||||||
|
PRINTF("Orig count: %d After ordering: %d\n", icount, count);
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
continue; // haven't found inner quads
|
||||||
|
|
||||||
|
|
||||||
|
// If count is more than it should be, this will remove those quads
|
||||||
|
// which cause maximum deviation from a nice square pattern.
|
||||||
|
count = icvCleanFoundConnectedQuads( count, quad_group, pattern_size );
|
||||||
|
PRINTF("Connected group: %d orig count: %d cleaned: %d\n", group_idx, icount, count);
|
||||||
|
|
||||||
|
count = icvCheckQuadGroup( quad_group, count, corner_group, pattern_size );
|
||||||
|
PRINTF("Connected group: %d count: %d cleaned: %d\n", group_idx, icount, count);
|
||||||
|
|
||||||
|
int n = count > 0 ? pattern_size.width * pattern_size.height : -count;
|
||||||
|
n = MIN( n, pattern_size.width * pattern_size.height );
|
||||||
|
float sum_dist = 0;
|
||||||
|
int total = 0;
|
||||||
|
|
||||||
|
for(int i = 0; i < n; i++ )
|
||||||
{
|
{
|
||||||
//Pattern was not found using binarization
|
int ni = 0;
|
||||||
// Run multi-level quads extraction
|
float avgi = corner_group[i]->meanDist(&ni);
|
||||||
// In case one-level binarization did not give enough number of quads
|
sum_dist += avgi*ni;
|
||||||
CV_CALL( quad_count = icvGenerateQuadsEx( &quads, &corners, storage, img, thresh_img, dilations, flags ));
|
total += ni;
|
||||||
PRINTF("EX quad count: %d/%d\n", quad_count, expected_corners_num);
|
|
||||||
}
|
}
|
||||||
else*/
|
prev_sqr_size = cvRound(sum_dist/MAX(total, 1));
|
||||||
|
|
||||||
|
if( count > 0 || (out_corner_count && -count > *out_corner_count) )
|
||||||
{
|
{
|
||||||
// convert the input grayscale image to binary (black-n-white)
|
// copy corners to output array
|
||||||
if( flags & CV_CALIB_CB_ADAPTIVE_THRESH )
|
for(int i = 0; i < n; i++ )
|
||||||
{
|
out_corners[i] = corner_group[i]->pt;
|
||||||
int block_size = cvRound(prev_sqr_size == 0 ?
|
|
||||||
MIN(img->cols,img->rows)*(k%2 == 0 ? 0.2 : 0.1): prev_sqr_size*2)|1;
|
|
||||||
|
|
||||||
// convert to binary
|
if( out_corner_count )
|
||||||
cvAdaptiveThreshold( img, thresh_img, 255,
|
*out_corner_count = n;
|
||||||
CV_ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY, block_size, (k/2)*5 );
|
|
||||||
if (dilations > 0)
|
|
||||||
cvDilate( thresh_img, thresh_img, 0, dilations-1 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Make dilation before the thresholding.
|
|
||||||
// It splits chessboard corners
|
|
||||||
//cvDilate( img, thresh_img, 0, 1 );
|
|
||||||
|
|
||||||
// empiric threshold level
|
if( count == pattern_size.width*pattern_size.height && icvCheckBoardMonotony( out_corners, pattern_size ))
|
||||||
double mean = cvAvg( img ).val[0];
|
{
|
||||||
int thresh_level = cvRound( mean - 10 );
|
found = 1;
|
||||||
thresh_level = MAX( thresh_level, 10 );
|
break;
|
||||||
|
}
|
||||||
cvThreshold( img, thresh_img, thresh_level, 255, CV_THRESH_BINARY );
|
|
||||||
cvDilate( thresh_img, thresh_img, 0, dilations );
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG_CHESSBOARD
|
|
||||||
cvCvtColor(thresh_img,dbg_img,CV_GRAY2BGR);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// So we can find rectangles that go to the edge, we draw a white line around the image edge.
|
|
||||||
// Otherwise FindContours will miss those clipped rectangle contours.
|
|
||||||
// The border color will be the image mean, because otherwise we risk screwing up filters like cvSmooth()...
|
|
||||||
cvRectangle( thresh_img, cvPoint(0,0), cvPoint(thresh_img->cols-1,
|
|
||||||
thresh_img->rows-1), CV_RGB(255,255,255), 3, 8);
|
|
||||||
|
|
||||||
quad_count = icvGenerateQuads( &quads, &corners, storage, thresh_img, flags, &max_quad_buf_size);
|
|
||||||
|
|
||||||
PRINTF("Quad count: %d/%d\n", quad_count, expected_corners_num);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG_CHESSBOARD
|
|
||||||
cvCopy(dbg_img, dbg1_img);
|
|
||||||
cvNamedWindow("all_quads", 1);
|
|
||||||
// copy corners to temp array
|
|
||||||
for(int i = 0; i < quad_count; i++ )
|
|
||||||
{
|
|
||||||
for (int k=0; k<4; k++)
|
|
||||||
{
|
|
||||||
CvPoint2D32f pt1, pt2;
|
|
||||||
CvScalar color = CV_RGB(30,255,30);
|
|
||||||
pt1 = quads[i].corners[k]->pt;
|
|
||||||
pt2 = quads[i].corners[(k+1)%4]->pt;
|
|
||||||
pt2.x = (pt1.x + pt2.x)/2;
|
|
||||||
pt2.y = (pt1.y + pt2.y)/2;
|
|
||||||
if (k>0)
|
|
||||||
color = CV_RGB(200,200,0);
|
|
||||||
cvLine( dbg1_img, cvPointFrom32f(pt1), cvPointFrom32f(pt2), color, 3, 8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
cvShowImage("all_quads", (IplImage*)dbg1_img);
|
|
||||||
cvWaitKey();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( quad_count <= 0 )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Find quad's neighbors
|
|
||||||
icvFindQuadNeighbors( quads, quad_count );
|
|
||||||
|
|
||||||
// allocate extra for adding in icvOrderFoundQuads
|
|
||||||
cvFree(&quad_group);
|
|
||||||
cvFree(&corner_group);
|
|
||||||
quad_group = (CvCBQuad**)cvAlloc( sizeof(quad_group[0]) * max_quad_buf_size);
|
|
||||||
corner_group = (CvCBCorner**)cvAlloc( sizeof(corner_group[0]) * max_quad_buf_size * 4 );
|
|
||||||
|
|
||||||
for( group_idx = 0; ; group_idx++ )
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
count = icvFindConnectedQuads( quads, quad_count, quad_group, group_idx, storage );
|
|
||||||
|
|
||||||
int icount = count;
|
|
||||||
if( count == 0 )
|
|
||||||
break;
|
|
||||||
|
|
||||||
// order the quad corners globally
|
|
||||||
// maybe delete or add some
|
|
||||||
PRINTF("Starting ordering of inner quads\n");
|
|
||||||
count = icvOrderFoundConnectedQuads(count, quad_group, &quad_count, &quads, &corners,
|
|
||||||
pattern_size, max_quad_buf_size, storage );
|
|
||||||
PRINTF("Orig count: %d After ordering: %d\n", icount, count);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG_CHESSBOARD
|
|
||||||
cvCopy(dbg_img,dbg2_img);
|
|
||||||
cvNamedWindow("connected_group", 1);
|
|
||||||
// copy corners to temp array
|
|
||||||
for(int i = 0; i < quad_count; i++ )
|
|
||||||
{
|
|
||||||
if (quads[i].group_idx == group_idx)
|
|
||||||
for (int k=0; k<4; k++)
|
|
||||||
{
|
|
||||||
CvPoint2D32f pt1, pt2;
|
|
||||||
CvScalar color = CV_RGB(30,255,30);
|
|
||||||
if (quads[i].ordered)
|
|
||||||
color = CV_RGB(255,30,30);
|
|
||||||
pt1 = quads[i].corners[k]->pt;
|
|
||||||
pt2 = quads[i].corners[(k+1)%4]->pt;
|
|
||||||
pt2.x = (pt1.x + pt2.x)/2;
|
|
||||||
pt2.y = (pt1.y + pt2.y)/2;
|
|
||||||
if (k>0)
|
|
||||||
color = CV_RGB(200,200,0);
|
|
||||||
cvLine( dbg2_img, cvPointFrom32f(pt1), cvPointFrom32f(pt2), color, 3, 8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cvShowImage("connected_group", (IplImage*)dbg2_img);
|
|
||||||
cvWaitKey();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (count == 0)
|
|
||||||
continue; // haven't found inner quads
|
|
||||||
|
|
||||||
|
|
||||||
// If count is more than it should be, this will remove those quads
|
|
||||||
// which cause maximum deviation from a nice square pattern.
|
|
||||||
count = icvCleanFoundConnectedQuads( count, quad_group, pattern_size );
|
|
||||||
PRINTF("Connected group: %d orig count: %d cleaned: %d\n", group_idx, icount, count);
|
|
||||||
|
|
||||||
count = icvCheckQuadGroup( quad_group, count, corner_group, pattern_size );
|
|
||||||
PRINTF("Connected group: %d count: %d cleaned: %d\n", group_idx, icount, count);
|
|
||||||
|
|
||||||
{
|
|
||||||
int n = count > 0 ? pattern_size.width * pattern_size.height : -count;
|
|
||||||
n = MIN( n, pattern_size.width * pattern_size.height );
|
|
||||||
float sum_dist = 0;
|
|
||||||
int total = 0;
|
|
||||||
|
|
||||||
for(int i = 0; i < n; i++ )
|
|
||||||
{
|
|
||||||
int ni = 0;
|
|
||||||
float avgi = corner_group[i]->meanDist(&ni);
|
|
||||||
sum_dist += avgi*ni;
|
|
||||||
total += ni;
|
|
||||||
}
|
|
||||||
prev_sqr_size = cvRound(sum_dist/MAX(total, 1));
|
|
||||||
|
|
||||||
if( count > 0 || (out_corner_count && -count > *out_corner_count) )
|
|
||||||
{
|
|
||||||
// copy corners to output array
|
|
||||||
for(int i = 0; i < n; i++ )
|
|
||||||
out_corners[i] = corner_group[i]->pt;
|
|
||||||
|
|
||||||
if( out_corner_count )
|
|
||||||
*out_corner_count = n;
|
|
||||||
|
|
||||||
if( count == pattern_size.width*pattern_size.height &&
|
|
||||||
icvCheckBoardMonotony( out_corners, pattern_size ))
|
|
||||||
{
|
|
||||||
found = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}//dilations
|
}//dilations
|
||||||
}//
|
}// for k = 0 -> 6
|
||||||
|
}
|
||||||
|
|
||||||
|
PRINTF("Chessboard detection result 1: %d\n", found);
|
||||||
|
|
||||||
if( found )
|
if( found )
|
||||||
found = icvCheckBoardMonotony( out_corners, pattern_size );
|
found = icvCheckBoardMonotony( out_corners, pattern_size );
|
||||||
|
|
||||||
|
PRINTF("Chessboard detection result 2: %d\n", found);
|
||||||
|
|
||||||
// check that none of the found corners is too close to the image boundary
|
// check that none of the found corners is too close to the image boundary
|
||||||
if( found )
|
if( found )
|
||||||
{
|
{
|
||||||
@ -521,36 +730,38 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
|
|||||||
found = k == pattern_size.width*pattern_size.height;
|
found = k == pattern_size.width*pattern_size.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( found && pattern_size.height % 2 == 0 && pattern_size.width % 2 == 0 )
|
PRINTF("Chessboard detection result 3: %d\n", found);
|
||||||
|
|
||||||
|
if( found )
|
||||||
{
|
{
|
||||||
|
if ( pattern_size.height % 2 == 0 && pattern_size.width % 2 == 0 )
|
||||||
|
{
|
||||||
int last_row = (pattern_size.height-1)*pattern_size.width;
|
int last_row = (pattern_size.height-1)*pattern_size.width;
|
||||||
double dy0 = out_corners[last_row].y - out_corners[0].y;
|
double dy0 = out_corners[last_row].y - out_corners[0].y;
|
||||||
if( dy0 < 0 )
|
if( dy0 < 0 )
|
||||||
{
|
{
|
||||||
int n = pattern_size.width*pattern_size.height;
|
int n = pattern_size.width*pattern_size.height;
|
||||||
for(int i = 0; i < n/2; i++ )
|
for(int i = 0; i < n/2; i++ )
|
||||||
{
|
{
|
||||||
CvPoint2D32f temp;
|
CvPoint2D32f temp;
|
||||||
CV_SWAP(out_corners[i], out_corners[n-i-1], temp);
|
CV_SWAP(out_corners[i], out_corners[n-i-1], temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cv::Ptr<CvMat> gray;
|
||||||
if( found )
|
if( CV_MAT_CN(img->type) != 1 )
|
||||||
{
|
{
|
||||||
cv::Ptr<CvMat> gray;
|
gray.reset(cvCreateMat(img->rows, img->cols, CV_8UC1));
|
||||||
if( CV_MAT_CN(img->type) != 1 )
|
cvCvtColor(img, gray, CV_BGR2GRAY);
|
||||||
{
|
}
|
||||||
gray.reset(cvCreateMat(img->rows, img->cols, CV_8UC1));
|
else
|
||||||
cvCvtColor(img, gray, CV_BGR2GRAY);
|
{
|
||||||
}
|
gray.reset(cvCloneMat(img));
|
||||||
else
|
}
|
||||||
{
|
int wsize = 2;
|
||||||
gray.reset(cvCloneMat(img));
|
cvFindCornerSubPix( gray, out_corners, pattern_size.width*pattern_size.height,
|
||||||
}
|
cvSize(wsize, wsize), cvSize(-1,-1),
|
||||||
int wsize = 2;
|
cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 15, 0.1));
|
||||||
cvFindCornerSubPix( gray, out_corners, pattern_size.width*pattern_size.height,
|
|
||||||
cvSize(wsize, wsize), cvSize(-1,-1), cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 15, 0.1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
@ -559,6 +770,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
|
|||||||
cvFree(&corners);
|
cvFree(&corners);
|
||||||
cvFree(&quad_group);
|
cvFree(&quad_group);
|
||||||
cvFree(&corner_group);
|
cvFree(&corner_group);
|
||||||
|
cvFree(&cImgSeg);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,6 +778,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
|
|||||||
cvFree(&corners);
|
cvFree(&corners);
|
||||||
cvFree(&quad_group);
|
cvFree(&quad_group);
|
||||||
cvFree(&corner_group);
|
cvFree(&corner_group);
|
||||||
|
cvFree(&cImgSeg);
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2345,8 +2345,8 @@ void cvStereoRectify( const CvMat* _cameraMatrix1, const CvMat* _cameraMatrix2,
|
|||||||
for( i = 0; i < 4; i++ )
|
for( i = 0; i < 4; i++ )
|
||||||
{
|
{
|
||||||
int j = (i<2) ? 0 : 1;
|
int j = (i<2) ? 0 : 1;
|
||||||
_pts[i].x = (float)((i % 2)*(nx-1));
|
_pts[i].x = (float)((i % 2)*(nx));
|
||||||
_pts[i].y = (float)(j*(ny-1));
|
_pts[i].y = (float)(j*(ny));
|
||||||
}
|
}
|
||||||
cvUndistortPoints( &pts, &pts, A, Dk, 0, 0 );
|
cvUndistortPoints( &pts, &pts, A, Dk, 0, 0 );
|
||||||
cvConvertPointsHomogeneous( &pts, &pts_3 );
|
cvConvertPointsHomogeneous( &pts, &pts_3 );
|
||||||
@ -2360,8 +2360,8 @@ void cvStereoRectify( const CvMat* _cameraMatrix1, const CvMat* _cameraMatrix2,
|
|||||||
_a_tmp[1][2]=0.0;
|
_a_tmp[1][2]=0.0;
|
||||||
cvProjectPoints2( &pts_3, k == 0 ? _R1 : _R2, &Z, &A_tmp, 0, &pts );
|
cvProjectPoints2( &pts_3, k == 0 ? _R1 : _R2, &Z, &A_tmp, 0, &pts );
|
||||||
CvScalar avg = cvAvg(&pts);
|
CvScalar avg = cvAvg(&pts);
|
||||||
cc_new[k].x = (nx-1)/2 - avg.val[0];
|
cc_new[k].x = (nx)/2 - avg.val[0];
|
||||||
cc_new[k].y = (ny-1)/2 - avg.val[1];
|
cc_new[k].y = (ny)/2 - avg.val[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// vertical focal length must be the same for both images to keep the epipolar constraint
|
// vertical focal length must be the same for both images to keep the epipolar constraint
|
||||||
|
@ -57,6 +57,8 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int cvCheckChessboardBinary(IplImage* src, CvSize size);
|
||||||
|
|
||||||
static void icvGetQuadrangleHypotheses(CvSeq* contours, std::vector<std::pair<float, int> >& quads, int class_id)
|
static void icvGetQuadrangleHypotheses(CvSeq* contours, std::vector<std::pair<float, int> >& quads, int class_id)
|
||||||
{
|
{
|
||||||
const float min_aspect_ratio = 0.3f;
|
const float min_aspect_ratio = 0.3f;
|
||||||
@ -205,3 +207,97 @@ int cvCheckChessboard(IplImage* src, CvSize size)
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// does a fast check if a chessboard is in the input image. This is a workaround to
|
||||||
|
// a problem of cvFindChessboardCorners being slow on images with no chessboard
|
||||||
|
// - src: input binary image
|
||||||
|
// - size: chessboard size
|
||||||
|
// Returns 1 if a chessboard can be in this image and findChessboardCorners should be called,
|
||||||
|
// 0 if there is no chessboard, -1 in case of error
|
||||||
|
int cvCheckChessboardBinary(IplImage* src, CvSize size)
|
||||||
|
{
|
||||||
|
if(src->nChannels > 1)
|
||||||
|
{
|
||||||
|
cvError(CV_BadNumChannels, "cvCheckChessboard", "supports single-channel images only",
|
||||||
|
__FILE__, __LINE__);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(src->depth != 8)
|
||||||
|
{
|
||||||
|
cvError(CV_BadDepth, "cvCheckChessboard", "supports depth=8 images only",
|
||||||
|
__FILE__, __LINE__);
|
||||||
|
}
|
||||||
|
|
||||||
|
CvMemStorage* storage = cvCreateMemStorage();
|
||||||
|
|
||||||
|
IplImage* white = cvCloneImage(src);
|
||||||
|
IplImage* black = cvCloneImage(src);
|
||||||
|
IplImage* thresh = cvCreateImage(cvGetSize(src), IPL_DEPTH_8U, 1);
|
||||||
|
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
for ( int erosion_count = 0; erosion_count <= 3; erosion_count++ )
|
||||||
|
{
|
||||||
|
if ( 1 == result )
|
||||||
|
break;
|
||||||
|
|
||||||
|
if ( 0 != erosion_count ) // first iteration keeps original images
|
||||||
|
{
|
||||||
|
cvErode(white, white, NULL, 1);
|
||||||
|
cvDilate(black, black, NULL, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
cvThreshold(white, thresh, 128, 255, CV_THRESH_BINARY);
|
||||||
|
|
||||||
|
CvSeq* first = 0;
|
||||||
|
std::vector<std::pair<float, int> > quads;
|
||||||
|
cvFindContours(thresh, storage, &first, sizeof(CvContour), CV_RETR_CCOMP);
|
||||||
|
icvGetQuadrangleHypotheses(first, quads, 1);
|
||||||
|
|
||||||
|
cvThreshold(black, thresh, 128, 255, CV_THRESH_BINARY_INV);
|
||||||
|
cvFindContours(thresh, storage, &first, sizeof(CvContour), CV_RETR_CCOMP);
|
||||||
|
icvGetQuadrangleHypotheses(first, quads, 0);
|
||||||
|
|
||||||
|
const size_t min_quads_count = size.width*size.height/2;
|
||||||
|
std::sort(quads.begin(), quads.end(), less_pred);
|
||||||
|
|
||||||
|
// now check if there are many hypotheses with similar sizes
|
||||||
|
// do this by floodfill-style algorithm
|
||||||
|
const float size_rel_dev = 0.4f;
|
||||||
|
|
||||||
|
for(size_t i = 0; i < quads.size(); i++)
|
||||||
|
{
|
||||||
|
size_t j = i + 1;
|
||||||
|
for(; j < quads.size(); j++)
|
||||||
|
{
|
||||||
|
if(quads[j].first/quads[i].first > 1.0f + size_rel_dev)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(j + 1 > min_quads_count + i)
|
||||||
|
{
|
||||||
|
// check the number of black and white squares
|
||||||
|
std::vector<int> counts;
|
||||||
|
countClasses(quads, i, j, counts);
|
||||||
|
const int black_count = cvRound(ceil(size.width/2.0)*ceil(size.height/2.0));
|
||||||
|
const int white_count = cvRound(floor(size.width/2.0)*floor(size.height/2.0));
|
||||||
|
if(counts[0] < black_count*0.75 ||
|
||||||
|
counts[1] < white_count*0.75)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
result = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cvReleaseImage(&thresh);
|
||||||
|
cvReleaseImage(&white);
|
||||||
|
cvReleaseImage(&black);
|
||||||
|
cvReleaseMemStorage(&storage);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
@ -158,7 +158,7 @@ public:
|
|||||||
rvec(_rvec), tvec(_tvec) {}
|
rvec(_rvec), tvec(_tvec) {}
|
||||||
|
|
||||||
/* Pre: True */
|
/* Pre: True */
|
||||||
/* Post: compute _model with given points an return number of found models */
|
/* Post: compute _model with given points and return number of found models */
|
||||||
int runKernel( InputArray _m1, InputArray _m2, OutputArray _model ) const
|
int runKernel( InputArray _m1, InputArray _m2, OutputArray _model ) const
|
||||||
{
|
{
|
||||||
Mat opoints = _m1.getMat(), ipoints = _m2.getMat();
|
Mat opoints = _m1.getMat(), ipoints = _m2.getMat();
|
||||||
|
@ -113,11 +113,7 @@ void CV_ChessboardDetectorTimingTest::run( int start_from )
|
|||||||
if( img2.empty() )
|
if( img2.empty() )
|
||||||
{
|
{
|
||||||
ts->printf( cvtest::TS::LOG, "one of chessboard images can't be read: %s\n", filename.c_str() );
|
ts->printf( cvtest::TS::LOG, "one of chessboard images can't be read: %s\n", filename.c_str() );
|
||||||
if( max_idx == 1 )
|
code = cvtest::TS::FAIL_MISSING_TEST_DATA;
|
||||||
{
|
|
||||||
code = cvtest::TS::FAIL_MISSING_TEST_DATA;
|
|
||||||
goto _exit_;
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user