-
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
Conversation
529db0a to
ec7edb9
Compare
ec7edb9 to
c7602a8
Compare
68a4b7b to
e802999
Compare
opencv-alalek
left a comment
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.
Thank you for the contribution!
Please take a look on comments below.
modules/signal/test/test_signal.cpp
Outdated
|
|
||
| float MSE(const Mat1f &outSignal, const Mat1f &refSignal) | ||
| { | ||
| auto mse{0.f}; |
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 use
float mse = 0.f;
here and below (instead of "auto" scalars).
To workaround old ARMv7 compiler.
| static float Bessel(float x) | ||
| { | ||
| int k = 12; // approximation parameter | ||
| float defmul = powf(x, 2) * 0.25f; |
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.
powf(x, 2)
x * x should be faster.
The same is below.
| { | ||
| tabs[i] = 2 * fc * (i - (ntabs - 1) / 2); | ||
| } | ||
| float *tmparr = new float[ntabs]; |
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 use cv::AutoBuffer or std::vector instead. Avoid manual memory management.
| for (int i = 0; i < ntabs; ++i) | ||
| { | ||
| tabs[i] = std::sin(tmparr[i]) / tmparr[i]; | ||
| tabs[i] *= Bessel(beta * sqrtf((float)1 - powf((2 * i / (float)(ntabs - 1) - 1), 2))) / Bessel(beta); |
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.
/ (float)(ntabs - 1)
could be moved out of the loop as pre-computed 2.0f / (float)(ntabs - 1)
|
|
||
| /////////////// cubic Hermite spline (OpenCV's Universal Intrinsics) /////////////// | ||
| #if (CV_SIMD || CV_SIMD_SCALABLE) | ||
| static v_float32 simd_cubicHermite(v_float32 v_A, v_float32 v_B, v_float32 v_C, v_float32 v_D, v_float32 v_t) |
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.
v_float32
static inlineconst v_float32&to workaround alignment issues (see Win32 builder)
c82e7f5 to
71d52c8
Compare
|
Thank you for the updates! |
71d52c8 to
953024c
Compare
Found the issue in scalar code. Fixed |
opencv-alalek
left a comment
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.
Thank you for update!
| // of this distribution and at http://opencv.org/license.html | ||
| #ifndef OPENCV_SIGNAL_HPP | ||
| #define OPENCV_SIGNAL_HPP | ||
|
|
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/
/**
@defgroup signal Signal Processing
This module includes signal processing algorithms.
@}
*/
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
953024c to
ec96a9f
Compare
opencv-alalek
left a comment
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.
Well done 👍
ec96a9f to
be00f49
Compare
|
Added fix for Windows10-x64 warnings check |
be00f49 to
105e514
Compare
Added signal module with resampling function implemented with cubic interpolation function and a filtering function based on Kaiser window and Bessel function, used to construct a FIR filter.
Detail: https://en.wikipedia.org/wiki/Sample-rate_conversion
There are provided:
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.