Compare commits
No commits in common. "3d50b69c1f259a20e07cfdba174b6fd0950cee63" and "f80c02e9232240cc64216891a3709a451fd2271c" have entirely different histories.
3d50b69c1f
...
f80c02e923
|
@ -2,13 +2,10 @@
|
||||||
|
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
import os.path
|
import os.path
|
||||||
import time
|
|
||||||
|
|
||||||
# First the window layout in 2 columns
|
# First the window layout in 2 columns
|
||||||
sg.theme('DarkAmber') # Add a touch of color
|
sg.theme('DarkAmber') # Add a touch of color
|
||||||
|
|
||||||
menu_def = [['Panel'], ['Debug']]
|
|
||||||
|
|
||||||
panel_view_column = [
|
panel_view_column = [
|
||||||
[
|
[
|
||||||
sg.Text("字符识别结果:", font=("微软雅黑", 20), size=(23, 1))
|
sg.Text("字符识别结果:", font=("微软雅黑", 20), size=(23, 1))
|
||||||
|
@ -21,9 +18,7 @@ panel_view_column = [
|
||||||
|
|
||||||
|
|
||||||
# ----- Full layout -----
|
# ----- Full layout -----
|
||||||
layout = [
|
layout = [[sg.VPush()],
|
||||||
[sg.Menu(menu_def)],
|
|
||||||
[sg.VPush()],
|
|
||||||
[
|
[
|
||||||
sg.Push(),
|
sg.Push(),
|
||||||
sg.Column(panel_view_column, vertical_alignment="center", justification="center"),
|
sg.Column(panel_view_column, vertical_alignment="center", justification="center"),
|
||||||
|
@ -35,13 +30,9 @@ layout = [
|
||||||
window = sg.Window("Lora 回传显示模块", layout, resizable=True, size=(500, 300), finalize=True)
|
window = sg.Window("Lora 回传显示模块", layout, resizable=True, size=(500, 300), finalize=True)
|
||||||
|
|
||||||
# Run the Event Loop
|
# Run the Event Loop
|
||||||
i = 1
|
|
||||||
while True:
|
while True:
|
||||||
event, values = window.read()
|
event, values = window.read()
|
||||||
if event == "Exit" or event == sg.WIN_CLOSED:
|
if event == "Exit" or event == sg.WIN_CLOSED:
|
||||||
break
|
break
|
||||||
|
|
||||||
window['-CHARACTER-'].update(i)
|
|
||||||
print(i)
|
|
||||||
|
|
||||||
window.close()
|
window.close()
|
||||||
|
|
18
cvshot.py
18
cvshot.py
|
@ -1,18 +0,0 @@
|
||||||
import cv2
|
|
||||||
|
|
||||||
# take a photo using cv2
|
|
||||||
|
|
||||||
img = cv2.VideoCapture(0)
|
|
||||||
|
|
||||||
# img.set(cv2.CAP_PROP_AUTO_EXPOSURE, 0.25)
|
|
||||||
img.set(cv2.CAP_PROP_AUTO_EXPOSURE, 3) # auto mode
|
|
||||||
img.set(cv2.CAP_PROP_AUTO_EXPOSURE, 1) # manual mode
|
|
||||||
img.set(cv2.CAP_PROP_EXPOSURE, 100)
|
|
||||||
# while True:
|
|
||||||
|
|
||||||
ret, frame = img.read()
|
|
||||||
if ret:
|
|
||||||
cv2.imwrite('img.png', frame)
|
|
||||||
img.release()
|
|
||||||
|
|
||||||
print('succeed')
|
|
|
@ -1,20 +0,0 @@
|
||||||
'''
|
|
||||||
@description: 摆烂的利用延时的自控程序
|
|
||||||
'''
|
|
||||||
|
|
||||||
import time
|
|
||||||
import random
|
|
||||||
from utils.auv_control import Ship
|
|
||||||
|
|
||||||
def motion_plan():
|
|
||||||
auv = Ship()
|
|
||||||
auv.LED0ON()
|
|
||||||
time.sleep(1)
|
|
||||||
auv.LED0OFF()
|
|
||||||
|
|
||||||
auv.setTarget_Y_Speed(0.5)
|
|
||||||
time.sleep(10)
|
|
||||||
auv.setTarget_Y_Speed(0)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
motion_plan()
|
|
|
@ -4,7 +4,7 @@ import numpy as np
|
||||||
from pytesseract import Output
|
from pytesseract import Output
|
||||||
|
|
||||||
# img_source = cv2.VideoCapture(0)
|
# img_source = cv2.VideoCapture(0)
|
||||||
img_source = cv2.imread('./img.png')
|
img_source = cv2.imread('./coffee-ocr.jpg')
|
||||||
|
|
||||||
|
|
||||||
def get_grayscale(image):
|
def get_grayscale(image):
|
||||||
|
@ -51,16 +51,4 @@ def test_performance():
|
||||||
cv2.imshow('img', img)
|
cv2.imshow('img', img)
|
||||||
cv2.waitKey(0)
|
cv2.waitKey(0)
|
||||||
|
|
||||||
# print(pytesseract.image_to_data(img_source, output_type=Output.DICT)['text'])
|
print(pytesseract.image_to_data(img_source, output_type=Output.DICT)['text'])
|
||||||
|
|
||||||
def identy_char(img_path):
|
|
||||||
source_img = cv2.imread(img_path)
|
|
||||||
d = pytesseract.image_to_data(source_img, output_type=Output.DICT, config='--psm 10')
|
|
||||||
|
|
||||||
for text in d['text']:
|
|
||||||
# print(text)
|
|
||||||
if len(text) == 1 and text.isalpha():
|
|
||||||
print(text)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
identy_char('./img.png')
|
|
|
@ -1,116 +0,0 @@
|
||||||
import serial
|
|
||||||
import time
|
|
||||||
import math
|
|
||||||
|
|
||||||
|
|
||||||
class Ship:
|
|
||||||
# @parameter badudrate 波特率
|
|
||||||
def __init__(self):
|
|
||||||
self.connect = serial.Serial("/dev/ttyAMA0",baudrate=9600,timeout=0.5)
|
|
||||||
|
|
||||||
self.Target_Pitch_Angle = 0
|
|
||||||
self.Target_Roll_Angle = 0
|
|
||||||
self.Target_Yaw_Angle = 0
|
|
||||||
self.Target_Pitch_Palstance = 0
|
|
||||||
self.Target_Roll_Palstance = 0
|
|
||||||
self.Target_Yaw_Palstance = 0
|
|
||||||
self.Target_X = 0
|
|
||||||
self.Target_Y = 0
|
|
||||||
self.Target_Depth = 0
|
|
||||||
self.Target_Height = 0
|
|
||||||
self.Target_X_Speed = 0
|
|
||||||
self.Target_Y_Speed = 0
|
|
||||||
self.Target_Z_Speed = 0
|
|
||||||
self.Target_X_Acc = 0
|
|
||||||
self.Target_Y_Acc = 0
|
|
||||||
self.LED0 = False
|
|
||||||
self.LED1 = False
|
|
||||||
|
|
||||||
def sendMessage(self,tmp:int , val:float):
|
|
||||||
end = 255
|
|
||||||
end = end.to_bytes(1,'big')
|
|
||||||
id = tmp.to_bytes(1, 'big')
|
|
||||||
try:
|
|
||||||
self.connect.write(id)
|
|
||||||
self.connect.write(str(float()).encode('ascii'))
|
|
||||||
self.connect.write(str(' ').encode('ascii'))
|
|
||||||
self.connect.write(end)
|
|
||||||
except:
|
|
||||||
return
|
|
||||||
|
|
||||||
def setSlopeAndInter(self , slope : float , val : float):
|
|
||||||
tmp = 0x02
|
|
||||||
end = 0xff
|
|
||||||
id = tmp.to_bytes(1, 'big')
|
|
||||||
mark = end.to_bytes(1, 'big')
|
|
||||||
self.connect.write(id)
|
|
||||||
self.connect.write(str(slope).encode('ascii'))
|
|
||||||
self.connect.write(str(' ').encode('ascii'))
|
|
||||||
self.connect.write(str(val).encode('ascii'))
|
|
||||||
self.connect.write(str(' ').encode('ascii'))
|
|
||||||
self.connect.write(end)
|
|
||||||
|
|
||||||
def LED0ON(self):
|
|
||||||
if self.LED0 == False:
|
|
||||||
self.LED0 = True
|
|
||||||
tmp = 0x10
|
|
||||||
self.sendMessage(tmp , 0.0)
|
|
||||||
|
|
||||||
def LED0OFF(self):
|
|
||||||
if self.LED0 == True:
|
|
||||||
self.LED0 = False
|
|
||||||
tmp = 0x0f
|
|
||||||
self.sendMessage(tmp , 0.0)
|
|
||||||
|
|
||||||
def LED1OFF(self):
|
|
||||||
if self.LED1 == True:
|
|
||||||
self.LED1 = False
|
|
||||||
tmp = 0x11
|
|
||||||
self.endMessage(tmp , 0.0)
|
|
||||||
|
|
||||||
def LED1ON(self):
|
|
||||||
if self.LED1 == False:
|
|
||||||
self.LED1 = False
|
|
||||||
tmp = 0x12
|
|
||||||
self.sendMessage(tmp, 0.0)
|
|
||||||
|
|
||||||
def setTarget_Depth(self , val : float):
|
|
||||||
tmp = 0x08
|
|
||||||
self.Target_Depth = val
|
|
||||||
self.sendMessage(tmp, val)
|
|
||||||
|
|
||||||
def setTarget_Yaw_Angle(self, val : float):
|
|
||||||
tmp = 0x02
|
|
||||||
self.Target_Yaw_Angle = val
|
|
||||||
self.sendMessage(tmp, val)
|
|
||||||
|
|
||||||
def setTarget_X_Speed(self , val : float):
|
|
||||||
tmp = 0x0A
|
|
||||||
self.Target_X_Speed = val
|
|
||||||
self.sendMessage(tmp, val)
|
|
||||||
|
|
||||||
def setTarget_Y_Speed(self , val : float):
|
|
||||||
tmp = 0x0B
|
|
||||||
self.Target_Y_Speed = val
|
|
||||||
self.sendMessage(tmp, val)
|
|
||||||
|
|
||||||
|
|
||||||
def sendAlpha(self , ch : int):
|
|
||||||
tmp = 0x13 + ch
|
|
||||||
self.sendMessage(tmp, 0.0)
|
|
||||||
|
|
||||||
def setFinal(self):
|
|
||||||
tmp = 0x2d
|
|
||||||
self.sendMessage(tmp, 0.0)
|
|
||||||
|
|
||||||
def setForward_Thrust(self, val:float):
|
|
||||||
tmp = 0x2f
|
|
||||||
self.sendMessage(tmp, val)
|
|
||||||
|
|
||||||
def setSidesway_Thrust(self , val: float):
|
|
||||||
tmp = 0x30
|
|
||||||
self.sendMessage(tmp ,val)
|
|
||||||
|
|
||||||
def setYaw_Rotate_Torque(self , val : float):
|
|
||||||
tmp = 0x32
|
|
||||||
self.sendMessage(tmp, val)
|
|
Loading…
Reference in New Issue