代码拉取完成,页面将自动刷新
同步操作将从 Cody Gu/LQ-Challenge2-PyCV 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import cv2
import argparse
import sys
import imutils
from src.shapedetect import Picture, putChineseText
from src.communicate import *
STRGLO="" #串口读取的数据
ap = argparse.ArgumentParser(
prog="Little-Quadcopter",
description="""
###################################################################################
__ _ _ _ _ ____ _ _
/ /(_) |_| |_| | ___ /___ \_ _ __ _ __| | ___ ___ _ __ | |_ ___ _ __
/ / | | __| __| |/ _ \_____ // / / | | |/ _` |/ _` |/ __/ _ \| '_ \| __/ _ \ '__|
/ /__| | |_| |_| | __/_____/ \_/ /| |_| | (_| | (_| | (_| (_) | |_) | || __/ |
\____/_|\__|\__|_|\___| \___,_\ \__,_|\__,_|\__,_|\___\___/| .__/ \__\___|_|
|_|
###################################################################################
""",
formatter_class=argparse.RawTextHelpFormatter)
ap.add_argument("-i", "--image", help="path to the input image", type=str)
ap.add_argument("-s", "--serialPort", help="serial port", type=str)
ap.add_argument("-w", "--webcam", help="start the webcam", type=int)
args = vars(ap.parse_args())
def image_opt() -> None: # 图片操作
image.drawShape(resize=500)
cv2.imshow("image", image.resized)
cv2.waitKey(0)
def frame_opt() -> None: # 视频操作
while 1:
sendData = " "
for i in range(10):
frame = Picture(webcam.read()[1])
sendData = frame.getShape(resize=300)
# serialSend(ser, sendData)
cv2.imshow("capture", frame.resized)
if cv2.waitKey(1) & 0xFF == ord('q'):
ser.close()
break
serialSend(ser, sendData)
if args["image"] is not None: # 处理图片操作
image = Picture(args["image"])
image_opt()
elif args["webcam"] is not None: # 处理视频操作
if args["serialPort"] is None:
print("no serial")
sys.exit(1)
ser,ret = serialInit(args["serialPort"])
webcam = cv2.VideoCapture(args["webcam"])
frame_opt()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。