package isapi import ( "encoding/json" "encoding/xml" "fmt" "github.com/sirupsen/logrus" ) // RegionEntrance 进入区域 type RegionEntranceParam struct { ID string `xml:"id" json:"id"` Enabled string `xml:"enabled" json:"enabled"` NormalizedScreenSize struct { NormalizedScreenWidth string `xml:"normalizedScreenWidth" json:"normalizedScreenWidth"` NormalizedScreenHeight string `xml:"normalizedScreenHeight" json:"normalizedScreenHeight"` } `xml:"normalizedScreenSize" json:"normalizedScreenSize"` RegionEntranceRegionList struct { Size string `xml:"size,attr" json:"size"` RegionEntranceRegion []struct { ID string `xml:"id" json:"id"` SensitivityLevel string `xml:"sensitivityLevel" json:"sensitivityLevel"` DetectionTarget string `xml:"detectionTarget" json:"detectionTarget"` AlarmConfidence string `xml:"alarmConfidence" json:"alarmConfidence"` RegionCoordinatesList struct { RegionCoordinates []struct { PositionX string `xml:"positionX" json:"positionX"` PositionY string `xml:"positionY" json:"positionY"` } `xml:"RegionCoordinates" json:"RegionCoordinates"` } `xml:"RegionCoordinatesList" json:"RegionCoordinatesList"` } `xml:"RegionEntranceRegion" json:"RegionEntranceRegion"` } `xml:"RegionEntranceRegionList" json:"RegionEntranceRegionList"` IsSupportMultiScene string `xml:"isSupportMultiScene" json:"isSupportMultiScene"` IsSupportHumanMisinfoFilter string `xml:"isSupportHumanMisinfoFilter" json:"isSupportHumanMisinfoFilter"` IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter" json:"isSupportVehicleMisinfoFilter"` IsSupportTargetMultiSelect string `xml:"isSupportTargetMultiSelect" json:"isSupportTargetMultiSelect"` } // GetRegionEntranceCap 获取区域入口上限 func (c *Client) GetRegionEntranceCap() (resp RegionEntranceCap, err error) { bytes, err := c.CommonGet("/ISAPI/Smart/regionEntrance/1/capabilities") if err != nil { logrus.Error("请求出错", err) return } err = xml.Unmarshal(bytes, &resp) return } // GetSizeRe 获取尺寸大小 func (c *Client) GetSizeRe() (resp SmartCalibrationList, err error) { bytes, err := c.CommonGet("/ISAPI/Smart/channels/1/calibrations/regionEntrance") if err != nil { logrus.Error("请求出错", err) return } err = xml.Unmarshal(bytes, &resp) return } // PutSizeRe 配置尺寸大小 func (c *Client) PutSizeRe(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/regionEntrance") if err != nil { logrus.Error(err) return ResponseStatus{}, err } err = xml.Unmarshal(respData, &resp) if err != nil { logrus.Error(err) return ResponseStatus{}, err } return } // GetRegionEntrance 获取区域侦测参数 func (c *Client) GetRegionEntrance() (resp RegionEntranceParam, err error) { bytes, err := c.CommonGet("/ISAPI/Smart/regionEntrance/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 } // PutRegionEntrance 配置区域侦测参数 func (c *Client) PutRegionEntrance(data []byte) (resp ResponseStatus, err error) { var info RegionEntranceParam 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/regionEntrance/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 RegionEntranceCap struct { ID string `xml:"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"` RegionEntranceRegionList struct { Size string `xml:"size,attr" json:"size"` RegionEntranceRegion []struct { ID string `xml:"id" json:"id"` 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"` RegionCoordinatesList struct { RegionCoordinates []struct { PositionX string `xml:"positionX" json:"positionX"` PositionY string `xml:"positionY" json:"positionY"` } `xml:"RegionCoordinates" json:"RegionCoordinates"` } `xml:"RegionCoordinatesList" json:"RegionCoordinatesList"` MinRegionCoordinatesNum string `xml:"minRegionCoordinatesNum" json:"minRegionCoordinatesNum"` MaxRegionCoordinatesNum string `xml:"maxRegionCoordinatesNum" json:"maxRegionCoordinatesNum"` 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:"RegionEntranceRegion" json:"RegionEntranceRegion"` } `xml:"RegionEntranceRegionList" json:"RegionEntranceRegionList"` IsSupportMultiScene string `xml:"isSupportMultiScene" json:"isSupportMultiScene"` IsSupportHumanMisinfoFilter string `xml:"isSupportHumanMisinfoFilter" json:"isSupportHumanMisinfoFilter"` IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter" json:"isSupportVehicleMisinfoFilter"` IsSupportTargetMultiSelect string `xml:"isSupportTargetMultiSelect" json:"isSupportTargetMultiSelect"` IsSupportAllDayUpload string `xml:"isSupportAllDayUpload" json:"isSupportAllDayUpload"` }