用kafka接收消息
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 2 gadiem
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import cv2
  2. import base64
  3. import io,os,sys
  4. sys.path.append('/home/thsw2/WJ/src/yolov5/utils')
  5. from get_offline_url import update_websource_offAndLive
  6. import requests
  7. import time,json
  8. import string,random
  9. def SendPost(txtSource):
  10. api = 'http://212.129.223.66:8888/detector'
  11. filename='THWangJin'
  12. for info in txtSource:
  13. input_ ={
  14. 'imgData':'',
  15. 'imgName':filename
  16. }
  17. if 'live' in info['name']:
  18. input_['outSource'] = "rtmp://127.0.0.1:%s/live/test"%(info['port'])
  19. else:
  20. input_['outSource'] = None
  21. input_['inSource'] = info['url']
  22. input_['streamName'] = info['name']
  23. time0=time.time()
  24. response=requests.post(api,json=input_).json()
  25. time1=time.time()
  26. print('###source_query:',response,'time:%.3f s'%(time1-time0))
  27. if 'live' in info['name']:
  28. print('#####process online video stream######')
  29. break
  30. def getLogFp(pollLogFile):
  31. #print(pollLogFile)
  32. #print(os.path.pardir(pollLogFile))
  33. if not os.path.exists(pollLogFile):
  34. os.makedirs(os.path.dirname(pollLogFile),exist_ok=True)
  35. fp_log = open(pollLogFile,'w')
  36. else:
  37. fp_log = open(pollLogFile,'a+')
  38. return fp_log
  39. if __name__=='__main__':
  40. ##建立日志文件
  41. pollLogFile='logs/poll/poll.txt'
  42. fp_log = getLogFp(pollLogFile)
  43. platform_query_url='http://47.96.182.154:9051/api/suanfa/getPlatformInfo'
  44. sourceFile='/home/thsw2/WJ/src/yolov5/config/source.txt'
  45. offlineFile='/home/thsw2/WJ/src/yolov5/mintors/offlines/doneCodes.txt'
  46. txtSource=update_websource_offAndLive(platform_query_url,sourceFile,offlineFile)
  47. txtSource=[
  48. #{'url': 'rtmp://demoplay.yunhengzhizao.cn/live/THSA_HD5M', 'port': '1935', 'name': 'live-THSAHD5M'}]
  49. {'url': 'http://images.5gai.taauav.com/video/DJI_20220111115516_0001_ZBJ.MP4', 'port': '1935', 'name': 'off-202202190001'},
  50. {'url': 'http://images.5gai.taauav.com/video/8bc32984dd893930dabb2856eb92b4d1.mp4', 'port': '1935', 'name': 'off-202202190002'},
  51. {'url': 'http://images.5gai.taauav.com/video/DJI_20220110145546_0003_W.MP4', 'port': '1935', 'name': 'off-202202190002'}
  52. ]
  53. print(txtSource)
  54. SendPost(txtSource)