'프로그램 사용'에 해당되는 글 2258건

  1. 2023.04.07 fft 복소수(complex) - 실수, 허수부(real, imaginary)
  2. 2023.04.06 gst-inspector.c
  3. 2023.04.05 fft 0 Hz 2
  4. 2023.04.04 partial fft
  5. 2023.03.31 fftw plan
  6. 2023.03.30 libfftw3 precision
  7. 2023.03.29 spectrogram
  8. 2023.03.29 fft 분석 패러미터
  9. 2023.03.27 gstreamer videomixer 반쪽 성공
  10. 2023.03.27 gstreamer videomixer ... 2?

내 프로그램에서도 한번 도식화 해볼까?

amplitude만 보는데 real 값과 imaginary 값은 어떻게 보여질지 궁금해서 찾아보는데

그렇게는 잘 안써서 그런지 그림도 찾기 힘들다.

 

[링크 : https://stackoverflow.com/questions/25624548/fft-real-imaginary-abs-parts-interpretation]

 

 

+

부랴부랴 수정해서 확인해보니 실수부, 허수부는 * 100,000 해서 받아와서 표현

일단 네 가지 데이터가 오가면서 출력되는데 이걸 phase 라고 보야하려나?

 

실수, 허수 둘 다 양수

 

실수, 허수 둘 다 음수

 

실수 양수, 허수 음수

실수 음수, 허수 양수

 

'프로그램 사용 > fft, fftw' 카테고리의 다른 글

fft phase 연산  (0) 2023.04.07
fftw input range?  (0) 2023.04.07
fft 0 Hz  (2) 2023.04.05
partial fft  (0) 2023.04.04
fftw plan  (0) 2023.03.31
Posted by 구차니

한번 빌드해서 원하는 결과만 덤프하는 용도로 수정이 가능하려나?

[링크 : https://github.com/GStreamer/gstreamer/blob/main/subprojects/gstreamer/tools/gst-inspect.c]

 

 gst-inspect 에서 원하는 정보는 아래의 Pad template 부분

Pad Templates:
  SINK template: 'sink_%u'
    Availability: On request
    Capabilities:
      video/x-raw
                 format: { (string)AYUV, (string)BGRA, (string)ARGB, (string)RGBA, (string)ABGR, (string)Y444, (string)Y42B, (string)YUY2, (string)UYVY, (string)YVYU, (string)I420, (string)YV12, (string)NV12, (string)NV21, (string)Y41B, (string)RGB, (string)BGR, (string)xRGB, (string)xBGR, (string)RGBx, (string)BGRx }
                  width: [ 1, 2147483647 ]
                 height: [ 1, 2147483647 ]
              framerate: [ 0/1, 2147483647/1 ]
  
  SRC template: 'src'
    Availability: Always
    Capabilities:
      video/x-raw
                 format: { (string)AYUV, (string)BGRA, (string)ARGB, (string)RGBA, (string)ABGR, (string)Y444, (string)Y42B, (string)YUY2, (string)UYVY, (string)YVYU, (string)I420, (string)YV12, (string)NV12, (string)NV21, (string)Y41B, (string)RGB, (string)BGR, (string)xRGB, (string)xBGR, (string)RGBx, (string)BGRx }
                  width: [ 1, 2147483647 ]
                 height: [ 1, 2147483647 ]
              framerate: [ 0/1, 2147483647/1 ]

Element has no clocking capabilities.
Element has no URI handling capabilities.

 

Pad Templates를 출력하는 함수

static void
print_pad_templates_info (GstElement * element, GstElementFactory * factory)

[링크 : https://github.com/GStreamer/gstreamer/blob/main/subprojects/gstreamer/tools/gst-inspect.c#L816]

 

Capabilities 부분을 출력하는 함수

static void
print_caps (const GstCaps * caps, const gchar * pfx)

[링크 : https://github.com/GStreamer/gstreamer/blob/main/subprojects/gstreamer/tools/gst-inspect.c#L194]

'프로그램 사용 > gstreamer' 카테고리의 다른 글

gst-device-monitor-1.0  (0) 2023.12.06
gstremaer videobox + videomixer  (0) 2023.04.10
gstreamer videomixer 반쪽 성공  (0) 2023.03.27
gstreamer videomixer ... 2?  (0) 2023.03.27
gstreamer pad - sink 와 src  (0) 2023.03.27
Posted by 구차니

정리하자면

FFT를 100개 하면, 1~50 Hz와 0Hz에 대한 분석 결과가 나온다.

그래서 N / 2 + 1개

 

---

도대체 왜 N/2+1이 나오나를 찾는데 이해를 못하겠다.

 

For a real-to-complex transform you get N / 2 + 1 complex outputs for N real inputs (the redundant symmetric outputs are not generated).

The 0 Hz component is in bin 0.

 

Now out contains r0, r1, r2, ..., rn/2, i(n+1)/2-1, ..., i2, i1 , as it is written in the manual.

r0 ,out[0],is the mean value of your data/signal.
r1 ,out[1],is the real part of the first element of the DFT.
...
i0 is 0 because you're using real data , so it isn't stored in out.
i1 ,out[N-1],is the imaginary part of the first element of the DFT.
i2 ,out[N-2],is the imaginary part of the second element of the DFT.
If N is a even number , then r(N/2) out[N/2] is the Nyquist frequency amplitude.

Im new to fftw library

Remember that FFTW computes only the product of your data by the trigonometric functions, but it don't normalize them. You can find more info about the halfcomplex here.

[링크 : https://stackoverflow.com/questions/36637727/fftw-library-what-is-the-output-size-of-fftw-plan-dft-r2c-1d]

[링크 : https://kr.mathworks.com/matlabcentral/answers/42325-fft-is-finding-a-max-amplitude-at-0-hz]

 

chatGPT

The reason that the Fast Fourier Transform (FFT) in the library FFTW produces a result of N/2+1 values when applied to real input data of length N is because of the way that the FFT algorithm works.
In FFTW, the FFT algorithm used is called the "real-to-complex" FFT, which takes real-valued input data and produces complex-valued output data. When applied to real input data, the algorithm takes advantage of the symmetry properties of the Fourier transform of real-valued signals. Specifically, the Fourier transform of a real-valued signal is complex-conjugate symmetric, meaning that if x(t) is a real-valued signal, then its Fourier transform X(f) satisfies X(-f) = conj(X(f)), where "conj" denotes complex conjugation.
Because of this symmetry property, half of the output values of the FFT algorithm are redundant, and can be calculated from the other half. Specifically, the output values for frequencies from 0 to N/2 are unique, while the output values for frequencies from N/2+1 to N-1 can be calculated as the complex conjugate of the corresponding frequency from 1 to N/2-1.
Therefore, to save computation time and memory, FFTW only calculates the unique output values for frequencies from 0 to N/2, as well as the value for frequency N/2 (if N is even). This results in a total of N/2+1 output values.
FFTW 라이브러리에서 Fast Fourier Transform (FFT)를 적용하면, 길이가 N인 실수 입력 데이터에 대해 복소수 출력 데이터 N/2+1개가 생성됩니다. 이는 FFT 알고리즘이 동작하는 방식 때문입니다.
FFTW에서 사용되는 FFT 알고리즘은 "real-to-complex" FFT라고 불리며, 실수값 입력 데이터를 복소수값 출력 데이터로 변환합니다. 이 알고리즘은 실수값 신호의 푸리에 변환의 대칭성(symmetric) 특성을 활용합니다. 구체적으로, 실수값 신호 x(t)의 푸리에 변환 X(f)은 X(-f) = conj(X(f)) 라는 복소수 공액대칭성(complex-conjugate symmetric)을 만족합니다. 여기서 "conj"는 복소수 공액(conjugate)를 의미합니다.
이 대칭성 특성 때문에 FFT 알고리즘의 출력값 중 절반은 중복되는 값이며, 나머지 절반은 이 중복된 값들로부터 계산될 수 있습니다. 구체적으로, 0부터 N/2까지의 주파수 대역에서는 고유한 출력값이 존재하며, N/2+1부터 N-1까지의 주파수 대역에서는 대응하는 1부터 N/2-1까지의 주파수 대역의 복소수 공액값을 계산하여 구할 수 있습니다.
따라서 FFTW는 연산 시간과 메모리를 절약하기 위해, 0부터 N/2까지의 주파수 대역에 대한 고유한 출력값과, N이 짝수인 경우 주파수 N/2에 대한 출력값을 계산합니다. 이렇게 계산된 출력값의 총 개수는 N/2+1개가 됩니다.

 

 

The DFT results are stored in-order in the array out, with the zero-frequency (DC) component in out[0]. 

[링크 : https://www.fftw.org/fftw3_doc/Complex-One_002dDimensional-DFTs.html#Complex-One_002dDimensional-DFTs]

 

+

2023.06.16

 

Size of FFT in 1D is not half of the signal length. It's still the signal length (assuming FFT length was of the signal length). However for real data, due to conjugate symmetryhalf of this is redundant and can be dicarded to reduce storage. Note however that, when it's required to process the FFT data, you have to construct the full length from the half and proceed.

This is also the reason why spectral analysis software display only positive frequencies for real data; i.e, negative frequencies will be a mirror copy (of the magnitude) of positive frequencies.

But you don't have to discard the half. You can just retain it.

For image processing, the symmetry of FFT for real input data again exist and if you wish you can also dicard half of the image FFT data. Whether this will be employed or not depends on the intentions of the package.

[링크 : https://dsp.stackexchange.com/questions/55239/why-is-the-size-of-results-from-fft-half-the-size-of-the-input-while-that-is-no]

[링크 : https://brianmcfee.net/dstbook-site/content/ch06-dft-properties/Conjugate-Symmetry.html]

'프로그램 사용 > fft, fftw' 카테고리의 다른 글

fftw input range?  (0) 2023.04.07
fft 복소수(complex) - 실수, 허수부(real, imaginary)  (0) 2023.04.07
partial fft  (0) 2023.04.04
fftw plan  (0) 2023.03.31
libfftw3 precision  (0) 2023.03.30
Posted by 구차니

'프로그램 사용 > fft, fftw' 카테고리의 다른 글

fft 복소수(complex) - 실수, 허수부(real, imaginary)  (0) 2023.04.07
fft 0 Hz  (2) 2023.04.05
fftw plan  (0) 2023.03.31
libfftw3 precision  (0) 2023.03.30
spectrogram  (0) 2023.03.29
Posted by 구차니

fftw를 이용하여 fft 연산을 하려고 하면

fft_plan_dft*() 함수로 plan을 만들고 (이 과정에서 input, output 포인터 지정)

fftw_execute() 함수로 fft 연산을 한다.

 

fft_plan_dft_*() 함수만 해도 수행에 꽤 시간이 걸리는 관계로

포인터를 바꾸어서 다시 할당할게 아니라.. 메모리 복사를 한번 더 하고

plan에 지정된 포인터를 재사용 하는게 cpu 점유율을 낮추는 방법이 될 것 같다.

 

Plans for all transform types in FFTW are stored as type fftw_plan (an opaque pointer type), and are created by one of the various planning routines described in the following sections. An fftw_plan contains all information necessary to compute the transform, including the pointers to the input and output arrays.

[링크 : https://www.fftw.org/fftw3_doc/Using-Plans.html]

'프로그램 사용 > fft, fftw' 카테고리의 다른 글

fft 0 Hz  (2) 2023.04.05
partial fft  (0) 2023.04.04
libfftw3 precision  (0) 2023.03.30
spectrogram  (0) 2023.03.29
fft 분석 패러미터  (0) 2023.03.29
Posted by 구차니

libfftw3 만 있는 줄 알았는데 yocto에서 이상한(?) l d 이런 붙는게 있다고 해서 찾아보니

double / long / quad / single 이라는 이상한(?) 정밀도가 존재한다.

$ apt-cache search libfftw*
libfftw3-double3 - Fast Fourier Transforms 계산용 라이브러리 - 이중 정밀도
libfftw3-long3 - Library for computing Fast Fourier Transforms - Long precision
libfftw3-quad3 - Library for computing Fast Fourier Transforms - Quad precision
libfftw3-single3 - Library for computing Fast Fourier Transforms - Single precision
libfftw3-bin - Library for computing Fast Fourier Transforms - Tools
libfftw3-dbg - Library for computing Fast Fourier Transforms - debug symbols
libfftw3-dev - Library for computing Fast Fourier Transforms - development
libfftw3-doc - Documentation for fftw version 3
libfftw3-3 - Fast Fourier Transforms 계산용 라이브러리
libfftw3-mpi-dev - MPI Library for computing Fast Fourier Transforms - development
libfftw3-mpi3 - MPI Library for computing Fast Fourier Transforms
libgnuradio-fft3.7.11 - gnuradio fast Fourier transform functions
sndfile-tools - Collection of programs for operating on sound files

 

Link to the single/long-double libraries; on Unix, -lfftw3f or -lfftw3l instead of (or in addition to) -lfftw3. (You can link to the different-precision libraries simultaneously.)
Include the same <fftw3.h> header file.
Replace all lowercase instances of ‘fftw_’ with ‘fftwf_’ or ‘fftwl_’ for single or long-double precision, respectively. (fftw_complex becomes fftwf_complex, fftw_execute becomes fftwf_execute, etcetera.)
Uppercase names, i.e. names beginning with ‘FFTW_’, remain the same.
Replace double with float or long double for subroutine parameters.

[링크 : https://www.fftw.org/fftw3_doc/Precision.html]

'프로그램 사용 > fft, fftw' 카테고리의 다른 글

partial fft  (0) 2023.04.04
fftw plan  (0) 2023.03.31
spectrogram  (0) 2023.03.29
fft 분석 패러미터  (0) 2023.03.29
FFT 윈도우, 오버랩  (0) 2023.03.23
Posted by 구차니

rtl-sdr에서 gqrx나 airspy sdr# 에서 처럼

주파수에 대한 그래프를 시간축으로 그리는 걸 spectrogram 이라고 하는 듯

 

[링크 : https://blog.freifunk.net/2017/06/26/choosing-spectrogram-visualization-library-javascript/]

[링크 : https://www.arc.id.au/Spectrogram.html]

 

에러 발생

[링크 : https://github.com/sebleier/spectrogram.js]

 

speccy - 오디오 초기화 문제 발생(linux google-chrome, firefox)

[링크 : https://github.com/drandrewthomas/Speccy]

 

+

정책 변경, deprecated로 인해서 먼가 손을 대긴 해야 할 듯

[링크 : https://sxbxn.tistory.com/12]

[링크 : https://developer.chrome.com/blog/autoplay/#webaudio]

'프로그램 사용 > fft, fftw' 카테고리의 다른 글

fftw plan  (0) 2023.03.31
libfftw3 precision  (0) 2023.03.30
fft 분석 패러미터  (0) 2023.03.29
FFT 윈도우, 오버랩  (0) 2023.03.23
cabs()  (0) 2023.02.15
Posted by 구차니

FFT Size

FFT overlap

FFT windowing

 - leakage

[링크 : https://scribblinganything.tistory.com/532]

'프로그램 사용 > fft, fftw' 카테고리의 다른 글

libfftw3 precision  (0) 2023.03.30
spectrogram  (0) 2023.03.29
FFT 윈도우, 오버랩  (0) 2023.03.23
cabs()  (0) 2023.02.15
FFT 분석 기법  (0) 2023.02.07
Posted by 구차니

되는데 엄청 느리다.

아마 async 옵션을 안줘서 그런거 같은데..

 

아무튼 gstaremer의 파이프를 구성하는데 ximagesink가 비디오를 출력하기 위한 마지막 sink 니까

파이프 구성없이 v4l2src를 실행하고 jpegdec 한다음(MJPG 웹캠이라) mix 라는 이름을 가지고 있던 videomixer 에게 던지면 끝

$ gst-launch-1.0 v4l2src ! jpegdec ! videomixer name=mix ! videoconvert ! ximagesink v4l2src device=/dev/video2 ! jpegdec ! mix.

'프로그램 사용 > gstreamer' 카테고리의 다른 글

gstremaer videobox + videomixer  (0) 2023.04.10
gst-inspector.c  (0) 2023.04.06
gstreamer videomixer ... 2?  (0) 2023.03.27
gstreamer pad - sink 와 src  (0) 2023.03.27
gstreamer cheat sheet - tee, queue  (0) 2023.03.22
Posted by 구차니

chatGPT 님께 물어보니 tee나 queue 대신 videomixer를 알려주시는데

videomixer의 경우 특이하게(?) sink_%u 라고 여러개의 sink를 받을 수 있는 엘리먼트이다.

Pad Templates
sink_%u
video/x-raw:
         format: { AYUV, BGRA, ARGB, RGBA, ABGR, Y444, Y42B, YUY2, UYVY, YVYU, I420, YV12, NV12, NV21, Y41B, RGB, BGR, xRGB, xBGR, RGBx, BGRx }
          width: [ 1, 2147483647 ]
         height: [ 1, 2147483647 ]
      framerate: [ 0/1, 2147483647/1 ]
Presence – request

Direction – sink

Object type – GstPad

src
video/x-raw:
         format: { AYUV, BGRA, ARGB, RGBA, ABGR, Y444, Y42B, YUY2, UYVY, YVYU, I420, YV12, NV12, NV21, Y41B, RGB, BGR, xRGB, xBGR, RGBx, BGRx }
          width: [ 1, 2147483647 ]
         height: [ 1, 2147483647 ]
      framerate: [ 0/1, 2147483647/1 ]
Presence – always

Direction – src

Object type – GstPad

[링크 : https://gstreamer.freedesktop.org/documentation/videomixer/index.html?gi-language=c]

 

그럴싸 하게 주는데 막상 실행하면 에러 -_-

$ gst-launch-1.0 \
v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480 ! videorate ! videoconvert ! videocrop top=0 left=0 right=640 bottom=480 ! \
videomixer name=mix \
sink_0::xpos=0 sink_0::ypos=0 sink_0::alpha=0 \
v4l2src device=/dev/video1 ! video/x-raw,width=640,height=480 ! videorate ! videoconvert ! videocrop top=0 left=0 right=640 bottom=480 ! \
sink_1::xpos=640 sink_1::ypos=0 sink_1::alpha=0 \
! videoconvert ! autovideosink

(gst-launch-1.0:11399): GStreamer-CRITICAL **: 12:04:11.113: gst_element_link_pads_filtered: assertion 'GST_IS_BIN (parent)' failed
WARNING: erroneous pipeline: syntax error

'프로그램 사용 > gstreamer' 카테고리의 다른 글

gst-inspector.c  (0) 2023.04.06
gstreamer videomixer 반쪽 성공  (0) 2023.03.27
gstreamer pad - sink 와 src  (0) 2023.03.27
gstreamer cheat sheet - tee, queue  (0) 2023.03.22
gstreamer를 이용하여 uvc 웹캠 (mjpg) 보기  (0) 2023.03.22
Posted by 구차니