Commit bffe254a authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #10003 from sturkmen72:documentation_updates

parents 981009ac 63fb79b5
...@@ -359,7 +359,7 @@ CVAPI(CvMat*) cvGetSubRect( const CvArr* arr, CvMat* submat, CvRect rect ); ...@@ -359,7 +359,7 @@ CVAPI(CvMat*) cvGetSubRect( const CvArr* arr, CvMat* submat, CvRect rect );
/** @brief Returns array row or row span. /** @brief Returns array row or row span.
The functions return the header, corresponding to a specified row/row span of the input array. The function returns the header, corresponding to a specified row/row span of the input array.
cvGetRow(arr, submat, row) is a shortcut for cvGetRows(arr, submat, row, row+1). cvGetRow(arr, submat, row) is a shortcut for cvGetRows(arr, submat, row, row+1).
@param arr Input array @param arr Input array
@param submat Pointer to the resulting sub-array header @param submat Pointer to the resulting sub-array header
...@@ -385,7 +385,7 @@ CV_INLINE CvMat* cvGetRow( const CvArr* arr, CvMat* submat, int row ) ...@@ -385,7 +385,7 @@ CV_INLINE CvMat* cvGetRow( const CvArr* arr, CvMat* submat, int row )
/** @brief Returns one of more array columns. /** @brief Returns one of more array columns.
The functions return the header, corresponding to a specified column span of the input array. That The function returns the header, corresponding to a specified column span of the input array. That
is, no data is copied. Therefore, any modifications of the submatrix will affect the original array. is, no data is copied. Therefore, any modifications of the submatrix will affect the original array.
If you need to copy the columns, use cvCloneMat. cvGetCol(arr, submat, col) is a shortcut for If you need to copy the columns, use cvCloneMat. cvGetCol(arr, submat, col) is a shortcut for
......
...@@ -58,8 +58,8 @@ namespace cv ...@@ -58,8 +58,8 @@ namespace cv
/** @brief Template function for accurate conversion from one primitive type to another. /** @brief Template function for accurate conversion from one primitive type to another.
The functions saturate_cast resemble the standard C++ cast operations, such as static_cast\<T\>() The function saturate_cast resembles the standard C++ cast operations, such as static_cast\<T\>()
and others. They perform an efficient and accurate conversion from one primitive type to another and others. It perform an efficient and accurate conversion from one primitive type to another
(see the introduction chapter). saturate in the name means that when the input value v is out of the (see the introduction chapter). saturate in the name means that when the input value v is out of the
range of the target type, the result is not formed just by taking low bits of the input, but instead range of the target type, the result is not formed just by taking low bits of the input, but instead
the value is clipped. For example: the value is clipped. For example:
......
...@@ -2623,7 +2623,7 @@ CV_EXPORTS_AS(integral3) void integral( InputArray src, OutputArray sum, ...@@ -2623,7 +2623,7 @@ CV_EXPORTS_AS(integral3) void integral( InputArray src, OutputArray sum,
//! @addtogroup imgproc_motion //! @addtogroup imgproc_motion
//! @{ //! @{
/** @brief Adds an image to the accumulator. /** @brief Adds an image to the accumulator image.
The function adds src or some of its elements to dst : The function adds src or some of its elements to dst :
...@@ -2631,7 +2631,7 @@ The function adds src or some of its elements to dst : ...@@ -2631,7 +2631,7 @@ The function adds src or some of its elements to dst :
The function supports multi-channel images. Each channel is processed independently. The function supports multi-channel images. Each channel is processed independently.
The functions accumulate\* can be used, for example, to collect statistics of a scene background The function cv::accumulate can be used, for example, to collect statistics of a scene background
viewed by a still camera and for the further foreground-background segmentation. viewed by a still camera and for the further foreground-background segmentation.
@param src Input image of type CV_8UC(n), CV_16UC(n), CV_32FC(n) or CV_64FC(n), where n is a positive integer. @param src Input image of type CV_8UC(n), CV_16UC(n), CV_32FC(n) or CV_64FC(n), where n is a positive integer.
...@@ -2643,7 +2643,7 @@ viewed by a still camera and for the further foreground-background segmentation. ...@@ -2643,7 +2643,7 @@ viewed by a still camera and for the further foreground-background segmentation.
CV_EXPORTS_W void accumulate( InputArray src, InputOutputArray dst, CV_EXPORTS_W void accumulate( InputArray src, InputOutputArray dst,
InputArray mask = noArray() ); InputArray mask = noArray() );
/** @brief Adds the square of a source image to the accumulator. /** @brief Adds the square of a source image to the accumulator image.
The function adds the input image src or its selected region, raised to a power of 2, to the The function adds the input image src or its selected region, raised to a power of 2, to the
accumulator dst : accumulator dst :
...@@ -2662,7 +2662,7 @@ floating-point. ...@@ -2662,7 +2662,7 @@ floating-point.
CV_EXPORTS_W void accumulateSquare( InputArray src, InputOutputArray dst, CV_EXPORTS_W void accumulateSquare( InputArray src, InputOutputArray dst,
InputArray mask = noArray() ); InputArray mask = noArray() );
/** @brief Adds the per-element product of two input images to the accumulator. /** @brief Adds the per-element product of two input images to the accumulator image.
The function adds the product of two images or their selected regions to the accumulator dst : The function adds the product of two images or their selected regions to the accumulator dst :
...@@ -2672,7 +2672,7 @@ The function supports multi-channel images. Each channel is processed independen ...@@ -2672,7 +2672,7 @@ The function supports multi-channel images. Each channel is processed independen
@param src1 First input image, 1- or 3-channel, 8-bit or 32-bit floating point. @param src1 First input image, 1- or 3-channel, 8-bit or 32-bit floating point.
@param src2 Second input image of the same type and the same size as src1 . @param src2 Second input image of the same type and the same size as src1 .
@param dst %Accumulator with the same number of channels as input images, 32-bit or 64-bit @param dst %Accumulator image with the same number of channels as input images, 32-bit or 64-bit
floating-point. floating-point.
@param mask Optional operation mask. @param mask Optional operation mask.
......
#include <opencv2/opencv.hpp> #include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include <iostream>
using namespace cv; using namespace cv;
using namespace std; using namespace std;
enum MyShape{MyCIRCLE=0,MyRECTANGLE,MyELLIPSE}; enum MyShape{MyCIRCLE=0,MyRECTANGLE,MyELLIPSE};
struct ParamColorMar { struct ParamColorMap {
int iColormap; int iColormap;
Mat img; Mat img;
}; };
Ptr<Mat> lutRND;
String winName="False color"; String winName="False color";
static const String ColorMaps[] = { "Autumn", "Bone", "Jet", "Winter", "Rainbow", "Ocean", "Summer",
"Spring", "Cool", "HSV", "Pink", "Hot", "Parula", "User defined (random)"};
static void TrackColorMap(int x, void *r) static void TrackColorMap(int x, void *r)
{ {
std::cout << "selected: " << x << std::endl; ParamColorMap *p = (ParamColorMap*)r;
ParamColorMar *p = (ParamColorMar*)r;
Mat dst; Mat dst;
p->iColormap= x; p->iColormap= x;
if (x == cv::COLORMAP_PARULA + 1) if (x == COLORMAP_PARULA + 1)
{ {
if (!lutRND) Mat lutRND(256, 1, CV_8UC3);
{ randu(lutRND, Scalar(0, 0, 0), Scalar(255, 255, 255));
RNG ra; applyColorMap(p->img, dst, lutRND);
lutRND = makePtr<Mat>(256, 1, CV_8UC3);
ra.fill(*lutRND, RNG::UNIFORM, 0, 256);
}
applyColorMap(p->img, dst, *lutRND.get());
} }
else else
applyColorMap(p->img,dst,p->iColormap); applyColorMap(p->img,dst,p->iColormap);
String colorMapName;
switch (p->iColormap) { putText(dst, "Colormap : "+ColorMaps[p->iColormap], Point(10, 20), FONT_HERSHEY_SIMPLEX, 0.8, Scalar(255, 255, 255),2);
case COLORMAP_AUTUMN :
colorMapName = "Colormap : Autumn";
break;
case COLORMAP_BONE :
colorMapName = "Colormap : Bone";
break;
case COLORMAP_JET :
colorMapName = "Colormap : Jet";
break;
case COLORMAP_WINTER :
colorMapName = "Colormap : Winter";
break;
case COLORMAP_RAINBOW :
colorMapName = "Colormap : Rainbow";
break;
case COLORMAP_OCEAN :
colorMapName = "Colormap : Ocean";
break;
case COLORMAP_SUMMER :
colorMapName = "Colormap : Summer";
break;
case COLORMAP_SPRING :
colorMapName = "Colormap : Spring";
break;
case COLORMAP_COOL :
colorMapName = "Colormap : Cool";
break;
case COLORMAP_HSV :
colorMapName = "Colormap : HSV";
break;
case COLORMAP_PINK :
colorMapName = "Colormap : Pink";
break;
case COLORMAP_HOT :
colorMapName = "Colormap : Hot";
break;
case COLORMAP_PARULA :
colorMapName = "Colormap : Parula";
break;
default:
colorMapName = "User colormap : random";
break;
}
std::cout << "> " << colorMapName << std::endl;
putText(dst, colorMapName, Point(10, 20), cv::FONT_HERSHEY_SIMPLEX, 1, Scalar(255, 255, 255));
imshow(winName, dst); imshow(winName, dst);
} }
...@@ -128,27 +81,29 @@ static Mat DrawMyImage(int thickness,int nbShape) ...@@ -128,27 +81,29 @@ static Mat DrawMyImage(int thickness,int nbShape)
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
ParamColorMar p; cout << "This program demonstrates the use of applyColorMap function.\n\n";
ParamColorMap p;
Mat img; Mat img;
if (argc > 1) if (argc > 1)
img = imread(argv[1], 0); img = imread(argv[1], IMREAD_GRAYSCALE);
else else
img = DrawMyImage(2,256); img = DrawMyImage(2,256);
p.img=img; p.img=img;
p.iColormap=0; p.iColormap=0;
imshow("Gray image",img); imshow("Gray image",img);
namedWindow(winName); namedWindow(winName);
createTrackbar("colormap", winName,&p.iColormap,1,TrackColorMap,(void*)&p); createTrackbar("colormap", winName,&p.iColormap,1,TrackColorMap,(void*)&p);
setTrackbarMin("colormap", winName, cv::COLORMAP_AUTUMN); setTrackbarMin("colormap", winName, COLORMAP_AUTUMN);
setTrackbarMax("colormap", winName, cv::COLORMAP_PARULA+1); setTrackbarMax("colormap", winName, COLORMAP_PARULA+1);
setTrackbarPos("colormap", winName, -1); setTrackbarPos("colormap", winName, -1);
TrackColorMap((int)getTrackbarPos("colormap", winName),(void*)&p); TrackColorMap(0, (void*)&p);
while (waitKey(0) != 27)
{ cout << "Press a key to exit" << endl;
std::cout << "Press 'ESC' to exit" << std::endl; waitKey(0);
}
return 0; return 0;
} }
#include "opencv2/imgproc.hpp" #include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp" #include "opencv2/highgui.hpp"
#include <cctype>
#include <iostream> #include <iostream>
#include <iterator>
#include <stdio.h>
using namespace std; using namespace std;
using namespace cv; using namespace cv;
static void help()
{
cout << "\nThis program demonstrates template match with mask.\n"
"Usage:\n"
"./mask_tmpl -i=<image_name> -t=<template_name> -m=<mask_name>, Default is ../data/lena_tmpl.jpg\n"
<< endl;
}
int main( int argc, const char** argv ) int main( int argc, const char** argv )
{ {
help(); CommandLineParser parser(argc, argv,
cv::CommandLineParser parser(argc, argv, "{ i | ../data/lena_tmpl.jpg |image name }"
"{ i | ../data/lena_tmpl.jpg | }" "{ t | ../data/tmpl.png |template name }"
"{ t | ../data/tmpl.png | }" "{ m | ../data/mask.png |mask name }"
"{ m | ../data/mask.png | }"); "{ cm| 3 |comparison method }");
cout << "This program demonstrates the use of template matching with mask.\n\n";
parser.printMessage();
string filename = parser.get<string>("i"); string filename = parser.get<string>("i");
string tmplname = parser.get<string>("t"); string tmplname = parser.get<string>("t");
...@@ -35,27 +26,23 @@ int main( int argc, const char** argv ) ...@@ -35,27 +26,23 @@ int main( int argc, const char** argv )
if(img.empty()) if(img.empty())
{ {
help();
cout << "can not open " << filename << endl; cout << "can not open " << filename << endl;
return -1; return -1;
} }
if(tmpl.empty()) if(tmpl.empty())
{ {
help();
cout << "can not open " << tmplname << endl; cout << "can not open " << tmplname << endl;
return -1; return -1;
} }
if(mask.empty()) if(mask.empty())
{ {
help();
cout << "can not open " << maskname << endl; cout << "can not open " << maskname << endl;
return -1; return -1;
} }
//int method = CV_TM_SQDIFF; int method = parser.get<int>("cm"); // default 3 (CV_TM_CCORR_NORMED)
int method = CV_TM_CCORR_NORMED;
matchTemplate(img, tmpl, res, method, mask); matchTemplate(img, tmpl, res, method, mask);
double minVal, maxVal; double minVal, maxVal;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment