Video Analysis底层库拆分,sdk的go封装
zhangzengfei
2019-11-20 308defe0578c2184d35a59fde31b9cb007f2f889
gosdk.go
@@ -2,13 +2,14 @@
/*
#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 CFLAGS:  -I./sdk/plate/eparking/include -I./sdk/plate/cloud/include -I./sdk/plate/vehicle/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 CXXFLAGS: -I./sdk/plate/eparking/include -I./sdk/plate/cloud/include -I./sdk/plate/vehicle/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: -L${SRCDIR}/sdk/plate/eparking/lib -L${SRCDIR}/sdk/plate/cloud/lib -L${SRCDIR}/sdk/plate/vehicle/lib
#cgo LDFLAGS: -Wl,-rpath,${SRCDIR}/sdk/face/lib/gpu:${SRCDIR}/sdk/darknet/lib:${SRCDIR}/sdk/plate/cloud/lib:${SRCDIR}/sdk/plate/vehicle/lib
#cgo LDFLAGS: -ldarknet -lTHFaceImage -lTHFeature -lTHFaceProperty -lTHFaceTracking -lcudart -lcublas -lcurand -lrt -ldl -lpthread -lthplateid -lLPRecognition
#cgo LDFLAGS: -lVehicleTypeRecognition -lDetection -lExtractor -lvehicleFeatureExt -lopenblas -lprotobuf
#include <stdlib.h>
#include "csdk.h"
*/
@@ -521,4 +522,30 @@
// FreePlateIDCloudSDKDetector free
func FreePlateIDCloudSDKDetector() {
   C.c_api_plate_id_free()
}
}
// InitVehicleITSDetector init vehicle detector
func InitVehicleITSDetector(sceneMode, modelMode int, keyPath, modelPath[]byte) int {
   return int(C.c_api_init_vehicle_its_detector(C.int(sceneMode), C.int(modelMode), (*C.char)(unsafe.Pointer(&keyPath[0])), (*C.char)(unsafe.Pointer(&modelPath[0]))))
}
// VehicleITSDetect vehicle detect
func VehicleITSDetect(img SDKImage, rcDetect *CRECT) []CVehicleITSResult {
   data := img.Data
   w := img.Width
   h := img.Height
   var count C.int
   cppos := C.c_api_vehicle_its_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 CVehicleITSPosArrayToGoArray(unsafe.Pointer(cppos), int(count))
   }
   return nil
}
// FreeVehicleITSDetector free
func FreeVehicleITSDetector() {
   C.c_api_vehicle_its_free()
}