Skip to content
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

signal contrib module #1273

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,15 @@ jobs:
key: ${{ steps.cache-opencv-build.outputs.cache-primary-key }}
path: |
./opencv/build
- name: List OpenCV Libraries
run: |
dir ${env:GITHUB_WORKSPACE}\opencv\build\install\x64\mingw\lib
- name: Set GoCV env
run: |
go env
echo "CGO_CXXFLAGS=--std=c++11" >> $env:GITHUB_ENV
echo "CGO_CPPFLAGS=-I${env:GITHUB_WORKSPACE}\opencv\build\install\include" >> $env:GITHUB_ENV
echo "CGO_LDFLAGS=-L${env:GITHUB_WORKSPACE}\opencv\build\install\x64\mingw\lib -lopencv_core4110 -lopencv_face4110 -lopencv_videoio4110 -lopencv_imgproc4110 -lopencv_highgui4110 -lopencv_imgcodecs4110 -lopencv_objdetect4110 -lopencv_features2d4110 -lopencv_video4110 -lopencv_dnn4110 -lopencv_xfeatures2d4110 -lopencv_plot4110 -lopencv_tracking4110 -lopencv_img_hash4110 -lopencv_calib3d4110 -lopencv_bgsegm4110 -lopencv_photo4110 -lopencv_aruco4110 -lopencv_wechat_qrcode4110 -lopencv_ximgproc4110 -lopencv_xphoto4110 -lopencv_xobjdetect4110" >> $env:GITHUB_ENV
echo "CGO_LDFLAGS=-L${env:GITHUB_WORKSPACE}\opencv\build\install\x64\mingw\lib -lopencv_core4110 -lopencv_face4110 -lopencv_videoio4110 -lopencv_imgproc4110 -lopencv_highgui4110 -lopencv_imgcodecs4110 -lopencv_objdetect4110 -lopencv_features2d4110 -lopencv_video4110 -lopencv_dnn4110 -lopencv_xfeatures2d4110 -lopencv_plot4110 -lopencv_tracking4110 -lopencv_img_hash4110 -lopencv_calib3d4110 -lopencv_bgsegm4110 -lopencv_photo4110 -lopencv_aruco4110 -lopencv_wechat_qrcode4110 -lopencv_ximgproc4110 -lopencv_xphoto4110 -lopencv_xobjdetect4110 -lopencv_signal4110" >> $env:GITHUB_ENV
echo "${env:GITHUB_WORKSPACE}/opencv/build/install/x64/mingw/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install Tensorflow test model
run: |
Expand Down
2 changes: 1 addition & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ Your pull requests will be greatly appreciated!
- [ ] saliency. Saliency API
- [ ] sfm. Structure From Motion
- [ ] shape. Shape Distance and Matching
- [ ] signal. Signal Processing
- [X] signal. Signal Processing
- [ ] stereo. Stereo Correspondance Algorithms
- [ ] structured_light. Structured Light API
- [ ] superres. Super Resolution
Expand Down
2 changes: 1 addition & 1 deletion cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ package gocv
#cgo !windows pkg-config: opencv4
#cgo CXXFLAGS: --std=c++11
#cgo windows CPPFLAGS: -IC:/opencv/build/install/include
#cgo windows LDFLAGS: -LC:/opencv/build/install/x64/mingw/lib -lopencv_core4110 -lopencv_face4110 -lopencv_videoio4110 -lopencv_imgproc4110 -lopencv_highgui4110 -lopencv_imgcodecs4110 -lopencv_objdetect4110 -lopencv_features2d4110 -lopencv_video4110 -lopencv_dnn4110 -lopencv_xfeatures2d4110 -lopencv_plot4110 -lopencv_tracking4110 -lopencv_img_hash4110 -lopencv_calib3d4110 -lopencv_bgsegm4110 -lopencv_photo4110 -lopencv_aruco4110 -lopencv_wechat_qrcode4110 -lopencv_ximgproc4110
#cgo windows LDFLAGS: -LC:/opencv/build/install/x64/mingw/lib -lopencv_core4110 -lopencv_face4110 -lopencv_videoio4110 -lopencv_imgproc4110 -lopencv_highgui4110 -lopencv_imgcodecs4110 -lopencv_objdetect4110 -lopencv_features2d4110 -lopencv_video4110 -lopencv_dnn4110 -lopencv_xfeatures2d4110 -lopencv_plot4110 -lopencv_tracking4110 -lopencv_img_hash4110 -lopencv_calib3d4110 -lopencv_bgsegm4110 -lopencv_photo4110 -lopencv_aruco4110 -lopencv_wechat_qrcode4110 -lopencv_ximgproc4110 -lopencv_signal4110
*/
import "C"
2 changes: 1 addition & 1 deletion cgo_static_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ package gocv
/*
#cgo CXXFLAGS: --std=c++11
#cgo CPPFLAGS: -IC:/opencv/build/install/include
#cgo LDFLAGS: -LC:/opencv/build/install/x64/mingw/staticlib -lopencv_stereo4110 -lopencv_tracking4110 -lopencv_superres4110 -lopencv_stitching4110 -lopencv_optflow4110 -lopencv_gapi4110 -lopencv_face4110 -lopencv_dpm4110 -lopencv_dnn_objdetect4110 -lopencv_ccalib4110 -lopencv_bioinspired4110 -lopencv_bgsegm4110 -lopencv_aruco4110 -lopencv_xobjdetect4110 -lopencv_ximgproc4110 -lopencv_xfeatures2d4110 -lopencv_videostab4110 -lopencv_video4110 -lopencv_structured_light4110 -lopencv_shape4110 -lopencv_rgbd4110 -lopencv_rapid4110 -lopencv_objdetect4110 -lopencv_mcc4110 -lopencv_highgui4110 -lopencv_datasets4110 -lopencv_calib3d4110 -lopencv_videoio4110 -lopencv_text4110 -lopencv_line_descriptor4110 -lopencv_imgcodecs4110 -lopencv_img_hash4110 -lopencv_hfs4110 -lopencv_fuzzy4110 -lopencv_features2d4110 -lopencv_dnn_superres4110 -lopencv_dnn4110 -lopencv_xphoto4110 -lopencv_wechat_qrcode4110 -lopencv_surface_matching4110 -lopencv_reg4110 -lopencv_quality4110 -lopencv_plot4110 -lopencv_photo4110 -lopencv_phase_unwrapping4110 -lopencv_ml4110 -lopencv_intensity_transform4110 -lopencv_imgproc4110 -lopencv_flann4110 -lopencv_core4110 -lade -lquirc -llibprotobuf -lIlmImf -llibpng -llibopenjp2 -llibwebp -llibtiff -llibjpeg-turbo -lzlib -lkernel32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -luser32
#cgo LDFLAGS: -LC:/opencv/build/install/x64/mingw/staticlib -lopencv_signal4110 -lopencv_stereo4110 -lopencv_tracking4110 -lopencv_superres4110 -lopencv_stitching4110 -lopencv_optflow4110 -lopencv_gapi4110 -lopencv_face4110 -lopencv_dpm4110 -lopencv_dnn_objdetect4110 -lopencv_ccalib4110 -lopencv_bioinspired4110 -lopencv_bgsegm4110 -lopencv_aruco4110 -lopencv_xobjdetect4110 -lopencv_ximgproc4110 -lopencv_xfeatures2d4110 -lopencv_videostab4110 -lopencv_video4110 -lopencv_structured_light4110 -lopencv_shape4110 -lopencv_rgbd4110 -lopencv_rapid4110 -lopencv_objdetect4110 -lopencv_mcc4110 -lopencv_highgui4110 -lopencv_datasets4110 -lopencv_calib3d4110 -lopencv_videoio4110 -lopencv_text4110 -lopencv_line_descriptor4110 -lopencv_imgcodecs4110 -lopencv_img_hash4110 -lopencv_hfs4110 -lopencv_fuzzy4110 -lopencv_features2d4110 -lopencv_dnn_superres4110 -lopencv_dnn4110 -lopencv_xphoto4110 -lopencv_wechat_qrcode4110 -lopencv_surface_matching4110 -lopencv_reg4110 -lopencv_quality4110 -lopencv_plot4110 -lopencv_photo4110 -lopencv_phase_unwrapping4110 -lopencv_ml4110 -lopencv_intensity_transform4110 -lopencv_imgproc4110 -lopencv_flann4110 -lopencv_core4110 -lade -lquirc -llibprotobuf -lIlmImf -llibpng -llibopenjp2 -llibwebp -llibtiff -llibjpeg-turbo -lzlib -lkernel32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -luser32
*/
import "C"
2 changes: 1 addition & 1 deletion contrib/cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ package contrib
#cgo !windows pkg-config: opencv4
#cgo CXXFLAGS: --std=c++11
#cgo windows CPPFLAGS: -IC:/opencv/build/install/include
#cgo windows LDFLAGS: -LC:/opencv/build/install/x64/mingw/lib -lopencv_core4110 -lopencv_face4110 -lopencv_videoio4110 -lopencv_imgproc4110 -lopencv_highgui4110 -lopencv_imgcodecs4110 -lopencv_objdetect4110 -lopencv_features2d4110 -lopencv_video4110 -lopencv_dnn4110 -lopencv_xfeatures2d4110 -lopencv_plot4110 -lopencv_tracking4110 -lopencv_img_hash4110 -lopencv_calib3d4110 -lopencv_bgsegm4110 -lopencv_xphoto4110 -lopencv_aruco4110 -lopencv_wechat_qrcode4110 -lopencv_ximgproc4110 -lopencv_xobjdetect4110
#cgo windows LDFLAGS: -LC:/opencv/build/install/x64/mingw/lib -lopencv_core4110 -lopencv_face4110 -lopencv_videoio4110 -lopencv_imgproc4110 -lopencv_highgui4110 -lopencv_imgcodecs4110 -lopencv_objdetect4110 -lopencv_features2d4110 -lopencv_video4110 -lopencv_dnn4110 -lopencv_xfeatures2d4110 -lopencv_plot4110 -lopencv_tracking4110 -lopencv_img_hash4110 -lopencv_calib3d4110 -lopencv_bgsegm4110 -lopencv_xphoto4110 -lopencv_aruco4110 -lopencv_wechat_qrcode4110 -lopencv_ximgproc4110 -lopencv_xobjdetect4110 -lopencv_signal4110
*/
import "C"
2 changes: 1 addition & 1 deletion contrib/cgo_static_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ package gocv
/*
#cgo CXXFLAGS: --std=c++11
#cgo CPPFLAGS: -IC:/opencv/build/install/include
#cgo LDFLAGS: -LC:/opencv/build/install/x64/mingw/staticlib -lopencv_stereo4110 -lopencv_tracking4110 -lopencv_superres4110 -lopencv_stitching4110 -lopencv_optflow4110 -lopencv_gapi4110 -lopencv_face4110 -lopencv_dpm4110 -lopencv_dnn_objdetect4110 -lopencv_ccalib4110 -lopencv_bioinspired4110 -lopencv_bgsegm4110 -lopencv_aruco4110 -lopencv_xobjdetect4110 -lopencv_ximgproc4110 -lopencv_xfeatures2d4110 -lopencv_videostab4110 -lopencv_video4110 -lopencv_structured_light4110 -lopencv_shape4110 -lopencv_rgbd4110 -lopencv_rapid4110 -lopencv_objdetect4110 -lopencv_mcc4110 -lopencv_highgui4110 -lopencv_datasets4110 -lopencv_calib3d4110 -lopencv_videoio4110 -lopencv_text4110 -lopencv_line_descriptor4110 -lopencv_imgcodecs4110 -lopencv_img_hash4110 -lopencv_hfs4110 -lopencv_fuzzy4110 -lopencv_features2d4110 -lopencv_dnn_superres4110 -lopencv_dnn4110 -lopencv_xphoto4110 -lopencv_wechat_qrcode4110 -lopencv_surface_matching4110 -lopencv_reg4110 -lopencv_quality4110 -lopencv_plot4110 -lopencv_photo4110 -lopencv_phase_unwrapping4110 -lopencv_ml4110 -lopencv_intensity_transform4110 -lopencv_imgproc4110 -lopencv_flann4110 -lopencv_core4110 -lade -lquirc -llibprotobuf -lIlmImf -llibpng -llibopenjp2 -llibwebp -llibtiff -llibjpeg-turbo -lzlib -lkernel32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -luser32
#cgo LDFLAGS: -LC:/opencv/build/install/x64/mingw/staticlib -lopencv_signal4110 -lopencv_stereo4110 -lopencv_tracking4110 -lopencv_superres4110 -lopencv_stitching4110 -lopencv_optflow4110 -lopencv_gapi4110 -lopencv_face4110 -lopencv_dpm4110 -lopencv_dnn_objdetect4110 -lopencv_ccalib4110 -lopencv_bioinspired4110 -lopencv_bgsegm4110 -lopencv_aruco4110 -lopencv_xobjdetect4110 -lopencv_ximgproc4110 -lopencv_xfeatures2d4110 -lopencv_videostab4110 -lopencv_video4110 -lopencv_structured_light4110 -lopencv_shape4110 -lopencv_rgbd4110 -lopencv_rapid4110 -lopencv_objdetect4110 -lopencv_mcc4110 -lopencv_highgui4110 -lopencv_datasets4110 -lopencv_calib3d4110 -lopencv_videoio4110 -lopencv_text4110 -lopencv_line_descriptor4110 -lopencv_imgcodecs4110 -lopencv_img_hash4110 -lopencv_hfs4110 -lopencv_fuzzy4110 -lopencv_features2d4110 -lopencv_dnn_superres4110 -lopencv_dnn4110 -lopencv_xphoto4110 -lopencv_wechat_qrcode4110 -lopencv_surface_matching4110 -lopencv_reg4110 -lopencv_quality4110 -lopencv_plot4110 -lopencv_photo4110 -lopencv_phase_unwrapping4110 -lopencv_ml4110 -lopencv_intensity_transform4110 -lopencv_imgproc4110 -lopencv_flann4110 -lopencv_core4110 -lade -lquirc -llibprotobuf -lIlmImf -llibpng -llibopenjp2 -llibwebp -llibtiff -llibjpeg-turbo -lzlib -lkernel32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -luser32
*/
import "C"
6 changes: 6 additions & 0 deletions contrib/signal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "signal.h"

