|
@@ -1,59 +1,184 @@
|
|
|
package isapi
|
|
|
|
|
|
+import (
|
|
|
+ "encoding/json"
|
|
|
+ "encoding/xml"
|
|
|
+ "fmt"
|
|
|
+ "github.com/sirupsen/logrus"
|
|
|
+)
|
|
|
+
|
|
|
//能力
|
|
|
//http://192.168.110.165/ISAPI/Smart/LineDetection/1/capabilities
|
|
|
//http://192.168.110.165/ISAPI/Smart/channels/1/calibrations/capabilities
|
|
|
|
|
|
// LineDetection 越界侦测
|
|
|
-type LineDetection struct {
|
|
|
- ID string `xml:"id"`
|
|
|
- Enabled string `xml:"enabled"`
|
|
|
+type LineDetectionParam struct {
|
|
|
+ ID string `xml:"id" json:"id"`
|
|
|
+ Enabled string `xml:"enabled" json:"enabled"`
|
|
|
NormalizedScreenSize struct {
|
|
|
- NormalizedScreenWidth string `xml:"normalizedScreenWidth"`
|
|
|
- NormalizedScreenHeight string `xml:"normalizedScreenHeight"`
|
|
|
- } `xml:"normalizedScreenSize"`
|
|
|
+ NormalizedScreenWidth string `xml:"normalizedScreenWidth" json:"normalizedScreenWidth"`
|
|
|
+ NormalizedScreenHeight string `xml:"normalizedScreenHeight" json:"normalizedScreenHeight"`
|
|
|
+ } `xml:"normalizedScreenSize" json:"normalizedScreenSize"`
|
|
|
LineItemList struct {
|
|
|
- Size string `xml:"size,attr"`
|
|
|
+ Size string `xml:"size,attr" json:"size"`
|
|
|
LineItem []struct {
|
|
|
- ID string `xml:"id"`
|
|
|
- Enabled string `xml:"enabled"`
|
|
|
- SensitivityLevel string `xml:"sensitivityLevel"`
|
|
|
- DirectionSensitivity string `xml:"directionSensitivity"`
|
|
|
- DetectionTarget string `xml:"detectionTarget"`
|
|
|
- AlarmConfidence struct {
|
|
|
- Text string `xml:",chardata"`
|
|
|
- Opt string `xml:"opt,attr"`
|
|
|
- } `xml:"alarmConfidence"`
|
|
|
- CoordinatesList struct {
|
|
|
+ ID string `xml:"id" json:"id"`
|
|
|
+ Enabled string `xml:"enabled" json:"enabled"`
|
|
|
+ SensitivityLevel string `xml:"sensitivityLevel" json:"sensitivityLevel"`
|
|
|
+ DirectionSensitivity string `xml:"directionSensitivity"json:"directionSensitivity"`
|
|
|
+ DetectionTarget string `xml:"detectionTarget" json:"detectionTarget"`
|
|
|
+ AlarmConfidence string `xml:"alarmConfidence" json:"alarmConfidence"`
|
|
|
+ CoordinatesList struct {
|
|
|
Coordinates []struct {
|
|
|
- PositionX string `xml:"positionX"`
|
|
|
- PositionY string `xml:"positionY"`
|
|
|
- } `xml:"Coordinates"`
|
|
|
- } `xml:"CoordinatesList"`
|
|
|
- } `xml:"LineItem"`
|
|
|
- } `xml:"LineItemList"`
|
|
|
- IsSupportMultiScene string `xml:"isSupportMultiScene"`
|
|
|
- RecogRuleType string `xml:"recogRuleType"`
|
|
|
+ PositionX string `xml:"positionX" json:"positionX"`
|
|
|
+ PositionY string `xml:"positionY" json:"positionY"`
|
|
|
+ } `xml:"Coordinates" json:"Coordinates"`
|
|
|
+ } `xml:"CoordinatesList" json:"CoordinatesList"`
|
|
|
+ } `xml:"LineItem" json:"LineItem"`
|
|
|
+ } `xml:"LineItemList" json:"LineItemList"`
|
|
|
+ IsSupportMultiScene string `xml:"isSupportMultiScene" json:"isSupportMultiScene"`
|
|
|
+ RecogRuleType string `xml:"recogRuleType" json:"recogRuleType"`
|
|
|
}
|
|
|
|
|
|
-func (c *Client) GetLineDetectionCap() ([]byte, error) {
|
|
|
- return c.CommonGet("/ISAPI/Smart/LineDetection/1/capabilities")
|
|
|
+// GetLineDetectionCap 获取单个通道越界侦测上限
|
|
|
+func (c *Client) GetLineDetectionCap() (resp LineDetectionCap, err error) {
|
|
|
+ bytes, err := c.CommonGet("/ISAPI/Smart/LineDetection/1/capabilities")
|
|
|
+ if err != nil {
|
|
|
+ logrus.Error("请求出错", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = xml.Unmarshal(bytes, &resp)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
-func (c *Client) GetSizeLd() ([]byte, error) {
|
|
|
- return c.CommonGet("/ISAPI/Smart/channels/1/calibrations/linedetection")
|
|
|
+// GetSizeLd 获取尺寸大小
|
|
|
+func (c *Client) GetSizeLd() (resp SmartCalibrationList, err error) {
|
|
|
+ bytes, err := c.CommonGet("/ISAPI/Smart/channels/1/calibrations/linedetection")
|
|
|
+ if err != nil {
|
|
|
+ logrus.Error("请求出错", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = xml.Unmarshal(bytes, &resp)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
-func (c *Client) PutSizeLd(data []byte) ([]byte, error) {
|
|
|
- return c.CommonPut(data, "/ISAPI/Smart/channels/1/calibrations/linedetection")
|
|
|
+// PutSizeLd 配置尺寸大小
|
|
|
+func (c *Client) PutSizeLd(data []byte) (resp ResponseStatus, err error) {
|
|
|
+ var info SmartCalibrationList
|
|
|
+ err = json.Unmarshal(data, &info)
|
|
|
+ if err != nil {
|
|
|
+ logrus.Error(err)
|
|
|
+ return ResponseStatus{}, err
|
|
|
+ }
|
|
|
+ marshal, err := xml.Marshal(info)
|
|
|
+ if err != nil {
|
|
|
+ logrus.Error(err)
|
|
|
+ return ResponseStatus{}, err
|
|
|
+ }
|
|
|
+ respData, err := c.CommonPut(marshal, "/ISAPI/Smart/channels/1/calibrations/linedetection")
|
|
|
+ if err != nil {
|
|
|
+ logrus.Error(err)
|
|
|
+ return ResponseStatus{}, err
|
|
|
+ }
|
|
|
+ err = xml.Unmarshal(respData, &resp)
|
|
|
+ if err != nil {
|
|
|
+ logrus.Error(err)
|
|
|
+ return ResponseStatus{}, err
|
|
|
+ }
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
// GetLineDetection 获取单个通道越界侦测规则
|
|
|
-func (c *Client) GetLineDetection() ([]byte, error) {
|
|
|
- return c.CommonGet("/ISAPI/Smart/LineDetection/1")
|
|
|
+func (c *Client) GetLineDetection() (resp LineDetectionParam, err error) {
|
|
|
+ bytes, err := c.CommonGet("/ISAPI/Smart/LineDetection/1")
|
|
|
+ if err != nil {
|
|
|
+ logrus.Error("请求出错", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = xml.Unmarshal(bytes, &resp)
|
|
|
+ marshal, err := json.Marshal(resp)
|
|
|
+ if err != nil {
|
|
|
+ logrus.Error("请求出错", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fmt.Println("json数据:", string(marshal))
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
// PutLineDetection 配置单个通道越界侦测规则
|
|
|
-func (c *Client) PutLineDetection(data []byte) ([]byte, error) {
|
|
|
- return c.CommonPut(data, "/ISAPI/Smart/LineDetection/1")
|
|
|
+func (c *Client) PutLineDetection(data []byte) (resp ResponseStatus, err error) {
|
|
|
+ var info LineDetectionParam
|
|
|
+ err = json.Unmarshal(data, &info)
|
|
|
+ if err != nil {
|
|
|
+ logrus.Error(err)
|
|
|
+ return ResponseStatus{}, err
|
|
|
+ }
|
|
|
+ marshal, err := xml.Marshal(info)
|
|
|
+ if err != nil {
|
|
|
+ logrus.Error(err)
|
|
|
+ return ResponseStatus{}, err
|
|
|
+ }
|
|
|
+ respData, err := c.CommonPut(marshal, "/ISAPI/Smart/LineDetection/1")
|
|
|
+ if err != nil {
|
|
|
+ logrus.Error(err)
|
|
|
+ return ResponseStatus{}, err
|
|
|
+ }
|
|
|
+ err = xml.Unmarshal(respData, &resp)
|
|
|
+ if err != nil {
|
|
|
+ logrus.Error(err)
|
|
|
+ return ResponseStatus{}, err
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+type LineDetectionCap struct {
|
|
|
+ ID string `xml:"id" json:"id"`
|
|
|
+ Enabled struct {
|
|
|
+ Text string `xml:",chardata" json:"value"`
|
|
|
+ Opt string `xml:"opt,attr" json:"opt"`
|
|
|
+ } `xml:"enabled" json:"enabled"`
|
|
|
+ NormalizedScreenSize struct {
|
|
|
+ NormalizedScreenWidth string `xml:"normalizedScreenWidth" json:"normalizedScreenWidth"`
|
|
|
+ NormalizedScreenHeight string `xml:"normalizedScreenHeight" json:"normalizedScreenHeight"`
|
|
|
+ } `xml:"normalizedScreenSize" json:"normalizedScreenSize"`
|
|
|
+ LineItemList struct {
|
|
|
+ Size string `xml:"size,attr" json:"size"`
|
|
|
+ LineItem []struct {
|
|
|
+ ID string `xml:"id" json:"id"`
|
|
|
+ Enabled struct {
|
|
|
+ Text string `xml:",chardata" json:"value"`
|
|
|
+ Opt string `xml:"opt,attr" json:"opt"`
|
|
|
+ } `xml:"enabled" json:"enabled"`
|
|
|
+ SensitivityLevel struct {
|
|
|
+ Text string `xml:",chardata" json:"value"`
|
|
|
+ Min string `xml:"min,attr" json:"min"`
|
|
|
+ Max string `xml:"max,attr" json:"max"`
|
|
|
+ } `xml:"sensitivityLevel" json:"sensitivityLevel"`
|
|
|
+ DirectionSensitivity struct {
|
|
|
+ Text string `xml:",chardata" json:"value"`
|
|
|
+ Opt string `xml:"opt,attr" json:"opt"`
|
|
|
+ } `xml:"directionSensitivity" json:"directionSensitivity"`
|
|
|
+ CoordinatesList struct {
|
|
|
+ Coordinates []struct {
|
|
|
+ PositionX string `xml:"positionX" json:"positionX"`
|
|
|
+ PositionY string `xml:"positionY" json:"positionY"`
|
|
|
+ } `xml:"Coordinates" json:"Coordinates"`
|
|
|
+ } `xml:"CoordinatesList" json:"CoordinatesList"`
|
|
|
+ DetectionTarget struct {
|
|
|
+ Text string `xml:",chardata" json:"value"`
|
|
|
+ Opt string `xml:"opt,attr" json:"opt"`
|
|
|
+ } `xml:"detectionTarget" json:"detectionTarget"`
|
|
|
+ AlarmConfidence struct {
|
|
|
+ Text string `xml:",chardata" json:"value"`
|
|
|
+ Opt string `xml:"opt,attr" json:"opt"`
|
|
|
+ Def string `xml:"def,attr" json:"def"`
|
|
|
+ } `xml:"alarmConfidence" json:"alarmConfidence"`
|
|
|
+ } `xml:"LineItem" json:"LineItem"`
|
|
|
+ } `xml:"LineItemList" json:"LineItemList"`
|
|
|
+ IsSupportMultiScene string `xml:"isSupportMultiScene" json:"isSupportMultiScene"`
|
|
|
+ RecogRuleType string `xml:"recogRuleType" json:"recogRuleType"`
|
|
|
+ IsSupportHumanMisinfoFilter string `xml:"isSupportHumanMisinfoFilter" json:"isSupportHumanMisinfoFilter"`
|
|
|
+ IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter" json:"isSupportVehicleMisinfoFilter"`
|
|
|
+ IsSupportTargetMultiSelect string `xml:"isSupportTargetMultiSelect" json:"isSupportTargetMultiSelect"`
|
|
|
+ IsSupportAllDayUpload string `xml:"isSupportAllDayUpload" json:"isSupportAllDayUpload"`
|
|
|
}
|