Video Analysis底层库拆分,sdk的go封装
zhangzengfei
2019-11-19 a8ff93a0cf274795f0e9c3d66093f1c4c6ccf972
gosdk.go
@@ -1,11 +1,14 @@
package gosdk
/*
#cgo CFLAGS: -I. -I./sdk/face/include -I./sdk/darknet/include -I/usr/local/cuda/include -I./sdk/plate/include -w -g
#cgo CXXFLAGS: -I. -I./sdk/face/include -I./sdk/darknet/include -I/usr/local/cuda/include -I./sdk/plate/include -w -g -std=c++11
#cgo LDFLAGS: -L/usr/local/cuda/lib64 -L${SRCDIR}/sdk/face/lib/gpu -L${SRCDIR}/sdk/darknet/lib -L${SRCDIR}/sdk/plate/lib
#cgo LDFLAGS: -Wl,-rpath,${SRCDIR}/sdk/face/lib/gpu:${SRCDIR}/sdk/darknet/lib
#cgo LDFLAGS: -ldarknet -lTHFaceImage -lTHFeature -lTHFaceProperty -lTHFaceTracking -lcudart -lcublas -lcurand -lrt -ldl -lpthread -lthplateid
#cgo CFLAGS: -I. -I./sdk/face/include -I./sdk/darknet/include -I/usr/local/cuda/include -w -g
#cgo CFLAGS:  -I./sdk/plate/eparking/include -I./sdk/plate/cloud/include
#cgo CXXFLAGS: -I. -I./sdk/face/include -I./sdk/darknet/include -I/usr/local/cuda/include -w -g -std=c++11
#cgo CXXFLAGS: -I./sdk/plate/eparking/include -I./sdk/plate/cloud/include
#cgo LDFLAGS: -L/usr/local/cuda/lib64 -L${SRCDIR}/sdk/face/lib/gpu -L${SRCDIR}/sdk/darknet/lib
#cgo LDFLAGS: -L${SRCDIR}/sdk/plate/eparking/lib -L${SRCDIR}/sdk/plate/cloud/lib
#cgo LDFLAGS: -Wl,-rpath,${SRCDIR}/sdk/face/lib/gpu:${SRCDIR}/sdk/darknet/lib:${SRCDIR}/sdk/plate/cloud/lib
#cgo LDFLAGS: -ldarknet -lTHFaceImage -lTHFeature -lTHFaceProperty -lTHFaceTracking -lcudart -lcublas -lcurand -lrt -ldl -lpthread -lthplateid -lLPRecognition
#include <stdlib.h>
#include "csdk.h"
*/
@@ -420,7 +423,7 @@
      MaxImageWidth: 4096,
      MaxImageHeight: 2160,
      IsFieldImage: 0,
      MovingImage: 1,
      MovingImage: 0,
      OrderOpt: 0,
      LeanCorrection: 1,
      ImproveSpeed: 0,
@@ -439,9 +442,9 @@
      TwoRowArmy: 1,
      Tractor: 1,
      Embassy: 1,
      ChangNei: 1,
      MinHang: 1,
      Consulate: 1,
      ChangNei: 0,
      MinHang: 0,
      Consulate: 10,
      NewEnergy: 1,
      OnlyTwoRowYellow: 0,
      OnlyLocation: 0,
@@ -454,13 +457,13 @@
}
// PlateIDDetect plateid detect
func PlateIDDetect(img SDKImage) []CPlateIDResult {
func PlateIDDetect(img SDKImage, rcDetect *CRECT) []CPlateIDResult {
   data := img.Data
   w := img.Width
   h := img.Height
   var count C.int
   cppos := C.c_api_plate_id_detect(&count, (*C.uchar)(unsafe.Pointer(&data[0])), C.int(w), C.int(h))
   cppos := C.c_api_plate_id_detect(&count, (*C.uchar)(unsafe.Pointer(&data[0])), C.int(w), C.int(h), (*C.cRECT)(unsafe.Pointer(rcDetect)))
   if cppos != nil {
      defer C.free(unsafe.Pointer(cppos))
      return CPlateIDPosArrayToGoArray(unsafe.Pointer(cppos), int(count))
@@ -470,4 +473,52 @@
func FreePlateIdDetector() int{
   return int(C.c_api_plate_id_free())
}
func DefaultPlateIDCloudSDKConfig() *CPlateIDCloudCfg{
   return &CPlateIDCloudCfg{
      NImageMode: 0,
      NRecMode:   0,
      NMinPlateWidth: 60,
      NMaxPlateWidth: 400,
      NImageWidth:  4096,
      NImageHeight: 2160,
      NMinHorAngle: -15,
      NMaxHorAngle: 15,
      NMinVerAngle: -30,
      NMaxVerAngle: 30,
      FExpLeftRightR: 1.6,
      FExpTopR:       6.0,
      FExpBottomR:    1.5,
   }
}
// InitPlateIDCloudSDKDetector init plateid detector
func InitPlateIDCloudSDKDetector(config *CPlateIDCloudCfg, keyPath, modelPath[]byte) int {
   return int(C.c_api_plate_id_cloud_init((*C.cPlateIDCloudSDKCfg)(unsafe.Pointer(config)), (*C.char)(unsafe.Pointer(&keyPath[0])), (*C.char)(unsafe.Pointer(&modelPath[0]))))
}
// PlateIDCloudSDKDetect plateid detect
func PlateIDCloudSDKDetect(img SDKImage, rcDetect *CRECT) []CPlateIDCloudResult {
   data := img.Data
   w := img.Width
   h := img.Height
   var count C.int
   cppos := C.c_api_plate_id_cloud_detect(&count, (*C.uchar)(unsafe.Pointer(&data[0])), C.int(w), C.int(h), (*C.cRECT)(unsafe.Pointer(rcDetect)))
   if cppos != nil {
      defer C.free(unsafe.Pointer(cppos))
      return CPlateIDCloudPosArrayToGoArray(unsafe.Pointer(cppos), int(count))
   }
   return nil
}
// FreePlateIDCloudSDKDetector free
func FreePlateIDCloudSDKDetector() {
   C.c_api_plate_id_free()
}