Skip to content

Commit

Permalink
add String method (hybridgroup#552)
Browse files Browse the repository at this point in the history
* all: add String() method for improved log output
  • Loading branch information
mh-cbon authored and deadprogram committed Dec 8, 2019
1 parent e7c254d commit d624e2c
Show file tree
Hide file tree
Showing 12 changed files with 1,116 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ count.out
.vscode/
/build
.idea/
contrib/data.yaml
27 changes: 27 additions & 0 deletions calib3d_string.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package gocv

func (c CalibFlag) String() string {
switch c {
case CalibUseIntrinsicGuess:
return "calib-use-intrinsec-guess"
case CalibRecomputeExtrinsic:
return "calib-recompute-extrinsic"
case CalibCheckCond:
return "calib-check-cond"
case CalibFixSkew:
return "calib-fix-skew"
case CalibFixK1:
return "calib-fix-k1"
case CalibFixK2:
return "calib-fix-k2"
case CalibFixK3:
return "calib-fix-k3"
case CalibFixK4:
return "calib-fix-k4"
case CalibFixIntrinsic:
return "calib-fix-intrinsic"
case CalibFixPrincipalPoint:
return "calib-fix-principal-point"
}
return ""
}
3 changes: 3 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ignore:
- "*_string.go"
- "*/*_string.go"
11 changes: 11 additions & 0 deletions contrib/img_hash_string.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package contrib

func (c BlockMeanHashMode) String() string {
switch c {
case BlockMeanHashMode0:
return "block-mean-hash-mode0"
case BlockMeanHashMode1:
return "block-mean-hash-mode1"
}
return ""
}
211 changes: 211 additions & 0 deletions core_string.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
package gocv

func (c MatType) String() string {
switch c {
case MatTypeCV8U:
return "CV8U"
case MatTypeCV8UC2:
return "CV8UC2"
case MatTypeCV8UC3:
return "CV8UC3"
case MatTypeCV8UC4:
return "CV8UC4"
case MatTypeCV16U:
return "CV16U"
case MatTypeCV16UC2:
return "CV16UC2"
case MatTypeCV16UC3:
return "CV16UC3"
case MatTypeCV16UC4:
return "CV16UC4"
case MatTypeCV16S:
return "CV16S"
case MatTypeCV16SC2:
return "CV16SC2"
case MatTypeCV16SC3:
return "CV16SC3"
case MatTypeCV16SC4:
return "CV16SC4"
case MatTypeCV32S:
return "CV32S"
case MatTypeCV32SC2:
return "CV32SC2"
case MatTypeCV32SC3:
return "CV32SC3"
case MatTypeCV32SC4:
return "CV32SC4"
case MatTypeCV32F:
return "CV32F"
case MatTypeCV32FC2:
return "CV32FC2"
case MatTypeCV32FC3:
return "CV32FC3"
case MatTypeCV32FC4:
return "CV32FC4"
case MatTypeCV64F:
return "CV64F"
case MatTypeCV64FC2:
return "CV64FC2"
case MatTypeCV64FC3:
return "CV64FC3"
case MatTypeCV64FC4:
return "CV64FC4"
}
return ""
}

func (c CompareType) String() string {
switch c {
case CompareEQ:
return "eq"
case CompareGT:
return "gt"
case CompareGE:
return "ge"
case CompareLT:
return "lt"
case CompareLE:
return "le"
case CompareNE:
return "ne"
}
return ""
}

func (c CovarFlags) String() string {
switch c {
case CovarScrambled:
return "covar-scrambled"
case CovarNormal:
return "covar-normal"
case CovarUseAvg:
return "covar-use-avg"
case CovarScale:
return "covar-scale"
case CovarRows:
return "covar-rows"
case CovarCols:
return "covar-cols"
}
return ""
}

func (c DftFlags) String() string {
switch c {
case DftForward:
return "dft-forward"
case DftInverse:
return "dft-inverse"
case DftScale:
return "dft-scale"
case DftRows:
return "dft-rows"
case DftComplexOutput:
return "dft-complex-output"
case DftRealOutput:
return "dft-real-output"
case DftComplexInput:
return "dft-complex-input"
}
return ""
}

func (c RotateFlag) String() string {
switch c {
case Rotate90Clockwise:
return "rotate-90-clockwise"
case Rotate180Clockwise:
return "rotate-180-clockwise"
case Rotate90CounterClockwise:
return "rotate-90-counter-clockwise"
}
return ""
}

func (c KMeansFlags) String() string {
switch c {
case KMeansRandomCenters:
return "kmeans-random-centers"
case KMeansPPCenters:
return "kmeans-pp-centers"
case KMeansUseInitialLabels:
return "kmeans-use-initial-labels"
}
return ""
}

func (c NormType) String() string {
switch c {
case NormInf:
return "norm-inf"
case NormL1:
return "norm-l1"
case NormL2:
return "norm-l2"
case NormL2Sqr:
return "norm-l2-sqr"
case NormHamming:
return "norm-hamming"
case NormHamming2:
return "norm-hamming2"
case NormRelative:
return "norm-relative"
case NormMinMax:
return "norm-minmax"
}
return ""
}

func (c TermCriteriaType) String() string {
switch c {
case Count:
return "count"
case EPS:
return "eps"
}
return ""
}

func (c SolveDecompositionFlags) String() string {
switch c {
case SolveDecompositionLu:
return "solve-decomposition-lu"
case SolveDecompositionSvd:
return "solve-decomposition-svd"
case SolveDecompositionEing:
return "solve-decomposition-eing"
case SolveDecompositionCholesky:
return "solve-decomposition-cholesky"
case SolveDecompositionQr:
return "solve-decomposition-qr"
case SolveDecompositionNormal:
return "solve-decomposition-normal"
}
return ""
}

func (c ReduceTypes) String() string {
switch c {
case ReduceSum:
return "reduce-sum"
case ReduceAvg:
return "reduce-avg"
case ReduceMax:
return "reduce-max"
case ReduceMin:
return "reduce-min"
}
return ""
}

func (c SortFlags) String() string {
switch c {
case SortEveryRow:
return "sort-every-row"
case SortEveryColumn:
return "sort-every-column"
case SortDescending:
return "sort-descending"
}
return ""
}
39 changes: 39 additions & 0 deletions cuda/cudawarping_string.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package cuda

func (c InterpolationFlags) String() string {
switch c {
case InterpolationNearestNeighbor:
return "interpolation-nearest-neighbor"
case InterpolationLinear:
return "interpolation-linear"
case InterpolationCubic:
return "interpolation-cubic"
case InterpolationArea:
return "interpolation-area"
case InterpolationLanczos4:
return "interpolation-lanczos4"
case InterpolationMax:
return "interpolation-max"
}
return ""
}

func (c BorderType) String() string {
switch c {
case BorderConstant:
return "border-constant"
case BorderReplicate:
return "border-replicate"
case BorderWrap:
return "border-wrap"
case BorderReflect101:
return "border-reflect101"
case BorderTransparent:
return "border-transparent"
case BorderDefault:
return "border-default"
case BorderIsolated:
return "border-isolated"
}
return ""
}
35 changes: 35 additions & 0 deletions dnn_string.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package gocv

func (c NetBackendType) String() string {
switch c {
case NetBackendDefault:
return ""
case NetBackendHalide:
return "halide"
case NetBackendOpenVINO:
return "openvino"
case NetBackendOpenCV:
return "opencv"
case NetBackendVKCOM:
return "vulkan"
}
return ""
}

func (c NetTargetType) String() string {
switch c {
case NetTargetCPU:
return "cpu"
case NetTargetFP32:
return "fp32"
case NetTargetFP16:
return "fp16"
case NetTargetVPU:
return "vpu"
case NetTargetVulkan:
return "vulkan"
case NetTargetFPGA:
return "fpga"
}
return ""
}
33 changes: 33 additions & 0 deletions features2d_string.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package gocv

/*
#include <stdlib.h>
#include "features2d.h"
*/
import "C"

func (c FastFeatureDetectorType) String() string {
switch c {
case FastFeatureDetectorType58:
return "fast-feature-detector-type-58"
case FastFeatureDetectorType712:
return "fast-feature-detector-type-712"
case FastFeatureDetectorType916:
return "fast-feature-detector-type-916"
}
return ""
}

func (c DrawMatchesFlag) String() string {
switch c {
case DrawDefault:
return "draw-default"
case DrawOverOutImg:
return "draw-over-out-imt"
case NotDrawSinglePoints:
return "draw-single-points"
case DrawRichKeyPoints:
return "draw-rich-key-points"
}
return ""
}
Loading

0 comments on commit d624e2c

Please sign in to comment.