Update cuda api

* cv::cuda::CascadeClassifier Class
	* cv::cuda::HOG Class
	* cv::cuda::CannyEdgeDetector
This commit is contained in:
Daniel
2020-02-07 10:43:16 +03:00
committed by Ron Evans
parent b88d1da6ba
commit d1f1c43d06
12 changed files with 828 additions and 1 deletions

7
cuda/core.cpp Normal file
View File

@@ -0,0 +1,7 @@
#include "../core.h"
#include "core.h"
#include <string.h>
void GpuRects_Close(struct Rects rs) {
delete[] rs.rects;
}

30
cuda/core.go Normal file
View File

@@ -0,0 +1,30 @@
package cuda
/*
#include <stdlib.h>
#include "../core.h"
#include "core.h"
*/
import "C"
import (
"image"
"reflect"
"unsafe"
)
func toRectangles(ret C.Rects) []image.Rectangle {
cArray := ret.rects
length := int(ret.length)
hdr := reflect.SliceHeader{
Data: uintptr(unsafe.Pointer(cArray)),
Len: length,
Cap: length,
}
s := *(*[]C.Rect)(unsafe.Pointer(&hdr))
rects := make([]image.Rectangle, length)
for i, r := range s {
rects[i] = image.Rect(int(r.x), int(r.y), int(r.x+r.width), int(r.y+r.height))
}
return rects
}

18
cuda/core.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef _OPENCV3_CUDA_CORE_H_
#define _OPENCV3_CUDA_CORE_H_
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
#include <opencv2/opencv.hpp>
extern "C" {
#endif
void GpuRects_Close(struct Rects rs);
#ifdef __cplusplus
}
#endif
#endif //_OPENCV3_CUDA_CORE_H_

View File

