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

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

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

大学软件设计实验题目,有没有好人帮忙啊 R1hmJ  
Z wKX$(n  
要求:输入给定信号(数组),基于FFT快速频谱计算,给出频谱图显示。并****成控件方便调用。 t(UBs-t  
格式:设计题目     I RLAsb3  
任务要求     y+^KVEw  
实验设备及软件     Rex 86!TO  
参考文献
此帖悬赏结束
最佳答案: 1 学点
最佳答案获得者: 慕容紫英
级别: 北风资深工程师


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

先搜索下载安装OpenCV gPk,nB  
然后参考C:\Program Files\OpenCV\modules\objdetect\src\fft.cpp 7wx=#  
C/C++ code #wIWh^^ Zy  
jSE)&K4nI  
3xs<w7  
#include "precomp.hpp" QNx]8r  
#include "_lsvm_fft.h" D2&d",%&f  
>JE+j=  
int getEntireRes(int number, int divisor, int *entire, int *res) (7G4v  
{ rk1,LsZVS  
    *entire = number / divisor; ,.9lz  
    *res = number % divisor;  `qs,V  
    return FFT_OK; 9$HKP9 G  
} k^%=\c   
~_EDJp1J  
int getMultipliers(int n, int *n1, int *n2) h-ii-c?R@0  
{ s>6h]H  
    int multiplier, i; %9>w|%+;U+  
    if (n == 1) 9k;,WU(K<  
    {  M99ku'  
        *n1 = 1; ~4~r  
        *n2 = 1; &233QRYM  
        return FFT_ERROR; // n = 1 Uwkxc  
    } bSw^a{~)  
    multiplier = n / 2; u1X^#K$nu'  
    for (i = multiplier; i >= 2; i--) f9K7^qwkiz  
    { #[jS&rr(  
        if (n % i == 0) oH=?1~ e  
        { sA?8i:]O:  
            *n1 = i; bss2<mqlH  
            *n2 = n / i; 5vLXMdN  
            return FFT_OK; // n = n1 * n2 '=$`N G8 l  
        } } TU r96  
    } F6sQeU  
    *n1 = 1; D@&xj_#\}  
    *n2 = n; ;&=jSgr8  
    return FFT_ERROR; // n - prime number CqEbQ>?  
} `\VtTS  
X:s~w#>R  
/* m OUO)[6y  
// 1-dimensional FFT GwF8ze+cH  
// ZX&e,X~V  
// API 2z !05]B%  
// int fft(float *x_in, float *x_out, int n, int shift); yJ!26  
// INPUT ~v(c9I)  
// x_in              - input signal w` +,  
// n                 - number of elements for searching Fourier image >g !Z|ju  
// shift             - shift between input elements # l9VTzi  
// OUTPUT H,TApF89A  
// x_out             - output signal (contains 2n elements in order /#T{0GBXe  
                       Re(x_in[0]), Im(x_in[0]), Re(x_in[1]), Im(x_in[1]) and etc.) yL asoh  
