Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

AudioIO: add spectrogram samples for C++/python#20934

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
alalek merged 5 commits intoopencv:4.xfromSinM9:spectrogram_samples
Dec 14, 2021

Conversation

@SinM9
Copy link
Contributor

@SinM9SinM9 commentedOct 24, 2021
edited
Loading

Pull Request Readiness Checklist

See details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@SinM9SinM9 marked this pull request as ready for reviewNovember 15, 2021 11:45
author Sinitsina Maria <marusya19.09.99@gmail.com> 1635100993 +0300committer Sinitsina Maria <marusya19.09.99@gmail.com> 1636985460 +0300initalupdate samplesfix warnings
@SinM9SinM9 changed the titleSpectrogram samplesAudioIO: add spectrogram samples for C++/pythonNov 15, 2021
@SinM9
Copy link
ContributorAuthor

@allnes Check please

{
line(img, Point(i-1, static_cast<int>(reshape_audio[i-1])), Point(i, static_cast<int>(reshape_audio[i])), color, thickness);
}
resize(img, img, Size(cols, rows), INTER_AREA );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

avoid "inplace" operations. There is performance src copy penalty.

"{inputType i | file | file or microphone }"
"{draw d | static | type of drawing: \n\t\t\tstatic - for plotting graph(s) across the entire input audio \n\t\t\tdynamic - for plotting graph(s) in a time-updating window}"
"{graph g | ampl_and_spec | type of graph: amplitude graph or/and spectrogram. Please use tags below : \n\t\t\tampl - draw the amplitude graph \n\t\t\tspec - draw the spectrogram\n\t\t\tampl_and_spec - draw the amplitude graph and spectrogram on one image under each other}"
"{audio a |../../../samples/data/Megamind.avi| name and path to file }"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Usecv.samples.findFile (Python) /samples::findFile (C++) instead of../

cv.CAP_PROP_AUDIO_DATA_DEPTH, cv.CV_16S]
params = np.asarray(params)

cap.open(file, cv.CAP_MSMF, params)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

cv.CAP_MSMF

This should be removed. We want to support other backends too.

UseCAP_ANY.

parser.add_argument("-g", "--graph", dest="graph", type=str, default="ampl_and_spec",
help="type of graph: amplitude graph or/and spectrogram. Please use tags below : ampl - draw the amplitude graph; spec - draw the spectrogram; ampl_and_spec - draw the amplitude graph and spectrogram on one image under each other")

parser.add_argument("-a", "--audio", dest="audio", type=str, default='../data/Megamind.avi',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

../

need to be removed

@@ -0,0 +1,827 @@
import cv2 as cv
import numpy as np
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Due to compatibility reasonsnumpy should go first (as a dependency)

}
else if (windowType == "Hamming")
{
double pi = 2 * acos(-1.0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

CV_PI, M_PI.

double pi = 2 * acos(-1.0);
for (int j = 1 - windLen; j < windLen; j+=2)
{
WindType.push_back(j * (0.53836 - 0.46164 * (cos(pi * j / (windLen - 1)))));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please add link at Wiki article or other documents so reviewers can validate used expressions

Comment on lines 903 to 904
string grid = parser.get<string>("grid");
if ((grid != "on") && (grid != "off"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

get<bool>()


}

static bool checkArgs(CommandLineParser parser)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Input parameters should be passed as 'const reference'

if (cap.grab())
{
for (int nCh = 0; nCh < numberOfChannels; nCh++)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

There is one imshow for multiple channels.

cap.open(0, CAP_MSMF, params);
if (!cap.isOpened())
{
cerr << "ERROR! Can't to open microphone" << endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

better:

cerr << "ERROR! Can't open microphone" << endl;

(w/o the "to")

alalek reacted with thumbs up emoji
@@ -0,0 +1,1124 @@
#include <opencv2/core.hpp>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please rename samples: addaudio_ prefix

Copy link
Member

@alalekalalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Well done! Thank you 👍

@alalekalalek merged commitd8b1fc4 intoopencv:4.xDec 14, 2021
@alalekalalek mentioned this pull requestDec 30, 2021
@alalekalalek mentioned this pull requestFeb 22, 2022
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull requestMar 30, 2023
AudioIO: add spectrogram samples for C++/python
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@alalekalalekalalek approved these changes

+1 more reviewer

@berakberakberak left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

@alalekalalek

Projects

None yet

Milestone

4.5.5

Development

Successfully merging this pull request may close these issues.

3 participants

@SinM9@berak@alalek

[8]ページ先頭

©2009-2025 Movatter.jp