initial commit
This commit is contained in:
43
test_send.py
Normal file
43
test_send.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import serial_module
|
||||
import cv2
|
||||
import time
|
||||
|
||||
# 初始化串口
|
||||
serial_module.init("/dev/ttyUSB0")
|
||||
|
||||
cap = cv2.VideoCapture(0)
|
||||
|
||||
# while True:
|
||||
for _ in range(100):
|
||||
time_via = time.time()
|
||||
ret, frame = cap.read()
|
||||
frame = cv2.resize(frame, (224,224))
|
||||
cv2.imshow('frame',frame)
|
||||
frame_jpg = cv2.imencode('.jpg', frame, [int(cv2.IMWRITE_JPEG_QUALITY), 50])[1].tobytes()
|
||||
print(len(frame_jpg))
|
||||
serial_module.send(frame_jpg)
|
||||
cv2.imwrite('test_send.jpg', frame)
|
||||
# # 创建一个大小为 3.5K 的二进制数据
|
||||
# file_size = int(3.5 * 1024)
|
||||
# empty_binary_data = bytearray(file_size)
|
||||
# empty_binary_data = bytes(empty_binary_data)
|
||||
|
||||
# # 发送数据
|
||||
# serial_module.send(empty_binary_data)
|
||||
|
||||
print(time.time() - time_via)
|
||||
time.sleep(4)
|
||||
if cv2.waitKey(1) & 0xFF == ord('q'):
|
||||
break
|
||||
|
||||
# # 发送数据
|
||||
# data = b"Your binary data here" # 替换为你的二进制数据
|
||||
# serial_module.send(data)
|
||||
|
||||
# # 接收数据
|
||||
# result = serial_module.receive()
|
||||
# if result:
|
||||
# frame_number, pdu, rssi = result
|
||||
# print(f"Frame Number: {frame_number}")
|
||||
# print(f"PDU: {pdu}")
|
||||
# print(f"RSSI: {rssi}")
|
||||
Reference in New Issue
Block a user