123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- package isapi
- import (
- "encoding/json"
- "encoding/xml"
- "github.com/sirupsen/logrus"
- )
- //能力
- //http://192.168.1.64/ISAPI/Smart/LineDetection/1/capabilities
- //http://192.168.1.64/ISAPI/Smart/channels/1/calibrations/capabilities
- // LineDetectionParam 越界侦测
- type LineDetectionParam 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"`
- LineItemList struct {
- Size string `xml:"size,attr" json:"size"`
- LineItem []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" 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() (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)
- detection, _ := c.GetLineDetection()
- for i, v := range detection.LineItemList.LineItem {
- resp.LineItemList.LineItem[i].AlarmConfidence.Text = v.AlarmConfidence
- }
- return
- }
- 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) (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() (resp LineDetectionParam, err error) {
- bytes, err := c.CommonGet("/ISAPI/Smart/LineDetection/1")
- if err != nil {
- logrus.Error("请求出错", err)
- return
- }
- err = xml.Unmarshal(bytes, &resp)
- return
- }
- // PutLineDetection 配置单个通道越界侦测规则
- 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"`
- }
|