mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Merge pull request #25252 from gursimarsingh:cpp_samples_cleanup
Move API focused C++ samples to snippets #25252 Clean Samples #25006 This PR removes 39 outdated C++ samples from the project, as part of an effort to keep the codebase clean and focused on current best practices.
This commit is contained in:
@@ -2212,47 +2212,9 @@ current implementation). Such an efficient DFT size can be calculated using the
|
||||
method.
|
||||
|
||||
The sample below illustrates how to calculate a DFT-based convolution of two 2D real arrays:
|
||||
@code
|
||||
void convolveDFT(InputArray A, InputArray B, OutputArray C)
|
||||
{
|
||||
// reallocate the output array if needed
|
||||
C.create(abs(A.rows - B.rows)+1, abs(A.cols - B.cols)+1, A.type());
|
||||
Size dftSize;
|
||||
// calculate the size of DFT transform
|
||||
dftSize.width = getOptimalDFTSize(A.cols + B.cols - 1);
|
||||
dftSize.height = getOptimalDFTSize(A.rows + B.rows - 1);
|
||||
@include samples/cpp/snippets/dft.cpp
|
||||
An example on DFT-based convolution
|
||||
|
||||
// allocate temporary buffers and initialize them with 0's
|
||||
Mat tempA(dftSize, A.type(), Scalar::all(0));
|
||||
Mat tempB(dftSize, B.type(), Scalar::all(0));
|
||||
|
||||
// copy A and B to the top-left corners of tempA and tempB, respectively
|
||||
Mat roiA(tempA, Rect(0,0,A.cols,A.rows));
|
||||
A.copyTo(roiA);
|
||||
Mat roiB(tempB, Rect(0,0,B.cols,B.rows));
|
||||
B.copyTo(roiB);
|
||||
|
||||
// now transform the padded A & B in-place;
|
||||
// use "nonzeroRows" hint for faster processing
|
||||
dft(tempA, tempA, 0, A.rows);
|
||||
dft(tempB, tempB, 0, B.rows);
|
||||
|
||||
// multiply the spectrums;
|
||||
// the function handles packed spectrum representations well
|
||||
mulSpectrums(tempA, tempB, tempA);
|
||||
|
||||
// transform the product back from the frequency domain.
|
||||
// Even though all the result rows will be non-zero,
|
||||
// you need only the first C.rows of them, and thus you
|
||||
// pass nonzeroRows == C.rows
|
||||
dft(tempA, tempA, DFT_INVERSE + DFT_SCALE, C.rows);
|
||||
|
||||
// now copy the result back to C.
|
||||
tempA(Rect(0, 0, C.cols, C.rows)).copyTo(C);
|
||||
|
||||
// all the temporary buffers will be deallocated automatically
|
||||
}
|
||||
@endcode
|
||||
To optimize this sample, consider the following approaches:
|
||||
- Since nonzeroRows != 0 is passed to the forward transform calls and since A and B are copied to
|
||||
the top-left corners of tempA and tempB, respectively, it is not necessary to clear the whole
|
||||
@@ -3092,7 +3054,7 @@ private:
|
||||
//! @addtogroup core_cluster
|
||||
//! @{
|
||||
|
||||
/** @example samples/cpp/kmeans.cpp
|
||||
/** @example samples/cpp/snippets/kmeans.cpp
|
||||
An example on K-means clustering
|
||||
*/
|
||||
|
||||
@@ -3207,6 +3169,10 @@ etc.).
|
||||
|
||||
Here is example of SimpleBlobDetector use in your application via Algorithm interface:
|
||||
@snippet snippets/core_various.cpp Algorithm
|
||||
|
||||
@example samples/cpp/snippets/detect_blob.cpp
|
||||
An example using the BLOB to detect and filter region.
|
||||
|
||||
*/
|
||||
class CV_EXPORTS_W Algorithm
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user