void Signal_ResampleSignal(Mat inputSignal, Mat outSignal, int inFreq, int outFreq) {
cv::signal::resampleSignal(*inputSignal, *outSignal, inFreq, outFreq);
}

32 changes: 32 additions & 0 deletions contrib/signal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package contrib

/*
#include <stdlib.h>
#include "signal.h"
*/
import "C"
import "gocv.io/x/gocv"

// ResampleSignal Signal resampling.
//
// Parameters:
//
// inputSignal: gocv.Mat with input signal.
//
// inFreq: Input signal frequency.
//
// outFreq: Output signal frequency. Signal resampling implemented a cubic interpolation function
// and a filtering function based on Kaiser window and Bessel function, used to construct a FIR filter.
// Result is similar to scipy.signal.resample.
//
// Returns a gocv.Mat with output signal.
//
// For further details, please see:
// https://docs.opencv.org/4.11.0/d2/d1f/group__signal.html#gad32480ac5c9832126cf0c6bde026686d
func ResampleSignal(inputSignal gocv.Mat, inFreq int, outFreq int) gocv.Mat {
out := gocv.NewMat()

C.Signal_ResampleSignal(C.Mat(inputSignal.Ptr()), C.Mat(out.Ptr()), C.int(inFreq), C.int(outFreq))

return out
}
18 changes: 18 additions & 0 deletions contrib/signal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef _OPENCV3_CONTRIB_SIGNAL_H_
#define _OPENCV3_CONTRIB_SIGNAL_H_

