47 lines
936 B
Python
47 lines
936 B
Python
from vidgear.gears import NetGear
|
||
import cv2
|
||
import time
|
||
|
||
# 设置,这里都是消息接收的方式,直接默认就行了,不用管。
|
||
options = {
|
||
"flag": 0, "copy": False, "track": False,
|
||
# "jpeg_compression": "GRAY",
|
||
"jpeg_compression": True,
|
||
"jpeg_compression_quality": 90,
|
||
"jpeg_compression_fastdct": True,
|
||
"jpeg_compression_fastupsample": True
|
||
}
|
||
|
||
|
||
# address设置为客户端的ip,port设置为客户端的端口
|
||
client = NetGear(
|
||
address="192.168.101.46",
|
||
port="5454",
|
||
protocol="tcp",
|
||
pattern=1,
|
||
receive_mode=True,
|
||
logging=True,
|
||
**options
|
||
)
|
||
|
||
idx = 0
|
||
while True:
|
||
# 收取数据
|
||
frame = client.recv()
|
||
|
||
if frame is None:
|
||
break
|
||
|
||
cv2.imshow("Output Frame", frame)
|
||
idx += 1
|
||
if idx == 30:
|
||
print(time.time())
|
||
idx = 0
|
||
|
||
key = cv2.waitKey(1) & 0xFF
|
||
if key == ord("q"):
|
||
break
|
||
|
||
cv2.destroyAllWindows()
|
||
|
||
client.close() |