lidar_camera_cablition/vidgear_client.py
2024-12-16 12:30:52 +08:00

47 lines
936 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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设置为客户端的ipport设置为客户端的端口
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()