isapi_smart_regionEntrance.go 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. package isapi
  2. import (
  3. "encoding/json"
  4. "encoding/xml"
  5. "fmt"
  6. "github.com/sirupsen/logrus"
  7. )
  8. // RegionEntrance 进入区域
  9. type RegionEntranceParam struct {
  10. ID string `xml:"id" json:"id"`
  11. Enabled string `xml:"enabled" json:"enabled"`
  12. NormalizedScreenSize struct {
  13. NormalizedScreenWidth string `xml:"normalizedScreenWidth" json:"normalizedScreenWidth"`
  14. NormalizedScreenHeight string `xml:"normalizedScreenHeight" json:"normalizedScreenHeight"`
  15. } `xml:"normalizedScreenSize" json:"normalizedScreenSize"`
  16. RegionEntranceRegionList struct {
  17. Size string `xml:"size,attr" json:"size"`
  18. RegionEntranceRegion []struct {
  19. ID string `xml:"id" json:"id"`
  20. SensitivityLevel string `xml:"sensitivityLevel" json:"sensitivityLevel"`
  21. DetectionTarget string `xml:"detectionTarget" json:"detectionTarget"`
  22. AlarmConfidence string `xml:"alarmConfidence" json:"alarmConfidence"`
  23. RegionCoordinatesList struct {
  24. RegionCoordinates []struct {
  25. PositionX string `xml:"positionX" json:"positionX"`
  26. PositionY string `xml:"positionY" json:"positionY"`
  27. } `xml:"RegionCoordinates" json:"RegionCoordinates"`
  28. } `xml:"RegionCoordinatesList" json:"RegionCoordinatesList"`
  29. } `xml:"RegionEntranceRegion" json:"RegionEntranceRegion"`
  30. } `xml:"RegionEntranceRegionList" json:"RegionEntranceRegionList"`
  31. IsSupportMultiScene string `xml:"isSupportMultiScene" json:"isSupportMultiScene"`
  32. IsSupportHumanMisinfoFilter string `xml:"isSupportHumanMisinfoFilter" json:"isSupportHumanMisinfoFilter"`
  33. IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter" json:"isSupportVehicleMisinfoFilter"`
  34. IsSupportTargetMultiSelect string `xml:"isSupportTargetMultiSelect" json:"isSupportTargetMultiSelect"`
  35. }
  36. // GetRegionEntranceCap 获取区域入口上限
  37. func (c *Client) GetRegionEntranceCap() (resp RegionEntranceCap, err error) {
  38. bytes, err := c.CommonGet("/ISAPI/Smart/regionEntrance/1/capabilities")
  39. if err != nil {
  40. logrus.Error("请求出错", err)
  41. return
  42. }
  43. err = xml.Unmarshal(bytes, &resp)
  44. return
  45. }
  46. // GetSizeRe 获取尺寸大小
  47. func (c *Client) GetSizeRe() (resp SmartCalibrationList, err error) {
  48. bytes, err := c.CommonGet("/ISAPI/Smart/channels/1/calibrations/regionEntrance")
  49. if err != nil {
  50. logrus.Error("请求出错", err)
  51. return
  52. }
  53. err = xml.Unmarshal(bytes, &resp)
  54. return
  55. }
  56. // PutSizeRe 配置尺寸大小
  57. func (c *Client) PutSizeRe(data []byte) (resp ResponseStatus, err error) {
  58. var info SmartCalibrationList
  59. err = json.Unmarshal(data, &info)
  60. if err != nil {
  61. logrus.Error(err)
  62. return ResponseStatus{}, err
  63. }
  64. marshal, err := xml.Marshal(info)
  65. if err != nil {
  66. logrus.Error(err)
  67. return ResponseStatus{}, err
  68. }
  69. respData, err := c.CommonPut(marshal, "/ISAPI/Smart/channels/1/calibrations/regionEntrance")
  70. if err != nil {
  71. logrus.Error(err)
  72. return ResponseStatus{}, err
  73. }
  74. err = xml.Unmarshal(respData, &resp)
  75. if err != nil {
  76. logrus.Error(err)
  77. return ResponseStatus{}, err
  78. }
  79. return
  80. }
  81. // GetRegionEntrance 获取区域侦测参数
  82. func (c *Client) GetRegionEntrance() (resp RegionEntranceParam, err error) {
  83. bytes, err := c.CommonGet("/ISAPI/Smart/regionEntrance/1")
  84. if err != nil {
  85. logrus.Error("请求出错", err)
  86. return
  87. }
  88. err = xml.Unmarshal(bytes, &resp)
  89. marshal, err := json.Marshal(resp)
  90. if err != nil {
  91. logrus.Error("请求出错", err)
  92. return
  93. }
  94. fmt.Println("json数据:", string(marshal))
  95. return
  96. }
  97. // PutRegionEntrance 配置区域侦测参数
  98. func (c *Client) PutRegionEntrance(data []byte) (resp ResponseStatus, err error) {
  99. var info RegionEntranceParam
  100. err = json.Unmarshal(data, &info)
  101. if err != nil {
  102. logrus.Error(err)
  103. return ResponseStatus{}, err
  104. }
  105. marshal, err := xml.Marshal(info)
  106. if err != nil {
  107. logrus.Error(err)
  108. return ResponseStatus{}, err
  109. }
  110. respData, err := c.CommonPut(marshal, "/ISAPI/Smart/regionEntrance/1")
  111. if err != nil {
  112. logrus.Error(err)
  113. return ResponseStatus{}, err
  114. }
  115. err = xml.Unmarshal(respData, &resp)
  116. if err != nil {
  117. logrus.Error(err)
  118. return ResponseStatus{}, err
  119. }
  120. return
  121. }
  122. type RegionEntranceCap struct {
  123. ID string `xml:"id"`
  124. Enabled struct {
  125. Text string `xml:",chardata" json:"value"`
  126. Opt string `xml:"opt,attr" json:"opt"`
  127. } `xml:"enabled" json:"enabled"`
  128. NormalizedScreenSize struct {
  129. NormalizedScreenWidth string `xml:"normalizedScreenWidth" json:"normalizedScreenWidth"`
  130. NormalizedScreenHeight string `xml:"normalizedScreenHeight" json:"normalizedScreenHeight"`
  131. } `xml:"normalizedScreenSize" json:"normalizedScreenSize"`
  132. RegionEntranceRegionList struct {
  133. Size string `xml:"size,attr" json:"size"`
  134. RegionEntranceRegion []struct {
  135. ID string `xml:"id" json:"id"`
  136. SensitivityLevel struct {
  137. Text string `xml:",chardata" json:"value"`
  138. Min string `xml:"min,attr" json:"min"`
  139. Max string `xml:"max,attr" json:"max"`
  140. } `xml:"sensitivityLevel" json:"sensitivityLevel"`
  141. RegionCoordinatesList struct {
  142. RegionCoordinates []struct {
  143. PositionX string `xml:"positionX" json:"positionX"`
  144. PositionY string `xml:"positionY" json:"positionY"`
  145. } `xml:"RegionCoordinates" json:"RegionCoordinates"`
  146. } `xml:"RegionCoordinatesList" json:"RegionCoordinatesList"`
  147. MinRegionCoordinatesNum string `xml:"minRegionCoordinatesNum" json:"minRegionCoordinatesNum"`
  148. MaxRegionCoordinatesNum string `xml:"maxRegionCoordinatesNum" json:"maxRegionCoordinatesNum"`
  149. DetectionTarget struct {
  150. Text string `xml:",chardata" json:"value"`
  151. Opt string `xml:"opt,attr" json:"opt"`
  152. } `xml:"detectionTarget" json:"detectionTarget"`
  153. AlarmConfidence struct {
  154. Text string `xml:",chardata" json:"value"`
  155. Opt string `xml:"opt,attr" json:"opt"`
  156. Def string `xml:"def,attr" json:"def"`
  157. } `xml:"alarmConfidence" json:"alarmConfidence"`
  158. } `xml:"RegionEntranceRegion" json:"RegionEntranceRegion"`
  159. } `xml:"RegionEntranceRegionList" json:"RegionEntranceRegionList"`
  160. IsSupportMultiScene string `xml:"isSupportMultiScene" json:"isSupportMultiScene"`
  161. IsSupportHumanMisinfoFilter string `xml:"isSupportHumanMisinfoFilter" json:"isSupportHumanMisinfoFilter"`
  162. IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter" json:"isSupportVehicleMisinfoFilter"`
  163. IsSupportTargetMultiSelect string `xml:"isSupportTargetMultiSelect" json:"isSupportTargetMultiSelect"`
  164. IsSupportAllDayUpload string `xml:"isSupportAllDayUpload" json:"isSupportAllDayUpload"`
  165. }