@@ -34,4 +34,8 @@ void PrintShortCudaDeviceInfo(int device){
int GetCudaEnabledDeviceCount(){ int GetCudaEnabledDeviceCount(){
return cv::cuda::getCudaEnabledDeviceCount(); return cv::cuda::getCudaEnabledDeviceCount();
} }
void GpuMat_ConvertTo(GpuMat m, GpuMat dst, int type) {
m->convertTo(*dst, type);
}

View File

@@ -79,3 +79,13 @@ func PrintShortCudaDeviceInfo(device int) {
func GetCudaEnabledDeviceCount() int { func GetCudaEnabledDeviceCount() int {
return int(C.GetCudaEnabledDeviceCount()) return int(C.GetCudaEnabledDeviceCount())
} }
// ConvertTo converts GpuMat into destination GpuMat.
//
// For further details, please see:
// https://docs.opencv.org/master/d0/d60/classcv_1_1cuda_1_1GpuMat.html#a3a1b076e54d8a8503014e27a5440d98a
//
func (m *GpuMat) ConvertTo(dst *GpuMat, mt gocv.MatType) {
C.GpuMat_ConvertTo(m.p, dst.p, C.int(mt))
return
}

View File

@@ -22,10 +22,12 @@ void GpuMat_Upload(GpuMat m,Mat data);
void GpuMat_Download(GpuMat m,Mat dst); void GpuMat_Download(GpuMat m,Mat dst);
void GpuMat_Close(GpuMat m); void GpuMat_Close(GpuMat m);
int GpuMat_Empty(GpuMat m); int GpuMat_Empty(GpuMat m);
void GpuMat_ConvertTo(GpuMat m, GpuMat dst, int type);
void PrintCudaDeviceInfo(int device); void PrintCudaDeviceInfo(int device);
void PrintShortCudaDeviceInfo(int device); void PrintShortCudaDeviceInfo(int device);
int GetCudaEnabledDeviceCount(); int GetCudaEnabledDeviceCount();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

54
cuda/imgproc.cpp Normal file
View File

@@ -0,0 +1,54 @@
#include "../core.h"
#include "imgproc.h"
#include <string.h>
void GpuCvtColor(GpuMat src, GpuMat dst, int code) {
cv::cuda::cvtColor(*src, *dst, code);
}
void GpuThreshold(GpuMat src, GpuMat dst, double thresh, double maxval, int typ) {
cv::cuda::threshold(*src, *dst, thresh, maxval, typ);
}
CannyEdgeDetector CreateCannyEdgeDetector(double lowThresh, double highThresh, int appertureSize, bool L2gradient) {
return new cv::Ptr<cv::cuda::CannyEdgeDetector>(cv::cuda::createCannyEdgeDetector(lowThresh,highThresh,appertureSize,L2gradient));
}
GpuMat CannyEdgeDetector_Detect(CannyEdgeDetector det, GpuMat img) {
GpuMat dst = new cv::cuda::GpuMat();
(*det)->detect(*img, *dst);
return dst;
}
int CannyEdgeDetector_GetAppertureSize(CannyEdgeDetector det) {
return int((*det)->getAppertureSize());
}
double CannyEdgeDetector_GetHighThreshold(CannyEdgeDetector det) {
return double((*det)->getHighThreshold());
}
bool CannyEdgeDetector_GetL2Gradient(CannyEdgeDetector det) {
return bool((*det)->getL2Gradient());
}
double CannyEdgeDetector_GetLowThreshold(CannyEdgeDetector det) {
return double((*det)->getLowThreshold());
}
void CannyEdgeDetector_SetAppertureSize(CannyEdgeDetector det, int appertureSize) {
(*det)->setAppertureSize(appertureSize);
}
void CannyEdgeDetector_SetHighThreshold(CannyEdgeDetector det, double highThresh) {
(*det)->setHighThreshold(highThresh);
}
void CannyEdgeDetector_SetL2Gradient(CannyEdgeDetector det, bool L2gradient) {
(*det)->setL2Gradient(L2gradient);
}
void CannyEdgeDetector_SetLowThreshold(CannyEdgeDetector det, double lowThresh) {
(*det)->setLowThreshold(lowThresh);
}

129
cuda/imgproc.go Normal file
View File

@@ -0,0 +1,129 @@
package cuda
/*
#include <stdlib.h>
#include "../core.h"
#include "core.h"
#include "imgproc.h"
*/
import "C"
import (
"unsafe"
"gocv.io/x/gocv"
)
// CannyEdgeDetector
//
// For further details, please see:
// https://docs.opencv.org/master/d0/d43/classcv_1_1cuda_1_1CannyEdgeDetector.html
//
type CannyEdgeDetector struct {
p unsafe.Pointer
}
// NewCascadeClassifier_GPU returns a new CascadeClassifier.
func CreateCannyEdgeDetector(lowThresh, highThresh float64, appertureSize int, L2gradient bool) CannyEdgeDetector {
return CannyEdgeDetector{p: unsafe.Pointer(C.CreateCannyEdgeDetector(C.double(lowThresh), C.double(highThresh), C.int(appertureSize), C.bool(L2gradient)))}
}
// Detect finds edges in an image using the Canny algorithm.
//
// For further details, please see:
// https://docs.opencv.org/master/d0/d43/classcv_1_1cuda_1_1CannyEdgeDetector.html#a6438cf8453f2dfd6703ceb50056de309
//
func (h *CannyEdgeDetector) Detect(img GpuMat) GpuMat {
return newGpuMat(C.CannyEdgeDetector_Detect(C.CannyEdgeDetector(h.p), img.p))
}
// GetAppertureSize
//
// For further details, please see:
// https://docs.opencv.org/master/d0/d43/classcv_1_1cuda_1_1CannyEdgeDetector.html#a19c2963ff255b0c18387594a704439d3
//
func (h *CannyEdgeDetector) GetAppertureSize() int {
return int(C.CannyEdgeDetector_GetAppertureSize(C.CannyEdgeDetector(h.p)))
}
// GetHighThreshold
//
// For further details, please see:
// https://docs.opencv.org/master/d0/d43/classcv_1_1cuda_1_1CannyEdgeDetector.html#a8366296a57059487dcfd7b30f4a9e3b1
//
func (h *CannyEdgeDetector) GetHighThreshold() float64 {
return float64(C.CannyEdgeDetector_GetHighThreshold(C.CannyEdgeDetector(h.p)))
}
// GetL2Gradient
//
// For further details, please see:
// https://docs.opencv.org/master/d0/d43/classcv_1_1cuda_1_1CannyEdgeDetector.html#a8fe4ed887c226b12ab44084789b4c6dd
//
func (h *CannyEdgeDetector) GetL2Gradient() bool {
return bool(C.CannyEdgeDetector_GetL2Gradient(C.CannyEdgeDetector(h.p)))
}
// GetLowThreshold
//
// For further details, please see:
// https://docs.opencv.org/master/d0/d43/classcv_1_1cuda_1_1CannyEdgeDetector.html#aaf5a8944a8ac11093cf7a093b45cd3a8
//
func (h *CannyEdgeDetector) GetLowThreshold() float64 {
return float64(C.CannyEdgeDetector_GetLowThreshold(C.CannyEdgeDetector(h.p)))
}
// SetAppertureSize
//
// For further details, please see:
// https://docs.opencv.org/master/d0/d43/classcv_1_1cuda_1_1CannyEdgeDetector.html#aac7d0602338e1a2a783811a929967714
//
func (h *CannyEdgeDetector) SetAppertureSize(appertureSize int) {
C.CannyEdgeDetector_SetAppertureSize(C.CannyEdgeDetector(h.p), C.int(appertureSize))
}
// SetHighThreshold
//
// For further details, please see:
// https://docs.opencv.org/master/d0/d43/classcv_1_1cuda_1_1CannyEdgeDetector.html#a63d352fe7f3bad640e63f4e394619235
//
func (h *CannyEdgeDetector) SetHighThreshold(highThresh float64) {
C.CannyEdgeDetector_SetHighThreshold(C.CannyEdgeDetector(h.p), C.double(highThresh))
}
// SetL2Gradient
//
// For further details, please see:
// https://docs.opencv.org/master/d0/d43/classcv_1_1cuda_1_1CannyEdgeDetector.html#ac2e8a675cc30cb3e621ac684e22f89d1
//
func (h *CannyEdgeDetector) SetL2Gradient(L2gradient bool) {
C.CannyEdgeDetector_SetL2Gradient(C.CannyEdgeDetector(h.p), C.bool(L2gradient))
}
// SetLowThreshold
//
// For further details, please see:
// https://docs.opencv.org/master/d0/d43/classcv_1_1cuda_1_1CannyEdgeDetector.html#a6bdc1479c1557288a69c6314c61d1548
//
func (h *CannyEdgeDetector) SetLowThreshold(lowThresh float64) {
C.CannyEdgeDetector_SetLowThreshold(C.CannyEdgeDetector(h.p), C.double(lowThresh))
}
// CvtColor converts an image from one color space to another.
// It converts the src Mat image to the dst Mat using the
// code param containing the desired ColorConversionCode color space.
//
// For further details, please see:
// https://docs.opencv.org/master/db/d8c/group__cudaimgproc__color.html#ga48d0f208181d5ca370d8ff6b62cbe826
//
func CvtColor(src GpuMat, dst *GpuMat, code gocv.ColorConversionCode) {
C.GpuCvtColor(src.p, dst.p, C.int(code))
}
// Threshold applies a fixed-level threshold to each array element.
//
// For further details, please see:
// https://docs.opencv.org/master/d8/d34/group__cudaarithm__elem.html#ga40f1c94ae9a9456df3cad48e3cb008e1
//
func Threshold(src GpuMat, dst *GpuMat, thresh, maxval float64, typ int) {
C.GpuThreshold(src.p, dst.p, C.double(thresh), C.double(maxval), C.int(typ))
}

36
cuda/imgproc.h Normal file
View File

@@ -0,0 +1,36 @@
#ifndef _OPENCV3_CUDA_IMGPROC_H_
#define _OPENCV3_CUDA_IMGPROC_H_
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
#include <opencv2/opencv.hpp>
extern "C" {
#endif
#include "cuda.h"
#ifdef __cplusplus
typedef cv::Ptr<cv::cuda::CannyEdgeDetector>* CannyEdgeDetector;
#else
typedef void* CannyEdgeDetector;
#endif
void GpuCvtColor(GpuMat src, GpuMat dst, int code);
void GpuThreshold(GpuMat src, GpuMat dst, double thresh, double maxval, int typ);
CannyEdgeDetector CreateCannyEdgeDetector(double lowThresh, double highThresh, int appertureSize, bool L2gradient);
GpuMat CannyEdgeDetector_Detect(CannyEdgeDetector det, GpuMat img);
int CannyEdgeDetector_GetAppertureSize(CannyEdgeDetector det);
double CannyEdgeDetector_GetHighThreshold(CannyEdgeDetector det);
bool CannyEdgeDetector_GetL2Gradient(CannyEdgeDetector det);
double CannyEdgeDetector_GetLowThreshold(CannyEdgeDetector det);
void CannyEdgeDetector_SetAppertureSize(CannyEdgeDetector det, int appertureSize);
void CannyEdgeDetector_SetHighThreshold(CannyEdgeDetector det, double highThresh);
void CannyEdgeDetector_SetL2Gradient(CannyEdgeDetector det, bool L2gradient);
void CannyEdgeDetector_SetLowThreshold(CannyEdgeDetector det, double lowThresh);
#ifdef __cplusplus
}
#endif
#endif //_OPENCV3_CUDA_IMGPROC_H_

155
cuda/objdetect.cpp Normal file
View File

@@ -0,0 +1,155 @@
#include "../core.h"
#include "cuda.h"
#include "objdetect.h"
// CascadeClassifier_GPU
CascadeClassifier_GPU CascadeClassifier_GPU_Create(const char* cascade_name) {
return new cv::Ptr<cv::cuda::CascadeClassifier>(cv::cuda::CascadeClassifier::create(cascade_name));
}
struct Rects CascadeClassifier_GPU_DetectMultiScale(CascadeClassifier_GPU cs, GpuMat img) {
std::vector<cv::Rect> detected;
cv::cuda::GpuMat objbuf;
(*cs)->detectMultiScale(*img, objbuf); // uses all default parameters
(*cs)->convert(objbuf, detected);
Rect* rects = new Rect[detected.size()];
for (size_t i = 0; i < detected.size(); ++i) {
Rect r = {detected[i].x, detected[i].y, detected[i].width, detected[i].height};
rects[i] = r;
}
Rects ret = {rects, (int)detected.size()};
return ret;
}
// HOG
HOG HOG_Create() {
return new cv::Ptr<cv::cuda::HOG>(cv::cuda::HOG::create());
}
HOG HOG_CreateWithParams(Size winSize, Size blockSize, Size blockStride, Size cellSize, int nbins) {
cv::Size winSz(winSize.width, winSize.height);
cv::Size blockSz(blockSize.width, blockSize.height);
cv::Size blockSt(blockStride.width, blockStride.height);
cv::Size cellSz(cellSize.width, cellSize.height);
return new cv::Ptr<cv::cuda::HOG>(cv::cuda::HOG::create(winSz, blockSz, blockSt, cellSz, nbins));
}
struct Rects HOG_DetectMultiScale(HOG hog, GpuMat img) {
std::vector<cv::Rect> detected;
(*hog)->detectMultiScale(*img, detected);
Rect* rects = new Rect[detected.size()];
for (size_t i = 0; i < detected.size(); ++i) {
Rect r = {detected[i].x, detected[i].y, detected[i].width, detected[i].height};
rects[i] = r;
}
Rects ret = {rects, (int)detected.size()};
return ret;
}
GpuMat HOG_Compute(HOG hog, GpuMat img) {
GpuMat dst = new cv::cuda::GpuMat();
(*hog)->compute(*img, *dst);
return dst;
}
Mat HOG_GetPeopleDetector(HOG hog) {
return new cv::Mat((*hog)->getDefaultPeopleDetector());
}
void HOG_SetSVMDetector(HOG hog, Mat det) {
(*hog)->setSVMDetector(*det);
}
int HOG_GetDescriptorFormat(HOG hog) {
return int((*hog)->getDescriptorFormat());
}
size_t HOG_GetBlockHistogramSize(HOG hog) {
return size_t((*hog)->getBlockHistogramSize());
}
size_t HOG_GetDescriptorSize(HOG hog) {
return size_t((*hog)->getDescriptorSize());
}
bool HOG_GetGammaCorrection(HOG hog) {
return bool((*hog)->getGammaCorrection());
}
int HOG_GetGroupThreshold(HOG hog) {
return int((*hog)->getGroupThreshold());
}
double HOG_GetHitThreshold(HOG hog) {
return double((*hog)->getHitThreshold());
}
double HOG_GetL2HysThreshold(HOG hog) {
return double((*hog)->getL2HysThreshold());
}
int HOG_GetNumLevels(HOG hog) {
return int((*hog)->getNumLevels());
}
double HOG_GetScaleFactor(HOG hog) {
return double((*hog)->getScaleFactor());
}
double HOG_GetWinSigma(HOG hog) {
return double((*hog)->getWinSigma());
}
struct Size HOG_GetWinStride(HOG hog) {
cv::Size sz = (*hog)->getWinStride();
Size size = {sz.width, sz.height};
return size;
}
void HOG_SetDescriptorFormat(HOG hog, int descrFormat) {
auto df = static_cast<cv::HOGDescriptor::DescriptorStorageFormat>(descrFormat);
(*hog)->setDescriptorFormat(df);
}
void HOG_SetGammaCorrection(HOG hog, bool gammaCorrection) {
(*hog)->setGammaCorrection(gammaCorrection);
}
void HOG_SetGroupThreshold(HOG hog, int groupThreshold) {
(*hog)->setGroupThreshold(groupThreshold);
}
void HOG_SetHitThreshold(HOG hog, double hitThreshold) {
(*hog)->setHitThreshold(hitThreshold);
}
void HOG_SetL2HysThreshold(HOG hog, double thresholdL2hys) {
(*hog)->setL2HysThreshold(thresholdL2hys);
}
void HOG_SetNumLevels(HOG hog, int nlevels) {
(*hog)->setNumLevels(nlevels);
}
void HOG_SetScaleFactor(HOG hog, double scale0) {
(*hog)->setScaleFactor(scale0);
}
void HOG_SetWinSigma(HOG hog, double winSigma) {
(*hog)->setWinSigma(winSigma);
}
void HOG_SetWinStride(HOG hog, Size dsize) {
cv::Size sz(dsize.width, dsize.height);
(*hog)->setWinStride(sz);
}

322
cuda/objdetect.go Normal file
View File

@@ -0,0 +1,322 @@
// Package cuda is the GoCV wrapper around OpenCV cuda.
//
// For further details, please see:
// https://github.com/opencv/c
//
// import "gocv.io/x/gocv/cuda"
package cuda
/*
#include <stdlib.h>
#include "../core.h"
#include "objdetect.h"
#include "core.h"
*/
import "C"
import (
"image"
"unsafe"
)
type DescriptorStorageFormat int
const (
DESCR_FORMAT_COL_BY_COL DescriptorStorageFormat = 0
DESCR_FORMAT_COL_BY_ROW = 1
)
// CascadeClassifier_GPU is a cascade classifier class for object detection.
//
// For further details, please see:
// https://docs.opencv.org/master/d9/d80/classcv_1_1cuda_1_1CascadeClassifier.html
//
type CascadeClassifier struct {
p unsafe.Pointer
}
// NewCascadeClassifier_GPU returns a new CascadeClassifier.
func NewCascadeClassifier(name string) CascadeClassifier {
cName := C.CString(name)
defer C.free(unsafe.Pointer(cName))
return CascadeClassifier{p: unsafe.Pointer(C.CascadeClassifier_GPU_Create(cName))}
}
// DetectMultiScale detects objects of different sizes in the input Mat image.
// The detected objects are returned as a slice of image.Rectangle structs.
//
// For further details, please see:
// https://docs.opencv.org/master/d9/d80/classcv_1_1cuda_1_1CascadeClassifier.html#a182656b878046eb3f0e9c0f0ee327f08
//
func (c *CascadeClassifier) DetectMultiScale(img GpuMat) []image.Rectangle {
ret := C.CascadeClassifier_GPU_DetectMultiScale(C.CascadeClassifier_GPU(c.p), img.p)
defer C.GpuRects_Close(ret)
return toRectangles(ret)
}
// HOG is a Histogram Of Gradiants (HOG) for object detection.
//
// For further details, please see:
// https://docs.opencv.org/master/d5/d33/structcv_1_1HOG.html#a723b95b709cfd3f95cf9e616de988fc8
//
type HOG struct {
p unsafe.Pointer
}
// NewHOG returns a new HOG.
func CreateHOG() HOG {
return HOG{p: unsafe.Pointer(C.HOG_Create())}
}
func CreateHOGWithParams(winSize, blockSize, blockStride, cellSize image.Point, nbins int) HOG {
wSz := C.struct_Size{
width: C.int(winSize.X),
height: C.int(winSize.Y),
}
bSz := C.struct_Size{
width: C.int(blockSize.X),
height: C.int(blockSize.Y),
}
bSt := C.struct_Size{
width: C.int(blockStride.X),
height: C.int(blockStride.Y),
}
cSz := C.struct_Size{
width: C.int(cellSize.X),
height: C.int(cellSize.Y),
}
return HOG{p: unsafe.Pointer(C.HOG_CreateWithParams(wSz, bSz, bSt, cSz, C.int(nbins)))}
}
// Compute returns block descriptors computed for the whole image.
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#ab4287267081959ec77c01269dbfcd373
//
func (h *HOG) Compute(img GpuMat) GpuMat {
return newGpuMat(C.HOG_Compute(C.HOG(h.p), img.p))
}
// DetectMultiScale detects objects in the input Mat image.
// The detected objects are returned as a slice of image.Rectangle structs.
//
// For further details, please see:
// https://docs.opencv.org/master/d5/d33/structcv_1_1HOG.html#a660e5cd036fd5ddf0f5767b352acd948
//
func (h *HOG) DetectMultiScale(img GpuMat) []image.Rectangle {
ret := C.HOG_DetectMultiScale(C.HOG(h.p), img.p)
defer C.GpuRects_Close(ret)
return toRectangles(ret)
}
// GetDefaultPeopleDetector returns a new Mat with the HOG DefaultPeopleDetector.
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#a016f9ffced8b2f4b20bdd06a775017d1
//
func (h *HOG) GetDefaultPeopleDetector() C.Mat {
return C.Mat(C.HOG_GetPeopleDetector(C.HOG(h.p)))
}
// SetSVMDetector sets the data for the HOG.
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#a5d12db2277b7c3c849d75258eec8d1d4
//
func (h *HOG) SetSVMDetector(det C.Mat) error {
C.HOG_SetSVMDetector(C.HOG(h.p), det)
return nil
}
// GetDescriptorFormat
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#adad29ed960a953aa13dc59c410683620
//
func (h *HOG) GetDescriptorFormat() DescriptorStorageFormat {
return DescriptorStorageFormat(C.HOG_GetDescriptorFormat(C.HOG(h.p)))
}
// GetBlockHistogramSize returns the block histogram size.
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#a016f9ffced8b2f4b20bdd06a775017d1
//
func (h *HOG) GetBlockHistogramSize() int {
return int(C.HOG_GetBlockHistogramSize(C.HOG(h.p)))
}
// GetDescriptorFormat returns the number of coefficients required for the classification.
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#adb8c714cba1a025b8869d5a0e152f824
//
func (h *HOG) GetDescriptorSize() int {
return int(C.HOG_GetDescriptorSize(C.HOG(h.p)))
}
// GetGammaCorrection
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#a7032eed27cf7a004b727a6e522c2404e
//
func (h *HOG) GetGammaCorrection() bool {
return bool(C.HOG_GetGammaCorrection(C.HOG(h.p)))
}
// GetGroupThreshold
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#a7032eed27cf7a004b727a6e522c2404e
//
func (h *HOG) GetGroupThreshold() int {
return int(C.HOG_GetGroupThreshold(C.HOG(h.p)))
}
// GetHitThreshold
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#ae0de149980ea47fbd39b7766df565b27
//
func (h *HOG) GetHitThreshold() float64 {
return float64(C.HOG_GetHitThreshold(C.HOG(h.p)))
}
// GetL2HysThreshold
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#a6853c9a66889fed996678f7972df9660
//
func (h *HOG) GetL2HysThreshold() float64 {
return float64(C.HOG_GetL2HysThreshold(C.HOG(h.p)))
}
// GetNumLevels
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#a15238eb6f52a1ddeedd015773c46efd8
//
func (h *HOG) GetNumLevels() int {
return int(C.HOG_GetNumLevels(C.HOG(h.p)))
}
// GetScaleFactor
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#a89c59564625bb2c691af8c2cf49aab9e
//
func (h *HOG) GetScaleFactor() float64 {
return float64(C.HOG_GetScaleFactor(C.HOG(h.p)))
}
// GetWinSigma
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#a22d03fa05b251b4f19cfa1fab36e754e
//
func (h *HOG) GetWinSigma() float64 {
return float64(C.HOG_GetWinSigma(C.HOG(h.p)))
}
// GetWinStride
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#a6c63504790b51963ca33496a0b039b48
//
func (h *HOG) GetWinStride() image.Point {
sz := C.HOG_GetWinStride(C.HOG(h.p))
return image.Pt(int(sz.width), int(sz.height))
}
// SetDescriptorFormat
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#a6e3e1075a567268f2dfb2151b1c99cb6
//
func (h *HOG) SetDescriptorFormat(descrFormat DescriptorStorageFormat) {
C.HOG_SetDescriptorFormat(C.HOG(h.p), C.int(descrFormat))
}
// SetGammaCorrection
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#a0eb2f1ecf59ccc599bffac3a0a55562f
//
func (h *HOG) SetGammaCorrection(gammaCorrection bool) {
C.HOG_SetGammaCorrection(C.HOG(h.p), C.bool(gammaCorrection))
}
// SetGroupThreshold
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#adad9af4e4ed0e0a045a70cd44520eefd
//
func (h *HOG) SetGroupThreshold(groupThreshold int) {
C.HOG_SetGroupThreshold(C.HOG(h.p), C.int(groupThreshold))
}
// SetHitThreshold
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#a8b623393c11d18b89fa373269b97aea4
//
func (h *HOG) SetHitThreshold(hitThreshold float64) {
C.HOG_SetHitThreshold(C.HOG(h.p), C.double(hitThreshold))
}
// SetL2HysThreshold
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#a30e5c88864fff774f403313993947d62
//
func (h *HOG) SetL2HysThreshold(thresholdL2hys float64) {
C.HOG_SetL2HysThreshold(C.HOG(h.p), C.double(thresholdL2hys))
}
// SetNumLevels
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#a7602088f3e792de196f8f7efcd9bd448
//
func (h *HOG) SetNumLevels(nlevels int) {
C.HOG_SetNumLevels(C.HOG(h.p), C.int(nlevels))
}
// SetScaleFactor
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#a21dc5e3dc6272030694d52e83352b337
//
func (h *HOG) SetScaleFactor(scale0 float64) {
C.HOG_SetScaleFactor(C.HOG(h.p), C.double(scale0))
}
// SetWinSigma
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#ab291779ff8ac649174b102f64c5f9012
//
func (h *HOG) SetWinSigma(winSigma float64) {
C.HOG_SetWinSigma(C.HOG(h.p), C.double(winSigma))
}
// SetWinStride
//
// For further details, please see:
// https://docs.opencv.org/master/de/da6/classcv_1_1cuda_1_1HOG.html#a5e74646651209ae13f1b3dd18179773f
//
func (h *HOG) SetWinStride(sz image.Point) {
pSize := C.struct_Size{
width: C.int(sz.X),
height: C.int(sz.Y),
}
C.HOG_SetWinStride(C.HOG(h.p), pSize)
return
}

60
cuda/objdetect.h Normal file
View File

@@ -0,0 +1,60 @@
#ifndef _OPENCV3_GPU_H_
#define _OPENCV3_GPU_H_
#include <stdbool.h>
#ifdef __cplusplus
#include <opencv2/opencv.hpp>
#include <opencv2/core/cuda.hpp>
extern "C" {
#endif
#include "../core.h"
#include "cuda.h"
#ifdef __cplusplus
typedef cv::Ptr<cv::cuda::CascadeClassifier>* CascadeClassifier_GPU;
typedef cv::Ptr<cv::cuda::HOG>* HOG;
#else
typedef void* CascadeClassifier_GPU;
typedef void* HOG;
#endif
// CascadeClassifier
CascadeClassifier_GPU CascadeClassifier_GPU_Create(const char* cascade_name);
struct Rects CascadeClassifier_GPU_DetectMultiScale(CascadeClassifier_GPU cs, GpuMat img);
// HOG
HOG HOG_Create();
HOG HOG_CreateWithParams(Size winSize, Size blockSize, Size blockStride, Size cellSize, int nbins);
struct Rects HOG_DetectMultiScale(HOG hog, GpuMat img);
GpuMat HOG_Compute(HOG hog, GpuMat img);
Mat HOG_GetPeopleDetector(HOG hog);
void HOG_SetSVMDetector(HOG hog, Mat det);
int HOG_GetDescriptorFormat(HOG hog);
size_t HOG_GetBlockHistogramSize(HOG hog);
size_t HOG_GetDescriptorSize(HOG hog);
bool HOG_GetGammaCorrection(HOG hog);
int HOG_GetGroupThreshold(HOG hog);
double HOG_GetHitThreshold(HOG hog);
double HOG_GetL2HysThreshold(HOG hog);
int HOG_GetNumLevels(HOG hog);
double HOG_GetScaleFactor(HOG hog);
double HOG_GetWinSigma(HOG hog);
struct Size HOG_GetWinStride(HOG hog);
void HOG_SetDescriptorFormat(HOG hog, int descrFormat);
void HOG_SetGammaCorrection(HOG hog, bool gammaCorrection);
void HOG_SetGroupThreshold(HOG hog, int groupThreshold);
void HOG_SetHitThreshold(HOG hog, double hitThreshold);
void HOG_SetL2HysThreshold(HOG hog, double thresholdL2hys);
void HOG_SetNumLevels(HOG hog, int nlevels);
void HOG_SetScaleFactor(HOG hog, double scale0);
void HOG_SetWinSigma(HOG hog, double winSigma);
void HOG_SetWinStride(HOG hog, Size dsize);
#ifdef __cplusplus
}
#endif
#endif //_OPENCV3_GPU_H_