上一主题下一主题
关键字
主题 : 利用c++频谱仪控件制作,有没有好人帮忙啊
级别: 北风助理工程师

UID: 474136
精华: 0
发帖: 418
威望: 898 点
学点: 715 点
贡献: 0 点
好评: 0 点
学币: 0 个
注册时间: 2014-07-13
最后登录: 2014-12-05
楼主  发表于: 2014-07-28 16:19||

利用c++频谱仪控件制作,有没有好人帮忙啊

大学软件设计实验题目,有没有好人帮忙啊 W:nef<WH  
9};8?mucr  
要求:输入给定信号(数组),基于FFT快速频谱计算,给出频谱图显示。并****成控件方便调用。 `?@}>.  
格式:设计题目     P=Jo+4O  
任务要求     H;LViP2K*  
实验设备及软件     E_wCN&`[  
参考文献
此帖悬赏结束
最佳答案: 1 学点
最佳答案获得者: 慕容紫英
级别: 北风资深工程师


UID: 472421
精华: 0
发帖: 1405
威望: 1631 点
学点: 64 点
贡献: 23 点
好评: 0 点
学币: 95 个
注册时间: 2014-07-09
最后登录: 2018-07-09
沙发(1楼)  发表于: 2014-07-28 16:21||

先搜索下载安装OpenCV $ Cjk  
然后参考C:\Program Files\OpenCV\modules\objdetect\src\fft.cpp =S]a&*M  
C/C++ code F X1ZG!  
]&i+!$N_  
h#Ce _,o  
#include "precomp.hpp" w3D]~&]  
#include "_lsvm_fft.h" TQ1WVq }*  
xQlT%X;'  
int getEntireRes(int number, int divisor, int *entire, int *res) {lzG*4?  
{ PG)_L.7rJ  
    *entire = number / divisor; <-jGqUN_I  
    *res = number % divisor; XqR{.jF.  
    return FFT_OK; 2Q$\KRE  
} 2neRJ  
?Nl"sVCo  
int getMultipliers(int n, int *n1, int *n2) iTNqWU-o  
{ i@<~"~>]7  
    int multiplier, i; (@ea|Fd#4  
    if (n == 1) Wm6dQQ;Bj  
    { t,vTAq.))  
        *n1 = 1; 9Nl*  4  
        *n2 = 1; }?O[N}>,m  
        return FFT_ERROR; // n = 1 Ww87  
    } u"F;OT\>g  
    multiplier = n / 2; 6dT|;koWbm  
    for (i = multiplier; i >= 2; i--) 8 G?b.NE^  
    { wd`R4CKhP]  
        if (n % i == 0) jCWu\Oe  
        { _XN~@5elrC  
            *n1 = i; tq E>Zx=X  
            *n2 = n / i; ]b\WaS8I  
            return FFT_OK; // n = n1 * n2 f sX;Nj]  
        } U3q5^{0d/  
    } $PfV<Yj'B  
    *n1 = 1; 2<.Vv\ =  
    *n2 = n; !`h~`-]O  
    return FFT_ERROR; // n - prime number cd"wNH-  
} 8c?8X=|D7  
WA$ p_% r=  
/* 6(5c7R#  
// 1-dimensional FFT gx&73f<J  
// ^k9rDn/AW  
// API ?',}? {"c  
// int fft(float *x_in, float *x_out, int n, int shift); 7#/|VQX<A  
// INPUT @>9A$w$H|a  
// x_in              - input signal I1J)#p%H.  
// n                 - number of elements for searching Fourier image x_pMG!2  
// shift             - shift between input elements o9^$hDs,si  
// OUTPUT zrTY1Asw;4  
// x_out             - output signal (contains 2n elements in order R=DPeUy;  
                       Re(x_in[0]), Im(x_in[0]), Re(x_in[1]), Im(x_in[1]) and etc.) =z']s4  
// RESULT 7@\ GU]. 2  
// Error status aliQ6_  
*/ Wpa$B )xg  
int fft(float *x_in, float *x_out, int n, int shift) ,$SkaTBe  
{ z4 nou>  
    int n1, n2, res, k1, k2, m1, m2, index, idx; paUyS1i  
    float alpha, beta, gamma, angle, cosAngle, sinAngle; `,Q<YT ~  
    float tmpGamma, tmpAlpha, tmpBeta; GZ}*r{  
    float tmpRe, tmpIm, phaseRe, phaseIm; la1D2 lM  
    res = getMultipliers(n, &n1, &n2); HK=CP0H  
    if (res == FFT_OK) 939]8BERt  
    { `mWQWx$V!  
        fft(x_in, x_out, n1, shift); oa?!50d  
        fft(x_in, x_out, n2, shift); ,5`."-0}  
    } D;K&  
    alpha = (float)(2.0 * PI / ((float)n)); ]Sk#a-^~  
    beta = (float)(2.0 * PI / ((float)n1)); P((S2"D<4  
    gamma = (float)(2.0 * PI / ((float)n2)); h,Y{t?Of  
    for (k1 = 0; k1 < n1; k1++) ~k"eE V p  
    { *tIdp`xT/T  
        tmpBeta = beta * k1; v[p/c.p?i  
        for (k2 = 0; k2 < n2; k2++) "{,\]l&o  
        { I 0x`H)DA  
            idx = shift * (n2 * k1 + k2); vCYSm  0  
            x_out[idx] = 0.0; 5&G Q=m  
            x_out[idx + 1] = 0.0; &/z+A{Hi  
            tmpGamma = gamma * k2; /gMa"5?,  
            tmpAlpha = alpha * k2; *B)Jv9  
            for (m1 = 0; m1 < n1; m1++) |>jqH @\P  
            { . x\/XlM  
                tmpRe = 0.0; Q6e'0EIKC  
                tmpIm = 0.0; ZEXj|wC  
                for (m2 = 0; m2 < n2; m2++) Lqz}&A   
                { ~jgN_jz  
                    angle = tmpGamma * m2; ly[\mGr  
                    index = shift * (n1 * m2 + m1); ~(*co[_  
                    cosAngle = cosf(angle); UeK, q>i  
                    sinAngle = sinf(angle); 3thG*^C 5  
                    tmpRe += x_in[index] * cosAngle + x_in[index + 1] * sinAngle; f 6dE\   
                    tmpIm += x_in[index + 1] * cosAngle - x_in[index] * sinAngle; &)fhlp5  
                } OLd$oxKR  
                angle = tmpAlpha * m1; o0-fUCmC  
                cosAngle = cosf(angle); {YxSH %  
                sinAngle = sinf(angle); v"Ud mv"  
                phaseRe = cosAngle * tmpRe + sinAngle * tmpIm; r~Is,.zZ}  
                phaseIm = cosAngle * tmpIm - sinAngle * tmpRe; t Sh}0N)  
                angle = tmpBeta * m1; ,*O{jc`(  
                cosAngle = cosf(angle); X &;]  
                sinAngle = sinf(angle); GmEJ,%A  
                x_out[idx] += (cosAngle * phaseRe + sinAngle * phaseIm); 2Xq!'NrS  
                x_out[idx + 1] += (cosAngle * phaseIm - sinAngle * phaseRe);  c+G:@%  
            } T/spUlWu  
        } fSQ3 :o  
    } =+sIX3  
    return FFT_OK; ovBd%wJ 0  
} xa%ktn  
*{p& Fy55  
/* =QxE-)v  
// Inverse 1-dimensional FFT F O3eg"{N  
// #t9=qR~"  
// API }FdcbNsP  
// int fftInverse(float *x_in, float *x_out, int n, int shift); LZAj4|~,m  
// INPUT gm%bxr@X~  
// x_in              - Fourier image of 1d input signal(contains 2n elements AB|VO4-?  
                       in order Re(x_in[0]), Im(x_in[0]), kBQenMm  
                       Re(x_in[1]), Im(x_in[1]) and etc.) *U^\Mwp  
// n                 - number of elements for searching counter FFT image g(}8n bTA  
// shift             - shift between input elements ah$7 Oudj  
// OUTPUT v>cE59('0  
// x_in              - input signal (contains n elements) ]GPz>k  
// RESULT )LMux j  
// Error status `h{mj|~  
*/ R{y{  
int fftInverse(float *x_in, float *x_out, int n, int shift) 48NXj\L[y  
{ )B5gs%u]  
    int n1, n2, res, k1, k2, m1, m2, index, idx; -3%)nV  
    float alpha, beta, gamma, angle, cosAngle, sinAngle; )tQ6rd'  
    float tmpRe, tmpIm, phaseRe, phaseIm; FveK|-  
    res = getMultipliers(n, &n1, &n2); ?RAR  
    if (res == FFT_OK) `} Zbfe~  
    { kITmo"$K  
        fftInverse(x_in, x_out, n1, shift); 34M.xB   
        fftInverse(x_in, x_out, n2, shift); ph (k2cb  
    } 6e-h;ylS  
    alpha = (float)(2.0f * PI / ((float)n)); wgP3&4cSUc  
    beta = (float)(2.0f * PI / ((float)n1)); t>u9NZt G  
    gamma = (float)(2.0f * PI / ((float)n2)); ;mKU>F<V  
    for (m1 = 0; m1 < n1; m1++) ?(UXK hs  
    { &Zy=vk*  
        for (m2 = 0; m2 < n2; m2++) (G!J==  
        { TUYl><F5v=  
            idx = (n1 * m2 + m1) * shift; 5!{ g6=(  
            x_out[idx] = 0.0; zd]L9 _  
            x_out[idx + 1] = 0.0; "T[jQr  
            for (k2 = 0; k2 < n2; k2++) {!bJ.O l  
            { *fX)=?h56  
                tmpRe = 0.0; ~?+m=\  
                tmpIm = 0.0; BV:,b S  
                for (k1 = 0; k1 < n1; k1++) `g1~ya(MC  
                { <4bo7XH  
                    angle = beta * k1 * m1; n\DT0E]  
                    index = shift *(n2 * k1 + k2); L,GtIZkE  
                    sinAngle = sinf(angle); N Uml"  
                    cosAngle = cosf(angle); )q-!5^ak  
                    tmpRe += x_in[index] * cosAngle - x_in[index + 1] * sinAngle; "7/YhLq7  
                    tmpIm += x_in[index] * sinAngle + x_in[index + 1] * cosAngle; e@VRdhb  
                } 7 [ji,.7  
                angle = alpha * m1 * k2; )$g /PQ  
                sinAngle = sinf(angle); -*r';Mz;  
                cosAngle = cosf(angle); *r3vTgo$  
                phaseRe = cosAngle * tmpRe - sinAngle * tmpIm; !!>G{  
                phaseIm = cosAngle * tmpIm + sinAngle * tmpRe; UGgi)  
                angle = gamma * k2 * m2; DR=1';63  
                sinAngle = sinf(angle); .[A S  
                cosAngle = cosf(angle); z<*]h^ !3  
                x_out[idx] += cosAngle * phaseRe - sinAngle * phaseIm; C(hg"_W ou  
                x_out[idx + 1] += cosAngle * phaseIm + sinAngle * phaseRe; AG2jl/  
            } 1jVcL)szU  
            x_out[idx] /= n; ,Fiiw  
            x_out[idx + 1] /= n; fOAb?:D  
        } !y.7"G*  
    } 6 H.Da]hk  
    return FFT_OK; `Fr$q1qae{  
} _L>n!"E/  
M`'2 a  
/* e +U o-CO  
// 2-dimensional FFT u)-l+U.  
// .+sIjd  
// API g;T`~  
// int fft2d(float *x_in, float *x_out, int numRows, int numColls); ^gImb`<6-  
// INPUT X,~C&#  
// x_in              - input signal (matrix, launched by rows) PoZBiw@  
// numRows           - number of rows X +R_TC  
// numColls          - number of collumns b._pG(o1  
// OUTPUT gC.T5,tn  
// x_out             - output signal (contains (2 * numRows * numColls) elements I]58;|J  
                       in order Re(x_in[0][0]), Im(x_in[0][0]), .E(Ucnz/  
                       Re(x_in[0][1]), Im(x_in[0][1]) and etc.) ` fXcW)  
// RESULT 90a= 39kI  
// Error status -VL3em|0  
*/ \oyr[so(i  
int fft2d(float *x_in, float *x_out, int numRows, int numColls) ^<c?Ire  
{ t V</ x0#  
    int i, size; 'tekne  
    float *x_outTmp; hz!.|U@,{<  
    size = numRows * numColls; HzV3O-Qz]  
    x_outTmp = (float *)malloc(sizeof(float) * (2 * size)); :v#3;('7  
    for (i = 0; i < numRows; i++) 74_ji  !  
    { h1xYQF_`Z  
        fft(x_in + i * 2 * numColls, HjrCX>v  
            x_outTmp + i * 2 * numColls, &}<IR\ci  
            numColls, 2); se&:Y&vrc~  
    } }0: =)e  
    for (i = 0; i < numColls; i++) u?!p[y6  
    { O3S_P]{*ny  
        fft(x_outTmp + 2 * i, Tw$lakw  
            x_out + 2 * i, Y`%:hvy~  
            numRows, 2 * numColls); h<[o;E  
    } J^U#dYd  
    free(x_outTmp); *+5AN306  
    return FFT_OK; S>nM&758  
} ) b?HK SqI  
N]gdS]pP2{  
/* +PjH2  
// Inverse 2-dimensional FFT F9N)UW:w  
// k \|Hd"T  
// API U)2\=%8  
// int fftInverse2d(float *x_in, float *x_out, int numRows, int numColls); VUk2pEGO.  
// INPUT +c?1\{M   
// x_in              - Fourier image of matrix (contains (2 * numRows * numColls) *G^ QS"%  
                       elements in order Re(x_in[0][0]), Im(x_in[0][0]), jT%k{"+>+?  
                       Re(x_in[0][1]), Im(x_in[0][1]) and etc.) :be BiO  
// numRows           - number of rows J"# o #~  
// numColls          - number of collumns UT%^!@u  
// OUTPUT m z) O  
// x_out             - initial signal (matrix, launched by rows) -:&qNY:Vp  
// RESULT v [\' M  
// Error status zQ&`|kS  
*/ q,A;d^g  
int fftInverse2d(float *x_in, float *x_out, int numRows, int numColls) NLf6}  
{ r$<[`L+6  
    int i, size;  ,SNN[a  
    float *x_outTmp; 8K =sx @l  
    size = numRows * numColls; %#7Yr(&  
    x_outTmp = (float *)malloc(sizeof(float) * (2 * size)); gmd-$%"  
    for (i = 0; i < numRows; i++) ~RgO9p(dY  
    { WW\t<O;z  
        fftInverse(x_in + i * 2 * numColls, 4Hc+F (  
            x_outTmp + i * 2 * numColls, Fg;V6s/>ts  
            numColls, 2); C7:;<<"P  
    } PZ06 _  
    for (i = 0; i < numColls; i++) N{w)}me[YY  
    { 8&+m5x S  
        fftInverse(x_outTmp + 2 * i, I@ "%iYL  
            x_out + 2 * i, JO{Rth  
            numRows, 2 * numColls); Gpv9~&  
    } I Wc?E  
    free(x_outTmp); Us kz~~}G  
    return FFT_OK; !0p_s;uu,W  
}
最佳答案奖励: (+1) 学点
级别: 北风工程师

UID: 474133
精华: 0
发帖: 541
威望: 1194 点
学点: 844 点
贡献: 0 点
好评: 0 点
学币: 0 个
注册时间: 2014-07-13
最后登录: 2014-09-01
板凳(2楼)  发表于: 2014-07-28 16:19||

老师看不懂啊,能说详细点吗?
级别: 北风工程师

UID: 474135
精华: 0
发帖: 543
威望: 1108 点
学点: 666 点
贡献: 0 点
好评: 0 点
学币: 0 个
注册时间: 2014-07-13
最后登录: 2014-08-25
地板(3楼)  发表于: 2014-07-28 16:20||

那该怎么****成控件啊
级别: 北风爱好者

UID: 579634
精华: 0
发帖: 1
威望: 1 点
学点: 3 点
贡献: 0 点
好评: 0 点
学币: 0 个
注册时间: 2015-05-18
最后登录: 2015-05-27
地下室(4楼)  发表于: 2015-05-18 20:28||

回 楼主(448832164) 的帖子

你好  请问你弄好了吗?  我今年也要弄这个软件  我看了帖子   但还不知道怎么弄    如果你弄好了还留着  能不能发给我  拜托了