#ifdef __cplusplus
#include <opencv2/opencv.hpp>
#include <opencv2/signal.hpp>
extern "C" {
#endif

#include "../core.h"

void Signal_ResampleSignal(Mat inputSignal, Mat outSignal, int inFreq, int outFreq);

#ifdef __cplusplus
}
#endif

#endif //_OPENCV3_CONTRIB_SIGNAL_H_
23 changes: 23 additions & 0 deletions contrib/signal_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package contrib

import (
"testing"

"gocv.io/x/gocv"
)

func TestResampleSignal(t *testing.T) {

img := gocv.IMRead("../images/face.jpg", gocv.IMReadAnyColor)
if img.Empty() {
t.Error("xobjdetect: cannot read image")
}

resampledMat := ResampleSignal(img, 1000, 1000)
defer resampledMat.Close()

if resampledMat.Empty() {
t.Error("contrib.signal.ResampleSignal: empty output")
}

}
2 changes: 1 addition & 1 deletion cuda/cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ package cuda
#cgo !windows pkg-config: opencv4
#cgo CXXFLAGS: --std=c++11
#cgo windows CPPFLAGS: -IC:/opencv/build/install/include
#cgo windows LDFLAGS: -LC:/opencv/build/install/x64/mingw/lib -lopencv_core4110 -lopencv_face4110 -lopencv_videoio4110 -lopencv_imgproc4110 -lopencv_highgui4110 -lopencv_imgcodecs4110 -lopencv_objdetect4110 -lopencv_features2d4110 -lopencv_video4110 -lopencv_dnn4110 -lopencv_xfeatures2d4110 -lopencv_plot4110 -lopencv_tracking4110 -lopencv_img_hash4110 -lopencv_calib3d4110 -lopencv_bgsegm4110 -lopencv_aruco4110 -lopencv_wechat_qrcode4110 -lopencv_ximgproc4110 -lopencv_xobjdetect4110
#cgo windows LDFLAGS: -LC:/opencv/build/install/x64/mingw/lib -lopencv_core4110 -lopencv_face4110 -lopencv_videoio4110 -lopencv_imgproc4110 -lopencv_highgui4110 -lopencv_imgcodecs4110 -lopencv_objdetect4110 -lopencv_features2d4110 -lopencv_video4110 -lopencv_dnn4110 -lopencv_xfeatures2d4110 -lopencv_plot4110 -lopencv_tracking4110 -lopencv_img_hash4110 -lopencv_calib3d4110 -lopencv_bgsegm4110 -lopencv_aruco4110 -lopencv_wechat_qrcode4110 -lopencv_ximgproc4110 -lopencv_xobjdetect4110 -lopencv_signal4110
*/
import "C"
2 changes: 1 addition & 1 deletion cuda/cgo_static_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ package gocv
/*
#cgo CXXFLAGS: --std=c++11
#cgo CPPFLAGS: -IC:/opencv/build/install/include
#cgo LDFLAGS: -LC:/opencv/build/install/x64/mingw/staticlib -lopencv_stereo4110 -lopencv_tracking4110 -lopencv_superres4110 -lopencv_stitching4110 -lopencv_optflow4110 -lopencv_gapi4110 -lopencv_face4110 -lopencv_dpm4110 -lopencv_dnn_objdetect4110 -lopencv_ccalib4110 -lopencv_bioinspired4110 -lopencv_bgsegm4110 -lopencv_aruco4110 -lopencv_xobjdetect4110 -lopencv_ximgproc4110 -lopencv_xfeatures2d4110 -lopencv_videostab4110 -lopencv_video4110 -lopencv_structured_light4110 -lopencv_shape4110 -lopencv_rgbd4110 -lopencv_rapid4110 -lopencv_objdetect4110 -lopencv_mcc4110 -lopencv_highgui4110 -lopencv_datasets4110 -lopencv_calib3d4110 -lopencv_videoio4110 -lopencv_text4110 -lopencv_line_descriptor4110 -lopencv_imgcodecs4110 -lopencv_img_hash4110 -lopencv_hfs4110 -lopencv_fuzzy4110 -lopencv_features2d4110 -lopencv_dnn_superres4110 -lopencv_dnn4110 -lopencv_xphoto4110 -lopencv_wechat_qrcode4110 -lopencv_surface_matching4110 -lopencv_reg4110 -lopencv_quality4110 -lopencv_plot4110 -lopencv_photo4110 -lopencv_phase_unwrapping4110 -lopencv_ml4110 -lopencv_intensity_transform4110 -lopencv_imgproc4110 -lopencv_flann4110 -lopencv_core4110 -lade -lquirc -llibprotobuf -lIlmImf -llibpng -llibopenjp2 -llibwebp -llibtiff -llibjpeg-turbo -lzlib -lkernel32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -luser32
#cgo LDFLAGS: -LC:/opencv/build/install/x64/mingw/staticlib -lopencv_signal4110 -lopencv_stereo4110 -lopencv_tracking4110 -lopencv_superres4110 -lopencv_stitching4110 -lopencv_optflow4110 -lopencv_gapi4110 -lopencv_face4110 -lopencv_dpm4110 -lopencv_dnn_objdetect4110 -lopencv_ccalib4110 -lopencv_bioinspired4110 -lopencv_bgsegm4110 -lopencv_aruco4110 -lopencv_xobjdetect4110 -lopencv_ximgproc4110 -lopencv_xfeatures2d4110 -lopencv_videostab4110 -lopencv_video4110 -lopencv_structured_light4110 -lopencv_shape4110 -lopencv_rgbd4110 -lopencv_rapid4110 -lopencv_objdetect4110 -lopencv_mcc4110 -lopencv_highgui4110 -lopencv_datasets4110 -lopencv_calib3d4110 -lopencv_videoio4110 -lopencv_text4110 -lopencv_line_descriptor4110 -lopencv_imgcodecs4110 -lopencv_img_hash4110 -lopencv_hfs4110 -lopencv_fuzzy4110 -lopencv_features2d4110 -lopencv_dnn_superres4110 -lopencv_dnn4110 -lopencv_xphoto4110 -lopencv_wechat_qrcode4110 -lopencv_surface_matching4110 -lopencv_reg4110 -lopencv_quality4110 -lopencv_plot4110 -lopencv_photo4110 -lopencv_phase_unwrapping4110 -lopencv_ml4110 -lopencv_intensity_transform4110 -lopencv_imgproc4110 -lopencv_flann4110 -lopencv_core4110 -lade -lquirc -llibprotobuf -lIlmImf -llibpng -llibopenjp2 -llibwebp -llibtiff -llibjpeg-turbo -lzlib -lkernel32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -luser32
*/
import "C"
Loading