|
@@ -1,68 +1,177 @@
|
|
|
package isapi
|
|
|
|
|
|
import (
|
|
|
+ "encoding/json"
|
|
|
"encoding/xml"
|
|
|
+ "fmt"
|
|
|
+ "github.com/sirupsen/logrus"
|
|
|
)
|
|
|
|
|
|
//能力
|
|
|
//http://192.168.1.64/ISAPI/Smart/FieldDetection/1/capabilities
|
|
|
//http://192.168.1.64/ISAPI/Smart/channels/1/calibrations/capabilities
|
|
|
|
|
|
-// FieldDetection 区域入侵
|
|
|
-type FieldDetection struct {
|
|
|
- XMLName xml.Name `xml:"FieldDetection"`
|
|
|
- Xmlns string `xml:"xmlns,attr"`
|
|
|
- Version string `xml:"version,attr"`
|
|
|
- ID string `xml:"id"`
|
|
|
- Enabled string `xml:"enabled"`
|
|
|
- StartTriggerTime string `xml:"startTriggerTime"`
|
|
|
- EndTriggerTime string `xml:"endTriggerTime"`
|
|
|
+// FieldDetectionCap 区域入侵参数能力
|
|
|
+type FieldDetectionCap struct {
|
|
|
+ ID string `xml:"id" json:"id"`
|
|
|
+ Enabled struct {
|
|
|
+ Text string `xml:",chardata" json:"value"`
|
|
|
+ Opt string `xml:"opt,attr" json:"opt"`
|
|
|
+ } `xml:"enabled"`
|
|
|
NormalizedScreenSize struct {
|
|
|
- NormalizedScreenWidth string `xml:"normalizedScreenWidth"`
|
|
|
- NormalizedScreenHeight string `xml:"normalizedScreenHeight"`
|
|
|
- } `xml:"normalizedScreenSize"`
|
|
|
+ NormalizedScreenWidth string `xml:"normalizedScreenWidth" json:"normalized_screen_width"`
|
|
|
+ NormalizedScreenHeight string `xml:"normalizedScreenHeight" json:"normalized_screen_height"`
|
|
|
+ } `xml:"normalizedScreenSize" json:"normalizedScreenSize"`
|
|
|
FieldDetectionRegionList struct {
|
|
|
- Size string `xml:"size,attr"`
|
|
|
+ Size string `xml:"size,attr" json:"size"`
|
|
|
FieldDetectionRegion []struct {
|
|
|
- ID string `xml:"id"`
|
|
|
- Enabled string `xml:"enabled"`
|
|
|
- SensitivityLevel string `xml:"sensitivityLevel"`
|
|
|
- TimeThreshold string `xml:"timeThreshold"`
|
|
|
- DetectionTarget string `xml:"detectionTarget"`
|
|
|
- AlarmConfidence struct {
|
|
|
- Opt string `xml:"opt,attr"`
|
|
|
- } `xml:"alarmConfidence"`
|
|
|
- RegionCoordinatesList struct {
|
|
|
- RegionCoordinates []struct {
|
|
|
- PositionX string `xml:"positionX"`
|
|
|
- PositionY string `xml:"positionY"`
|
|
|
- } `xml:"RegionCoordinates"`
|
|
|
- } `xml:"RegionCoordinatesList"`
|
|
|
- } `xml:"FieldDetectionRegion"`
|
|
|
- } `xml:"FieldDetectionRegionList"`
|
|
|
- IsSupportMultiScene string `xml:"isSupportMultiScene"`
|
|
|
- IsSupportHumanMisinfoFilter string `xml:"isSupportHumanMisinfoFilter"`
|
|
|
- IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter"`
|
|
|
+ ID string `xml:"id" json:"id"`
|
|
|
+ MinRegionCoordinatesNum string `xml:"minRegionCoordinatesNum" json:"minRegionCoordinatesNum"`
|
|
|
+ MaxRegionCoordinatesNum string `xml:"maxRegionCoordinatesNum" json:"maxRegionCoordinatesNum"`
|
|
|
+ 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"`
|
|
|
+ TimeThreshold struct {
|
|
|
+ Text string `xml:",chardata" json:"value"`
|
|
|
+ Min string `xml:"min,attr" json:"min"`
|
|
|
+ Max string `xml:"max,attr" json:"max"`
|
|
|
+ } `xml:"timeThreshold" json:"timeThreshold"`
|
|
|
+ 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:"FieldDetectionRegion" json:"FieldDetectionRegion"`
|
|
|
+ } `xml:"FieldDetectionRegionList" json:"FieldDetectionRegionList"`
|
|
|
+ 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"`
|
|
|
}
|
|
|
|
|
|
-func (c *Client) GetFieldDetectionCap() ([]byte, error) {
|
|
|
- return c.CommonGet("/ISAPI/Smart/FieldDetection/1/capabilities")
|
|
|
+func (c *Client) GetFieldDetectionCap() (resp FieldDetectionCap, err error) {
|
|
|
+ bytes, err := c.CommonGet("/ISAPI/Smart/FieldDetection/1/capabilities")
|
|
|
+ if err != nil {
|
|
|
+ logrus.Error("请求出错", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = xml.Unmarshal(bytes, &resp)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
-func (c *Client) GetSizeFd() ([]byte, error) {
|
|
|
- return c.CommonGet("/ISAPI/Smart/channels/1/calibrations/FieldDetection")
|
|
|
+func (c *Client) GetSizeFd() (resp SmartCalibrationList, err error) {
|
|
|
+ bytes, err := c.CommonGet("/ISAPI/Smart/channels/1/calibrations/FieldDetection")
|
|
|
+ if err != nil {
|
|
|
+ logrus.Error("请求出错", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = xml.Unmarshal(bytes, &resp)
|
|
|
+ fmt.Printf("%+v\n", string(bytes))
|
|
|
+ fmt.Printf("%+v\n", resp)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
-func (c *Client) PutSizeFd(data []byte) ([]byte, error) {
|
|
|
- return c.CommonPut(data, "/ISAPI/Smart/channels/1/calibrations/FieldDetection")
|
|
|
+func (c *Client) PutSizeFd(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/FieldDetection")
|
|
|
+ if err != nil {
|
|
|
+ logrus.Error(err)
|
|
|
+ return ResponseStatus{}, err
|
|
|
+ }
|
|
|
+ err = xml.Unmarshal(respData, &resp)
|
|
|
+ if err != nil {
|
|
|
+ logrus.Error(err)
|
|
|
+ return ResponseStatus{}, err
|
|
|
+ }
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
// PutFieldDetection 设置区域入侵报警区域
|
|
|
-func (c *Client) PutFieldDetection(data []byte) ([]byte, error) {
|
|
|
- return c.CommonPut(data, "/ISAPI/Smart/FieldDetection/1")
|
|
|
+func (c *Client) PutFieldDetection(data []byte) (resp ResponseStatus, err error) {
|
|
|
+ var info FieldDetectionParam
|
|
|
+ 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/FieldDetection/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
|
|
|
}
|
|
|
|
|
|
// GetFieldDetection 获取报警区域
|
|
|
-func (c *Client) GetFieldDetection() ([]byte, error) {
|
|
|
- return c.CommonGet("/ISAPI/Smart/FieldDetection/1")
|
|
|
+func (c *Client) GetFieldDetection() (resp FieldDetectionParam, err error) {
|
|
|
+ bytes, err := c.CommonGet("/ISAPI/Smart/FieldDetection/1")
|
|
|
+ if err != nil {
|
|
|
+ logrus.Error("请求出错", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = xml.Unmarshal(bytes, &resp)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// FieldDetectionParam 查询,配置 进入区域参数
|
|
|
+type FieldDetectionParam 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"`
|
|
|
+ FieldDetectionRegionList struct {
|
|
|
+ Size string `xml:"size,attr" json:"size"`
|
|
|
+ FieldDetectionRegion []struct {
|
|
|
+ ID string `xml:"id" json:"id"`
|
|
|
+ Enabled string `xml:"enabled" json:"enabled"`
|
|
|
+ SensitivityLevel string `xml:"sensitivityLevel" json:"sensitivityLevel"`
|
|
|
+ TimeThreshold string `xml:"timeThreshold" json:"timeThreshold"`
|
|
|
+ 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:"FieldDetectionRegion" json:"FieldDetectionRegion"`
|
|
|
+ } `xml:"FieldDetectionRegionList" json:"FieldDetectionRegionList"`
|
|
|
+ IsSupportMultiScene string `xml:"isSupportMultiScene" json:"isSupportMultiScene"`
|
|
|
+ IsSupportHumanMisinfoFilter string `xml:"isSupportHumanMisinfoFilter" json:"isSupportHumanMisinfoFilter"`
|
|
|
+ IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter" json:"isSupportVehicleMisinfoFilter"`
|
|
|
}
|