// RESULT xKE=$SV(  
// Error status c&bhb[  
*/ })] iN "  
int fft(float *x_in, float *x_out, int n, int shift) T+T)~!{%  
{ (5] [L<L  
    int n1, n2, res, k1, k2, m1, m2, index, idx; ?<.a>"!  
    float alpha, beta, gamma, angle, cosAngle, sinAngle; E8av/O VUd  
    float tmpGamma, tmpAlpha, tmpBeta; awR !=\  
    float tmpRe, tmpIm, phaseRe, phaseIm; O-7)"   
    res = getMultipliers(n, &n1, &n2); +mBS&FK  
    if (res == FFT_OK) 'V%w{ZiiV  
    { F^{31iU~CX  
        fft(x_in, x_out, n1, shift); >k\p%{P  
        fft(x_in, x_out, n2, shift); 6, j60`f)  
    } MzB.Vvsy%9  
    alpha = (float)(2.0 * PI / ((float)n)); 8Ckd.HKpQ  
    beta = (float)(2.0 * PI / ((float)n1)); xKBi".wA  
    gamma = (float)(2.0 * PI / ((float)n2)); R%r25_8  
    for (k1 = 0; k1 < n1; k1++) ncadVheKt  
    { I-8I/RRkmP  
        tmpBeta = beta * k1; -ewR:Y@j  
        for (k2 = 0; k2 < n2; k2++) tkm@&e=e%  
        { [bKc5qp  
            idx = shift * (n2 * k1 + k2); 2V;{@k  
            x_out[idx] = 0.0; Zc38ht\r;  
            x_out[idx + 1] = 0.0; C8v  
            tmpGamma = gamma * k2; "D>/#cY1/  
            tmpAlpha = alpha * k2; Ha]vG@?+  
            for (m1 = 0; m1 < n1; m1++) j0oto6z~b  
            { |Wck-+}U  
                tmpRe = 0.0; I+W,%)vb  
                tmpIm = 0.0; 1Hhr6T^)  
                for (m2 = 0; m2 < n2; m2++) V/DMkO#a  
                { q},,[t  
                    angle = tmpGamma * m2; F@ |(  
                    index = shift * (n1 * m2 + m1); 1NZpd'$c  
                    cosAngle = cosf(angle); _7u&.l<;  
                    sinAngle = sinf(angle); e\aW~zs 2  
                    tmpRe += x_in[index] * cosAngle + x_in[index + 1] * sinAngle; fUis_?!  
                    tmpIm += x_in[index + 1] * cosAngle - x_in[index] * sinAngle; r$M<vo6C  
                } .L^j:2(L  
                angle = tmpAlpha * m1; Hr]  
                cosAngle = cosf(angle); QTF1~A\  
                sinAngle = sinf(angle); "g"%7jK  
                phaseRe = cosAngle * tmpRe + sinAngle * tmpIm; >(YH@Z&;  
                phaseIm = cosAngle * tmpIm - sinAngle * tmpRe; o[JZ>nm  
                angle = tmpBeta * m1; vd^Z^cpi p  
                cosAngle = cosf(angle); ;InMgo,  
                sinAngle = sinf(angle);  .MDSP/s  
                x_out[idx] += (cosAngle * phaseRe + sinAngle * phaseIm); \%}]wf}  
                x_out[idx + 1] += (cosAngle * phaseIm - sinAngle * phaseRe); dci,[TEGu  
            } S}Z@g  
        } l.;^w  
    } d7&d FvG  
    return FFT_OK; j~+(#|  
} .A/xH x  
wwR}h I(  
/* (<H@W/0$  
// Inverse 1-dimensional FFT 4 }0YLwgJ  
// "~Kph0-  
// API ?caHS2%?ae  
// int fftInverse(float *x_in, float *x_out, int n, int shift); <ZO+e*4  
// INPUT X}QcXc.d  
// x_in              - Fourier image of 1d input signal(contains 2n elements NUh%\{  
                       in order Re(x_in[0]), Im(x_in[0]), 931GJA~g  
                       Re(x_in[1]), Im(x_in[1]) and etc.) Gt,VSpb~s  
// n                 - number of elements for searching counter FFT image AOqL&z  
// shift             - shift between input elements @6;ZP1  
// OUTPUT ']^]z".H  
// x_in              - input signal (contains n elements) ;<F^&/a|yQ  
// RESULT G;pc,\MF  
// Error status KfC{/J\   
*/ zSOZr2- ^a  
int fftInverse(float *x_in, float *x_out, int n, int shift) P+e{,~o  
{ r"VNq&v]9  
    int n1, n2, res, k1, k2, m1, m2, index, idx; -<u_fv  
    float alpha, beta, gamma, angle, cosAngle, sinAngle; yZmeke)_  
    float tmpRe, tmpIm, phaseRe, phaseIm; O^3XhTW^\~  
    res = getMultipliers(n, &n1, &n2); j0=H6Y  
    if (res == FFT_OK) 1 :{+{Yl7  
    { 9T2y2 d!X  
        fftInverse(x_in, x_out, n1, shift); (r1"!~d@  
        fftInverse(x_in, x_out, n2, shift); iQiX wEAi[  
    } I3ugBLxVC3  
    alpha = (float)(2.0f * PI / ((float)n)); =ATQ2\T$m  
    beta = (float)(2.0f * PI / ((float)n1)); 0OtUb:8LX  
    gamma = (float)(2.0f * PI / ((float)n2)); 7G Jhc  
    for (m1 = 0; m1 < n1; m1++) 1b2xWzpG  
    { ^>y|{;`  
        for (m2 = 0; m2 < n2; m2++) 'SWK{t \4  
        { !]8QOn7=  
            idx = (n1 * m2 + m1) * shift; hXc:y0 0  
            x_out[idx] = 0.0; Saks~m7,  
            x_out[idx + 1] = 0.0; kr44@!s+'  
            for (k2 = 0; k2 < n2; k2++) 7lzmAih  
            { ;"NW= P&  
                tmpRe = 0.0; w6AG:u  
                tmpIm = 0.0; Rvj[Csgi  
                for (k1 = 0; k1 < n1; k1++) #0Z%4WQ  
                { MX|@x~9W  
                    angle = beta * k1 * m1; 5RKs 2 eV  
                    index = shift *(n2 * k1 + k2); X/D% cQ6  
                    sinAngle = sinf(angle); Et;Ubj"+  
                    cosAngle = cosf(angle); #*+$o<Q]9  
                    tmpRe += x_in[index] * cosAngle - x_in[index + 1] * sinAngle; Ge*N%=MX 8  
                    tmpIm += x_in[index] * sinAngle + x_in[index + 1] * cosAngle; yONX?cS  
                } 6^z):d#u  
                angle = alpha * m1 * k2; rpL]5e !  
                sinAngle = sinf(angle); '.XR,\g>  
                cosAngle = cosf(angle); ]!WD">d:  
                phaseRe = cosAngle * tmpRe - sinAngle * tmpIm; w2V:g$~,  
                phaseIm = cosAngle * tmpIm + sinAngle * tmpRe; w(q\75  
                angle = gamma * k2 * m2; bG]?AiW r  
                sinAngle = sinf(angle); 3Zm;:v4y  
                cosAngle = cosf(angle); "X-"uIc  
                x_out[idx] += cosAngle * phaseRe - sinAngle * phaseIm; B1J2m^  
                x_out[idx + 1] += cosAngle * phaseIm + sinAngle * phaseRe; -D wO*f  
            } ohPDknHp  
            x_out[idx] /= n; ?b?YiK&yz  
            x_out[idx + 1] /= n; ifadnl26 s  
        } b25C[C5C  
    } 'CvV Kt k  
    return FFT_OK; y~py+:_  
} 4R9y~~+  
%"AB\lL.  
/* xDn#=%~+x  
// 2-dimensional FFT +3r4GEa Z  
// A 7zL\U4  
// API *NoixV1>  
// int fft2d(float *x_in, float *x_out, int numRows, int numColls); --F6n/>  
// INPUT *^p^tK  
// x_in              - input signal (matrix, launched by rows) t:tIzFNv  
// numRows           - number of rows "?s  
// numColls          - number of collumns '~AR|8q?  
// OUTPUT |) CfO4  
// x_out             - output signal (contains (2 * numRows * numColls) elements =$\9t$A  
                       in order Re(x_in[0][0]), Im(x_in[0][0]), uQz!of%x  
                       Re(x_in[0][1]), Im(x_in[0][1]) and etc.) b}Xh|0`b+  
// RESULT T}Ve:S  
// Error status Gw+pjSJL`  
*/ @ [%K D  
int fft2d(float *x_in, float *x_out, int numRows, int numColls) f<3lxu  
{ PgYIQpV  
    int i, size; LMI7Ih;  
    float *x_outTmp; aJ J 6 3aJ  
    size = numRows * numColls; Zo}vV2  
    x_outTmp = (float *)malloc(sizeof(float) * (2 * size)); !>)o&sM  
    for (i = 0; i < numRows; i++) =&WH9IKz  
    { %g~zE a-g  
        fft(x_in + i * 2 * numColls, @oQ"FLF.  
            x_outTmp + i * 2 * numColls, RSup_4A  
            numColls, 2); \hg%J/  
    } ^CP>|JWD^  
    for (i = 0; i < numColls; i++) cueaOtD  
    { 6bT> x5?  
        fft(x_outTmp + 2 * i, | cL,$G  
            x_out + 2 * i, i-R}O6  
            numRows, 2 * numColls); XC4wm #R  
    } &.P G2f*  
    free(x_outTmp); XT1P. w[aA  
    return FFT_OK; F12$BK DH  
} ub M  N  
gi$'x^]#  
/* Cng_*\=O  
// Inverse 2-dimensional FFT svtqX-Vj"  
// Q;GcV&f;f  
// API ^0?ww&X  
// int fftInverse2d(float *x_in, float *x_out, int numRows, int numColls); /z:1nq  
// INPUT M"6J"s  
// x_in              - Fourier image of matrix (contains (2 * numRows * numColls) wV\G$|Y  
                       elements in order Re(x_in[0][0]), Im(x_in[0][0]), QwL*A `@  
                       Re(x_in[0][1]), Im(x_in[0][1]) and etc.) 1 ]ePU8  
// numRows           - number of rows 2a*+mw  
// numColls          - number of collumns oA3;P]~[  
// OUTPUT wQa,o l_p  
// x_out             - initial signal (matrix, launched by rows) \\3 ?ij:v  
// RESULT /4|_A {m{m  
// Error status W j`f^^\HJ  
*/ Rln\  
int fftInverse2d(float *x_in, float *x_out, int numRows, int numColls) .yD5>iBh  
{ Q: Ma3El\  
    int i, size; KNR7Igw?}  
    float *x_outTmp; %,e,KcP'  
    size = numRows * numColls; >=;hnLu  
    x_outTmp = (float *)malloc(sizeof(float) * (2 * size)); @!^Y_q  
    for (i = 0; i < numRows; i++) ?Ezy0>j  
    { rV} 5&N*c  
        fftInverse(x_in + i * 2 * numColls, oDayfyy4y)  
            x_outTmp + i * 2 * numColls, 2/\I/QkTs  
            numColls, 2); W }v ,6Oe  
    } :#cJZ\YH  
    for (i = 0; i < numColls; i++) :jC$$oC].  
    { +\?+cXSc  
        fftInverse(x_outTmp + 2 * i, gtT&97tT<  
            x_out + 2 * i, piqh7u3~  
            numRows, 2 * numColls); 2p 4iir  
    } +ej5C:El_}  
    free(x_outTmp); ~z")';I|  
    return FFT_OK; y]+[o1]-c  
}
最佳答案奖励: (+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) 的帖子

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