main.py 950 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import time
  2. import cv2
  3. from wvp import WvpProxy, Rtsp
  4. def row_main():
  5. rtsp = Rtsp()
  6. proxy = WvpProxy()
  7. did, cid = "34020000001320000001", "34020000001310000001"
  8. url = proxy.start(did, cid)
  9. rtsp.connect(url)
  10. for item in rtsp.read_stream(1): # 每5秒从图像流中读取一帧图像数据
  11. # item = rtsp.resize(item, 2) # 长宽压缩3倍
  12. cv2.imshow("raw", item) # 显示原图
  13. # cv2.imshow("detr", rtsp.detr(item)) # 显示检测结果
  14. cv2.waitKey(1)
  15. rtsp.close()
  16. proxy.stop(did, cid)
  17. def main():
  18. rtsp = Rtsp()
  19. proxy = WvpProxy()
  20. did, cid = "34020000001320000001", "34020000001310000001"
  21. try:
  22. url = proxy.start(did, cid)
  23. print(url)
  24. rtsp.connect(url)
  25. while True:
  26. time.sleep(60)
  27. except:
  28. rtsp.close()
  29. proxy.stop(did, cid)
  30. time.sleep(2)
  31. main()
  32. if __name__ == "__main__":
  33. main()