-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Add signal module with signal resampling function #3613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| set(the_description "Signal processing algorithms") | ||
| ocv_define_module(signal opencv_core WRAP python) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Signal Processing algorithms | ||
| ================================================ | ||
|
|
||
| Signal resampling done with cubic interpolation and low-pass filtering |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // This file is part of OpenCV project. | ||
| // It is subject to the license terms in the LICENSE file found in the top-level directory | ||
| // of this distribution and at http://opencv.org/license.html | ||
| #ifndef OPENCV_SIGNAL_HPP | ||
| #define OPENCV_SIGNAL_HPP | ||
|
|
||
| /** | ||
| * @defgroup signal Signal Processing | ||
| * @{ | ||
| * This module includes signal processing algorithms. | ||
| * @} | ||
| */ | ||
|
|
||
| #include "opencv2/core.hpp" | ||
| #include "opencv2/signal/signal_resample.hpp" | ||
|
|
||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // This file is part of OpenCV project. | ||
| // It is subject to the license terms in the LICENSE file found in the top-level directory | ||
| // of this distribution and at http://opencv.org/license.html | ||
| #ifndef OPENCV_SIGNAL_SIGNAL_RESAMPLE_HPP | ||
| #define OPENCV_SIGNAL_SIGNAL_RESAMPLE_HPP | ||
|
|
||
| #include <opencv2/core.hpp> | ||
|
|
||
| namespace cv { | ||
| namespace signal { | ||
|
|
||
| //! @addtogroup signal | ||
| //! @{ | ||
|
|
||
| /** @brief Signal resampling | ||
| * | ||
| * @param[in] inputSignal Array with input signal. | ||
| * @param[out] outSignal Array with output signal | ||
| * @param[in] inFreq Input signal frequency. | ||
| * @param[in] outFreq Output signal frequency. | ||
| * Signal resampling implemented a cubic interpolation function and a filtering function based on Kaiser window and Bessel function, used to construct a FIR filter. | ||
| * Result is similar to `scipy.signal.resample`. | ||
|
|
||
| Detail: https://en.wikipedia.org/wiki/Sample-rate_conversion | ||
| */ | ||
| CV_EXPORTS_W void resampleSignal(InputArray inputSignal, OutputArray outSignal, const int inFreq, const int outFreq); | ||
|
|
||
| //! @} | ||
|
|
||
| } | ||
| } | ||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // This file is part of OpenCV project. | ||
| // It is subject to the license terms in the LICENSE file found in the top-level directory | ||
| // of this distribution and at http://opencv.org/license.html. | ||
| #include "perf_precomp.hpp" | ||
|
|
||
| CV_PERF_TEST_MAIN(signal) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // This file is part of OpenCV project. | ||
| // It is subject to the license terms in the LICENSE file found in the top-level directory | ||
| // of this distribution and at http://opencv.org/license.html. | ||
| #ifndef __OPENCV_PERF_PRECOMP_HPP__ | ||
| #define __OPENCV_PERF_PRECOMP_HPP__ | ||
|
|
||
| #include "opencv2/ts.hpp" | ||
| #include "opencv2/signal.hpp" | ||
|
|
||
| namespace opencv_test { | ||
| using namespace perf; | ||
| using namespace cv::signal; | ||
| } | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // This file is part of OpenCV project. | ||
| // It is subject to the license terms in the LICENSE file found in the top-level directory | ||
| // of this distribution and at http://opencv.org/license.html. | ||
|
|
||
| #include "perf_precomp.hpp" | ||
|
|
||
| using namespace std; | ||
| using namespace cv; | ||
| using namespace perf; | ||
|
|
||
| namespace opencv_test { namespace { | ||
|
|
||
| typedef TestBaseWithParam< tuple<uint32_t, uint32_t, uint32_t> > TestResampleFunc; | ||
|
|
||
| PERF_TEST_P( TestResampleFunc, resample_sin_signal, | ||
| testing::Combine( | ||
| testing::Values(1234U, 12345U, 123456U, 1234567U, 12345678U), | ||
| testing::Values(16000U, 32000U, 44100U, 48000U), | ||
| testing::Values(48000U, 44100U, 32000U, 16000U)) | ||
| ) | ||
| { | ||
| uint32_t sample_signal_size = GET_PARAM(0); | ||
| uint32_t inFreq = GET_PARAM(1); | ||
| uint32_t outFreq = GET_PARAM(2); | ||
|
|
||
| Mat1f sample_signal(Size(sample_signal_size,1U)); | ||
| Mat1f outSignal(Size(1U, 1U)); | ||
| for (uint32_t i = 0U; i < (uint32_t)sample_signal.cols; ++i) | ||
| { | ||
| sample_signal.at<float>(0, i) = sinf(float(i)); | ||
| } | ||
| declare.in(sample_signal).out(outSignal); | ||
| TEST_CYCLE() resampleSignal(sample_signal, outSignal, inFreq, outFreq); | ||
| SANITY_CHECK_NOTHING(); | ||
| } | ||
|
|
||
| }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // This file is part of OpenCV project. | ||
| // It is subject to the license terms in the LICENSE file found in the top-level directory | ||
| // of this distribution and at http://opencv.org/license.html | ||
|
|
||
| #ifndef __OPENCV_SIGNAL_PRECOMP__ | ||
| #define __OPENCV_SIGNAL_PRECOMP__ | ||
|
|
||
| #include <opencv2/core.hpp> | ||
|
|
||
| #endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add module declaration for documentation: http://pullrequest.opencv.org/buildbot/export/pr_contrib/3613/docs/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added declaration