diff --git a/cuda/imgproc.go b/cuda/imgproc.go index f04b798c..8ab25640 100644 --- a/cuda/imgproc.go +++ b/cuda/imgproc.go @@ -295,7 +295,25 @@ func (tm *TemplateMatching) MatchWithStream(img GpuMat, tmpl GpuMat, dst *GpuMat // // For further details, please see: // https://docs.opencv.org/4.x/db/d8c/group__cudaimgproc__color.html#ga08a698700458d9311390997b57fbf8dc -func AlphaComp(img1 GpuMat, img2 GpuMat, dst *GpuMat, alphaOp AlphaCompTypes, s Stream) { +func AlphaComp(img1 GpuMat, img2 GpuMat, dst *GpuMat, alphaOp AlphaCompTypes) { + C.AlphaComp(img1.p, img2.p, dst.p, C.int(alphaOp), nil) +} + +// AlphaCompWithStream Composites two images using alpha opacity values contained in each image. +// +// img1: First image. Supports CV_8UC4 , CV_16UC4 , CV_32SC4 and CV_32FC4 types. +// +// img2: Second image. Must have the same size and the same type as img1. +// +// dst: Destination image. +// +// alpha_op: Flag specifying the alpha-blending operation +// +// stream: Stream for the asynchronous version. +// +// For further details, please see: +// https://docs.opencv.org/4.x/db/d8c/group__cudaimgproc__color.html#ga08a698700458d9311390997b57fbf8dc +func AlphaCompWithStream(img1 GpuMat, img2 GpuMat, dst *GpuMat, alphaOp AlphaCompTypes, s Stream) { C.AlphaComp(img1.p, img2.p, dst.p, C.int(alphaOp), s.p) } @@ -307,11 +325,25 @@ func AlphaComp(img1 GpuMat, img2 GpuMat, dst *GpuMat, alphaOp AlphaCompTypes, s // // forward: true for forward gamma correction or false for inverse gamma correction. // +// For further details, please see: +// https://docs.opencv.org/4.x/db/d8c/group__cudaimgproc__color.html#gaf4195a8409c3b8fbfa37295c2b2c4729 +func GammaCorrection(src GpuMat, dst *GpuMat, forward bool) { + C.GammaCorrection(src.p, dst.p, C.bool(forward), nil) +} + +// GammaCorrectionWithStream Routines for correcting image color gamma. +// +// src: Source image (3- or 4-channel 8 bit). +// +// dst: Destination image. +// +// forward: true for forward gamma correction or false for inverse gamma correction. +// // stream: Stream for the asynchronous version. // // For further details, please see: // https://docs.opencv.org/4.x/db/d8c/group__cudaimgproc__color.html#gaf4195a8409c3b8fbfa37295c2b2c4729 -func GammaCorrection(src GpuMat, dst *GpuMat, forward bool, s Stream) { +func GammaCorrectionWithStream(src GpuMat, dst *GpuMat, forward bool, s Stream) { C.GammaCorrection(src.p, dst.p, C.bool(forward), s.p) } @@ -323,13 +355,29 @@ func GammaCorrection(src GpuMat, dst *GpuMat, forward bool, s Stream) { // contains the number of the channel that is stored in the n-th channel of the output image. // E.g. Given an RGBA image, aDstOrder = [3,2,1,0] converts this to ABGR channel order. // +// supports arbitrary permutations of the original channels, including replication. +// +// For further details, please see: +// https://docs.opencv.org/4.x/db/d8c/group__cudaimgproc__color.html#ga75a29cc4a97cde0d43ea066b01de927e +func SwapChannels(image *GpuMat, dstOrder []int) { + C.SwapChannels(image.p, (*C.int)(unsafe.Pointer(&dstOrder[0])), nil) +} + +// SwapChannelsWithStream Exchanges the color channels of an image in-place. +// +// image: Source image. Supports only CV_8UC4 type. +// +// dstOrder: Integer array describing how channel values are permutated. The n-th entry of the array +// contains the number of the channel that is stored in the n-th channel of the output image. +// E.g. Given an RGBA image, aDstOrder = [3,2,1,0] converts this to ABGR channel order. +// // stream: Stream for the asynchronous version. // // supports arbitrary permutations of the original channels, including replication. // // For further details, please see: // https://docs.opencv.org/4.x/db/d8c/group__cudaimgproc__color.html#ga75a29cc4a97cde0d43ea066b01de927e -func SwapChannels(image *GpuMat, dstOrder []int, s Stream) { +func SwapChannelsWithStream(image *GpuMat, dstOrder []int, s Stream) { C.SwapChannels(image.p, (*C.int)(unsafe.Pointer(&dstOrder[0])), s.p) } @@ -339,11 +387,23 @@ func SwapChannels(image *GpuMat, dstOrder []int, s Stream) { // // hist: Destination histogram with one row, 256 columns, and the CV_32SC1 type. // +// For further details, please see: +// https://docs.opencv.org/4.x/d8/d0e/group__cudaimgproc__hist.html#gaaf3944106890947020bb4522a7619c26 +func CalcHist(src GpuMat, dst *GpuMat) { + C.Cuda_CalcHist(src.p, dst.p, nil) +} + +// CalcHistWithStream Calculates histogram for one channel 8-bit image. +// +// src: Source image with CV_8UC1 type. +// +// hist: Destination histogram with one row, 256 columns, and the CV_32SC1 type. +// // stream: Stream for the asynchronous version. // // For further details, please see: // https://docs.opencv.org/4.x/d8/d0e/group__cudaimgproc__hist.html#gaaf3944106890947020bb4522a7619c26 -func CalcHist(src GpuMat, dst *GpuMat, s Stream) { +func CalcHistWithStream(src GpuMat, dst *GpuMat, s Stream) { C.Cuda_CalcHist(src.p, dst.p, s.p) } @@ -369,11 +429,23 @@ func CalcHistWithParams(src GpuMat, mask GpuMat, dst *GpuMat, s Stream) { // // dst: Destination image. // +// For further details, please see: +// https://docs.opencv.org/4.x/d8/d0e/group__cudaimgproc__hist.html#ga2384be74bd2feba7e6c46815513f0060 +func EqualizeHist(src GpuMat, dst *GpuMat) { + C.Cuda_EqualizeHist(src.p, dst.p, nil) +} + +// EqualizeHistWithStream Equalizes the histogram of a grayscale image. +// +// src: Source image with CV_8UC1 type. +// +// dst: Destination image. +// // stream: Stream for the asynchronous version. // // For further details, please see: // https://docs.opencv.org/4.x/d8/d0e/group__cudaimgproc__hist.html#ga2384be74bd2feba7e6c46815513f0060 -func EqualizeHist(src GpuMat, dst *GpuMat, s Stream) { +func EqualizeHistWithStream(src GpuMat, dst *GpuMat, s Stream) { C.Cuda_EqualizeHist(src.p, dst.p, s.p) } @@ -387,11 +459,27 @@ func EqualizeHist(src GpuMat, dst *GpuMat, s Stream) { // // upperLevel: Upper boundary value of the greatest level. // +// For further details, please see: +// https://docs.opencv.org/4.x/d8/d0e/group__cudaimgproc__hist.html#ga2f2cbd21dc6d7367a7c4ee1a826f389dFor further details, please see: +func EvenLevels(levels *GpuMat, nLevels int, lowerLevel int, upperLevel int) { + C.Cuda_EvenLevels(levels.p, C.int(nLevels), C.int(lowerLevel), C.int(upperLevel), nil) +} + +// EvenLevelsWithStream Computes levels with even distribution. +// +// levels: Destination array. levels has 1 row, nLevels columns, and the CV_32SC1 type. +// +// nLevels: Number of computed levels. nLevels must be at least 2. +// +// lowerLevel: Lower boundary value of the lowest level. +// +// upperLevel: Upper boundary value of the greatest level. +// // stream: Stream for the asynchronous version. // // For further details, please see: // https://docs.opencv.org/4.x/d8/d0e/group__cudaimgproc__hist.html#ga2f2cbd21dc6d7367a7c4ee1a826f389dFor further details, please see: -func EvenLevels(levels *GpuMat, nLevels int, lowerLevel int, upperLevel int, s Stream) { +func EvenLevelsWithStream(levels *GpuMat, nLevels int, lowerLevel int, upperLevel int, s Stream) { C.Cuda_EvenLevels(levels.p, C.int(nLevels), C.int(lowerLevel), C.int(upperLevel), s.p) } @@ -408,11 +496,30 @@ func EvenLevels(levels *GpuMat, nLevels int, lowerLevel int, upperLevel int, s S // // upperLevel: Upper boundary of highest-level bin. // +// For further details, please see: +// https://docs.opencv.org/4.x/d8/d0e/group__cudaimgproc__hist.html#gacd3b14279fb77a57a510cb8c89a1856f +func HistEven(src GpuMat, hist *GpuMat, histSize int, lowerLevel int, upperLevel int) { + C.Cuda_HistEven(src.p, hist.p, C.int(histSize), C.int(lowerLevel), C.int(upperLevel), nil) +} + +// HistEvenWithStream Calculates a histogram with evenly distributed bins. +// +// src: Source image. CV_8U, CV_16U, or CV_16S depth and 1 or 4 channels are supported. +// For a four-channel image, all channels are processed separately. +// +// hist: Destination histogram with one row, histSize columns, and the CV_32S type. +// +// histSize: Size of the histogram. +// +// lowerLevel: Lower boundary of lowest-level bin. +// +// upperLevel: Upper boundary of highest-level bin. +// // stream: Stream for the asynchronous version. // // For further details, please see: // https://docs.opencv.org/4.x/d8/d0e/group__cudaimgproc__hist.html#gacd3b14279fb77a57a510cb8c89a1856f -func HistEven(src GpuMat, hist *GpuMat, histSize int, lowerLevel int, upperLevel int, s Stream) { +func HistEvenWithStream(src GpuMat, hist *GpuMat, histSize int, lowerLevel int, upperLevel int, s Stream) { C.Cuda_HistEven(src.p, hist.p, C.int(histSize), C.int(lowerLevel), C.int(upperLevel), s.p) } @@ -425,11 +532,26 @@ func HistEven(src GpuMat, hist *GpuMat, histSize int, lowerLevel int, upperLevel // // levels: Number of levels in the histogram. // +// For further details, please see: +// https://docs.opencv.org/4.x/d8/d0e/group__cudaimgproc__hist.html#ga87819085c1059186d9cdeacd92cea783 +func HistRange(src GpuMat, hist *GpuMat, levels GpuMat) { + C.Cuda_HistRange(src.p, hist.p, levels.p, nil) +} + +// HistRangeWithStream Calculates a histogram with bins determined by the levels array. +// +// src: Source image. CV_8U , CV_16U , or CV_16S depth and 1 or 4 channels are supported. +// For a four-channel image, all channels are processed separately. +// +// hist: Destination histogram with one row, (levels.cols-1) columns, and the CV_32SC1 type. +// +// levels: Number of levels in the histogram. +// // stream: Stream for the asynchronous version. // // For further details, please see: // https://docs.opencv.org/4.x/d8/d0e/group__cudaimgproc__hist.html#ga87819085c1059186d9cdeacd92cea783 -func HistRange(src GpuMat, hist *GpuMat, levels GpuMat, s Stream) { +func HistRangeWithStream(src GpuMat, hist *GpuMat, levels GpuMat, s Stream) { C.Cuda_HistRange(src.p, hist.p, levels.p, s.p) } @@ -448,11 +570,32 @@ func HistRange(src GpuMat, hist *GpuMat, levels GpuMat, s Stream) { // borderMode: Border type. See borderInterpolate for details. // BorderReflect101 , BorderReplicate , BorderConstant , BorderReflect and BorderWrap are supported for now. // +// For further details, please see: +// https://docs.opencv.org/4.x/d0/d05/group__cudaimgproc.html#ga6abeaecdd4e7edc0bd1393a04f4f20bd +func BilateralFilter(src GpuMat, dst *GpuMat, kernelSize int, sigmaColor float32, sigmaSpatial float32, borderMode BorderType) { + C.Cuda_BilateralFilter(src.p, dst.p, C.int(kernelSize), C.float(sigmaColor), C.float(sigmaSpatial), C.int(borderMode), nil) +} + +// BilateralFilterWithStream Performs bilateral filtering of passed image. +// +// src: Source image. Supports only (channels != 2 && depth() != CV_8S && depth() != CV_32S && depth() != CV_64F). +// +// dst: Destination imagwe. +// +// kernelSize: Kernel window size. +// +// sigmaColor: Filter sigma in the color space. +// +// sigmaSpatial: Filter sigma in the coordinate space. +// +// borderMode: Border type. See borderInterpolate for details. +// BorderReflect101 , BorderReplicate , BorderConstant , BorderReflect and BorderWrap are supported for now. +// // stream: Stream for the asynchronous version. // // For further details, please see: // https://docs.opencv.org/4.x/d0/d05/group__cudaimgproc.html#ga6abeaecdd4e7edc0bd1393a04f4f20bd -func BilateralFilter(src GpuMat, dst *GpuMat, kernelSize int, sigmaColor float32, sigmaSpatial float32, borderMode BorderType, s Stream) { +func BilateralFilterWithStream(src GpuMat, dst *GpuMat, kernelSize int, sigmaColor float32, sigmaSpatial float32, borderMode BorderType, s Stream) { C.Cuda_BilateralFilter(src.p, dst.p, C.int(kernelSize), C.float(sigmaColor), C.float(sigmaSpatial), C.int(borderMode), s.p) } @@ -468,11 +611,29 @@ func BilateralFilter(src GpuMat, dst *GpuMat, kernelSize int, sigmaColor float32 // // result: Destination image. // +// For further details, please see: +// https://docs.opencv.org/4.x/d0/d05/group__cudaimgproc.html#ga4793607e5729bcc15b27ea33d9fe335e +func BlendLinear(img1 GpuMat, img2 GpuMat, weights1 GpuMat, weights2 GpuMat, result *GpuMat) { + C.Cuda_BlendLinear(img1.p, img2.p, weights1.p, weights2.p, result.p, nil) +} + +// BlendLinearWithStream Performs linear blending of two images. +// +// img1: First image. Supports only CV_8U and CV_32F depth. +// +// img2: Second image. Must have the same size and the same type as img1 . +// +// weights1: Weights for first image. Must have tha same size as img1 . Supports only CV_32F type. +// +// weights2: Weights for second image. Must have tha same size as img2 . Supports only CV_32F type. +// +// result: Destination image. +// // stream: Stream for the asynchronous version. // // For further details, please see: // https://docs.opencv.org/4.x/d0/d05/group__cudaimgproc.html#ga4793607e5729bcc15b27ea33d9fe335e -func BlendLinear(img1 GpuMat, img2 GpuMat, weights1 GpuMat, weights2 GpuMat, result *GpuMat, s Stream) { +func BlendLinearWithStream(img1 GpuMat, img2 GpuMat, weights1 GpuMat, weights2 GpuMat, result *GpuMat, s Stream) { C.Cuda_BlendLinear(img1.p, img2.p, weights1.p, weights2.p, result.p, s.p) } @@ -490,11 +651,31 @@ func BlendLinear(img1 GpuMat, img2 GpuMat, weights1 GpuMat, weights2 GpuMat, res // // criteria: Termination criteria. See TermCriteria. // +// For further details, please see: +// https://docs.opencv.org/4.x/d0/d05/group__cudaimgproc.html#gae13b3035bc6df0e512d876dbb8c00555 +func MeanShiftFiltering(src GpuMat, dst *GpuMat, sp int, sr int, criteria gocv.TermCriteria) { + C.Cuda_MeanShiftFiltering(src.p, dst.p, C.int(sp), C.int(sr), C.TermCriteria(criteria.Ptr()), nil) +} + +// MeanShiftFilteringWithStream Performs mean-shift filtering for each point of the source image. +// It maps each point of the source image into another point. +// As a result, you have a new color and new position of each point. +// +// src: Source image. Only CV_8UC4 images are supported for now. +// +// dst: Destination image containing the color of mapped points. It has the same size and type as src . +// +// sp: Spatial window radius. +// +// sr: Color window radius. +// +// criteria: Termination criteria. See TermCriteria. +// // stream: Stream for the asynchronous version. // // For further details, please see: // https://docs.opencv.org/4.x/d0/d05/group__cudaimgproc.html#gae13b3035bc6df0e512d876dbb8c00555 -func MeanShiftFiltering(src GpuMat, dst *GpuMat, sp int, sr int, criteria gocv.TermCriteria, s Stream) { +func MeanShiftFilteringWithStream(src GpuMat, dst *GpuMat, sp int, sr int, criteria gocv.TermCriteria, s Stream) { C.Cuda_MeanShiftFiltering(src.p, dst.p, C.int(sp), C.int(sr), C.TermCriteria(criteria.Ptr()), s.p) } @@ -513,11 +694,32 @@ func MeanShiftFiltering(src GpuMat, dst *GpuMat, sp int, sr int, criteria gocv.T // // criteria: Termination criteria. See TermCriteria. // +// For further details, please see: +// https://docs.opencv.org/4.x/d0/d05/group__cudaimgproc.html#ga6039dc8ecbe2f912bc83fcc9b3bcca39 +func MeanShiftProc(src GpuMat, dstr *GpuMat, dstsp *GpuMat, sp int, sr int, criteria gocv.TermCriteria) { + C.Cuda_MeanShiftProc(src.p, dstr.p, dstsp.p, C.int(sp), C.int(sr), C.TermCriteria(criteria.Ptr()), nil) +} + +// MeanShiftProcWithStream Performs a mean-shift procedure and stores information +// about processed points (their colors and positions) in two images. +// +// src: Source image. Only CV_8UC4 images are supported for now. +// +// dstr: Destination image containing the color of mapped points. The size and type is the same as src . +// +// dstsp: Destination image containing the position of mapped points. The size is the same as src size. The type is CV_16SC2 . +// +// sp: Spatial window radius. +// +// sr: Color window radius. +// +// criteria: Termination criteria. See TermCriteria. +// // stream: Stream for the asynchronous version. // // For further details, please see: // https://docs.opencv.org/4.x/d0/d05/group__cudaimgproc.html#ga6039dc8ecbe2f912bc83fcc9b3bcca39 -func MeanShiftProc(src GpuMat, dstr *GpuMat, dstsp *GpuMat, sp int, sr int, criteria gocv.TermCriteria, s Stream) { +func MeanShiftProcWithStream(src GpuMat, dstr *GpuMat, dstsp *GpuMat, sp int, sr int, criteria gocv.TermCriteria, s Stream) { C.Cuda_MeanShiftProc(src.p, dstr.p, dstsp.p, C.int(sp), C.int(sr), C.TermCriteria(criteria.Ptr()), s.p) } @@ -535,10 +737,30 @@ func MeanShiftProc(src GpuMat, dstr *GpuMat, dstsp *GpuMat, sp int, sr int, crit // // criteria: Termination criteria. See TermCriteria. // +// For further details, please see: +// https://docs.opencv.org/4.x/d0/d05/group__cudaimgproc.html#ga70ed80533a448829dc48cf22b1845c16 +func MeanShiftSegmentation(src GpuMat, dst *GpuMat, sp int, sr int, minSize int, criteria gocv.TermCriteria) { + C.Cuda_MeanShiftSegmentation(src.p, dst.p, C.int(sp), C.int(sr), C.int(minSize), C.TermCriteria(criteria.Ptr()), nil) +} + +// MeanShiftSegmentationWithStream Performs a mean-shift segmentation of the source image and eliminates small segments. +// +// src: Source image. Only CV_8UC4 images are supported for now. +// +// dst: Segmented image with the same size and type as src. +// +// sp: Spatial window radius. +// +// sr: Color window radius. +// +// minsize: Minimum segment size. Smaller segments are merged. +// +// criteria: Termination criteria. See TermCriteria. +// // stream: Stream for the asynchronous version. // // For further details, please see: // https://docs.opencv.org/4.x/d0/d05/group__cudaimgproc.html#ga70ed80533a448829dc48cf22b1845c16 -func MeanShiftSegmentation(src GpuMat, dst *GpuMat, sp int, sr int, minSize int, criteria gocv.TermCriteria, s Stream) { +func MeanShiftSegmentationWithStream(src GpuMat, dst *GpuMat, sp int, sr int, minSize int, criteria gocv.TermCriteria, s Stream) { C.Cuda_MeanShiftSegmentation(src.p, dst.p, C.int(sp), C.int(sr), C.int(minSize), C.TermCriteria(criteria.Ptr()), s.p) } diff --git a/cuda/imgproc_test.go b/cuda/imgproc_test.go index dbd418df..2a4970bc 100644 --- a/cuda/imgproc_test.go +++ b/cuda/imgproc_test.go @@ -477,10 +477,35 @@ func TestAlphaComp(t *testing.T) { dst := NewGpuMat() defer dst.Close() - AlphaComp(m1, m2, &dst, AlphaCompTypeOver, Stream{}) + AlphaComp(m1, m2, &dst, AlphaCompTypeOver) } +func TestAlphaCompWithStream(t *testing.T) { + img := gocv.IMRead("../images/box.png", gocv.IMReadUnchanged) + defer img.Close() + + converted := gocv.NewMat() + defer converted.Close() + + gocv.CvtColor(img, &converted, gocv.ColorRGBAToBGRA) + + m1 := NewGpuMatFromMat(converted) + defer m1.Close() + + m2 := NewGpuMatFromMat(converted) + defer m2.Close() + + dst := NewGpuMat() + defer dst.Close() + + s := NewStream() + defer s.Close() + + AlphaCompWithStream(m1, m2, &dst, AlphaCompTypeOver, s) + s.WaitForCompletion() +} + func TestGammaCorrection(t *testing.T) { img := gocv.IMRead("../images/box.png", gocv.IMReadUnchanged) defer img.Close() @@ -496,9 +521,33 @@ func TestGammaCorrection(t *testing.T) { dst := NewGpuMat() defer dst.Close() - GammaCorrection(m1, &dst, true, Stream{}) + GammaCorrection(m1, &dst, true) + +} + +func TestGammaCorrectionWithStream(t *testing.T) { + img := gocv.IMRead("../images/box.png", gocv.IMReadUnchanged) + defer img.Close() + + converted := gocv.NewMat() + defer converted.Close() + + gocv.CvtColor(img, &converted, gocv.ColorRGBAToBGRA) + + m1 := NewGpuMatFromMat(converted) + defer m1.Close() + + dst := NewGpuMat() + defer dst.Close() + + s := NewStream() + defer s.Close() + + GammaCorrectionWithStream(m1, &dst, true, s) + s.WaitForCompletion() } + func TestSwapChannels(t *testing.T) { img := gocv.IMRead("../images/box.png", gocv.IMReadUnchanged) defer img.Close() @@ -511,7 +560,27 @@ func TestSwapChannels(t *testing.T) { m1 := NewGpuMatFromMat(converted) defer m1.Close() - SwapChannels(&m1, []int{3, 2, 1, 0}, Stream{}) + SwapChannels(&m1, []int{3, 2, 1, 0}) + +} + +func TestSwapChannelsWithStream(t *testing.T) { + img := gocv.IMRead("../images/box.png", gocv.IMReadUnchanged) + defer img.Close() + + converted := gocv.NewMat() + defer converted.Close() + + gocv.CvtColor(img, &converted, gocv.ColorRGBAToBGRA) + + m1 := NewGpuMatFromMat(converted) + defer m1.Close() + + s := NewStream() + defer s.Close() + + SwapChannelsWithStream(&m1, []int{3, 2, 1, 0}, s) + s.WaitForCompletion() } @@ -522,10 +591,30 @@ func TestCalcHist(t *testing.T) { m2 := NewGpuMatWithSize(1, 256, gocv.MatTypeCV32SC1) defer m2.Close() - CalcHist(m1, &m2, Stream{}) + CalcHist(m1, &m2) CalcHistWithParams(m1, m1, &m2, Stream{}) } +func TestCalcHistWithStream(t *testing.T) { + m1 := NewGpuMatWithSize(256, 256, gocv.MatTypeCV8UC1) + defer m1.Close() + + m2 := NewGpuMatWithSize(1, 256, gocv.MatTypeCV32SC1) + defer m2.Close() + + s := NewStream() + defer s.Close() + + s1 := NewStream() + defer s1.Close() + + CalcHistWithStream(m1, &m2, s) + CalcHistWithParams(m1, m1, &m2, s1) + + s.WaitForCompletion() + s1.WaitForCompletion() +} + func TestEqualizeHist(t *testing.T) { m1 := NewGpuMatWithSize(256, 256, gocv.MatTypeCV8UC1) defer m1.Close() @@ -533,14 +622,40 @@ func TestEqualizeHist(t *testing.T) { m2 := NewGpuMatWithSize(1, 256, gocv.MatTypeCV32SC1) defer m2.Close() - EqualizeHist(m1, &m2, Stream{}) + EqualizeHist(m1, &m2) +} + +func TestEqualizeHistWithStream(t *testing.T) { + m1 := NewGpuMatWithSize(256, 256, gocv.MatTypeCV8UC1) + defer m1.Close() + + m2 := NewGpuMatWithSize(1, 256, gocv.MatTypeCV32SC1) + defer m2.Close() + + s := NewStream() + defer s.Close() + + EqualizeHistWithStream(m1, &m2, s) + s.WaitForCompletion() + } func TestEvenLevels(t *testing.T) { m1 := NewGpuMatWithSize(256, 256, gocv.MatTypeCV8UC1) defer m1.Close() - EvenLevels(&m1, 2, 1, 2, Stream{}) + EvenLevels(&m1, 2, 1, 2) +} + +func TestEvenLevelsWithStream(t *testing.T) { + m1 := NewGpuMatWithSize(256, 256, gocv.MatTypeCV8UC1) + defer m1.Close() + + s := NewStream() + defer s.Close() + + EvenLevelsWithStream(&m1, 2, 1, 2, s) + s.WaitForCompletion() } func TestHistEven(t *testing.T) { @@ -550,7 +665,21 @@ func TestHistEven(t *testing.T) { m2 := NewGpuMatWithSize(1, 256, gocv.MatTypeCV32SC1) defer m2.Close() - HistEven(m1, &m2, 256, 1, 2, Stream{}) + HistEven(m1, &m2, 256, 1, 2) +} + +func TestHistEvenWithStream(t *testing.T) { + m1 := NewGpuMatWithSize(256, 256, gocv.MatTypeCV8UC1) + defer m1.Close() + + m2 := NewGpuMatWithSize(1, 256, gocv.MatTypeCV32SC1) + defer m2.Close() + + s := NewStream() + defer s.Close() + + HistEvenWithStream(m1, &m2, 256, 1, 2, s) + s.WaitForCompletion() } func TestHistRange(t *testing.T) { @@ -563,7 +692,24 @@ func TestHistRange(t *testing.T) { hist := NewGpuMatWithSize(1, 256, gocv.MatTypeCV32SC1) defer hist.Close() - HistRange(src, &hist, levels, Stream{}) + HistRange(src, &hist, levels) +} + +func TestHistRangeWithStream(t *testing.T) { + src := NewGpuMatWithSize(256, 256, gocv.MatTypeCV8UC1) + defer src.Close() + + levels := NewGpuMatWithSize(1, 256, gocv.MatTypeCV32SC1) + defer levels.Close() + + hist := NewGpuMatWithSize(1, 256, gocv.MatTypeCV32SC1) + defer hist.Close() + + s := NewStream() + defer s.Close() + + HistRangeWithStream(src, &hist, levels, s) + s.WaitForCompletion() } func TestBilateralFilter(t *testing.T) { @@ -573,7 +719,21 @@ func TestBilateralFilter(t *testing.T) { dst := NewGpuMatWithSize(256, 256, gocv.MatTypeCV32SC1) defer dst.Close() - BilateralFilter(src, &dst, 1, 2.2, 3.3, BorderDefault, Stream{}) + BilateralFilter(src, &dst, 1, 2.2, 3.3, BorderDefault) +} + +func TestBilateralFilterWithStream(t *testing.T) { + src := NewGpuMatWithSize(256, 256, gocv.MatTypeCV8UC1) + defer src.Close() + + dst := NewGpuMatWithSize(256, 256, gocv.MatTypeCV32SC1) + defer dst.Close() + + s := NewStream() + defer s.Close() + + BilateralFilterWithStream(src, &dst, 1, 2.2, 3.3, BorderDefault, s) + s.WaitForCompletion() } func TestBlendLinear(t *testing.T) { @@ -592,10 +752,33 @@ func TestBlendLinear(t *testing.T) { weights2 := NewGpuMatWithSize(256, 256, gocv.MatTypeCV32FC1) defer weights2.Close() - BlendLinear(img1, img2, weights1, weights2, &result, Stream{}) + BlendLinear(img1, img2, weights1, weights2, &result) } +func TestBlendLinearWithStream(t *testing.T) { + img1 := NewGpuMatWithSize(256, 256, gocv.MatTypeCV8UC1) + defer img1.Close() + + img2 := NewGpuMatWithSize(256, 256, gocv.MatTypeCV8UC1) + defer img2.Close() + + result := NewGpuMatWithSize(256, 256, gocv.MatTypeCV8UC1) + defer result.Close() + + weights1 := NewGpuMatWithSize(256, 256, gocv.MatTypeCV32FC1) + defer weights1.Close() + + weights2 := NewGpuMatWithSize(256, 256, gocv.MatTypeCV32FC1) + defer weights2.Close() + + s := NewStream() + defer s.Close() + + BlendLinearWithStream(img1, img2, weights1, weights2, &result, s) + s.WaitForCompletion() + +} func TestMeanShiftFiltering(t *testing.T) { src := NewGpuMatWithSize(256, 256, gocv.MatTypeCV8UC4) defer src.Close() @@ -605,7 +788,23 @@ func TestMeanShiftFiltering(t *testing.T) { criteria := gocv.NewTermCriteria(gocv.Count, 1, 2.2) - MeanShiftFiltering(src, &dst, 1, 2, criteria, Stream{}) + MeanShiftFiltering(src, &dst, 1, 2, criteria) +} + +func TestMeanShiftFilteringWithStream(t *testing.T) { + src := NewGpuMatWithSize(256, 256, gocv.MatTypeCV8UC4) + defer src.Close() + + dst := NewGpuMatWithSize(256, 256, gocv.MatTypeCV8UC4) + defer dst.Close() + + criteria := gocv.NewTermCriteria(gocv.Count, 1, 2.2) + + s := NewStream() + defer s.Close() + + MeanShiftFilteringWithStream(src, &dst, 1, 2, criteria, s) + s.WaitForCompletion() } func TestMeanShiftProc(t *testing.T) { @@ -620,7 +819,26 @@ func TestMeanShiftProc(t *testing.T) { criteria := gocv.NewTermCriteria(gocv.Count, 1, 2.2) - MeanShiftProc(src, &dstr, &dstsp, 1, 2, criteria, Stream{}) + MeanShiftProc(src, &dstr, &dstsp, 1, 2, criteria) +} + +func TestMeanShiftProcWithStream(t *testing.T) { + src := NewGpuMatWithSize(256, 256, gocv.MatTypeCV8UC4) + defer src.Close() + + dstr := NewGpuMatWithSize(256, 256, gocv.MatTypeCV8UC4) + defer dstr.Close() + + dstsp := NewGpuMatWithSize(256, 256, gocv.MatTypeCV16SC2) + defer dstsp.Close() + + criteria := gocv.NewTermCriteria(gocv.Count, 1, 2.2) + + s := NewStream() + defer s.Close() + + MeanShiftProcWithStream(src, &dstr, &dstsp, 1, 2, criteria, s) + s.WaitForCompletion() } func TestMeanShiftSegmentation(t *testing.T) { @@ -632,5 +850,21 @@ func TestMeanShiftSegmentation(t *testing.T) { criteria := gocv.NewTermCriteria(gocv.Count, 1, 2.2) - MeanShiftSegmentation(src, &dst, 1, 2, 3, criteria, Stream{}) + MeanShiftSegmentation(src, &dst, 1, 2, 3, criteria) +} + +func TestMeanShiftSegmentationWithStream(t *testing.T) { + src := NewGpuMatWithSize(256, 256, gocv.MatTypeCV8UC4) + defer src.Close() + + dst := NewGpuMatWithSize(256, 256, gocv.MatTypeCV8UC4) + defer dst.Close() + + criteria := gocv.NewTermCriteria(gocv.Count, 1, 2.2) + + s := NewStream() + defer s.Close() + + MeanShiftSegmentationWithStream(src, &dst, 1, 2, 3, criteria, s) + s.WaitForCompletion() }