|
|

楼主 |
发表于 2020-2-24 21:25:02
|
显示全部楼层
- import cv2
- import time
- from tkinter import *
- def up():
- a=int(inp1.get())
- for i in range(a):
- forwardStep()
- XY.Y=XY.Y+1
- def down():
- a=int(inp1.get())
- for i in range(a):
- backwardStep()
- XY.Y=XY.Y-1
- def left():
- a=int(inp1.get())
- for i in range(a):
- leftStep()
- XY.X=XY.X-1
- def right():
- a=int(inp1.get())
- for i in range(a):
- rightStep()
- XY.X=XY.X+1
-
- root=Tk()
- root.geometry('480x480')
- root.title('3+1物创操作窗口1.0')
- PX = 18
- DX = 12
- PY = 32
- DY = 37
- btn1=Button(root,text='Up',command=up) #up
- btn1.place(relx=0.2, rely=0.1, relwidth=0.1, relheight=0.1)
- btn2=Button(root,text='Down',command=down) #down
- btn2.place(relx=0.2, rely=0.2, relwidth=0.1, relheight=0.1)
- btn3=Button(root,text='Left',command=left) #left
- btn3.place(relx=0.1, rely=0.2, relwidth=0.1, relheight=0.1)
- btn4=Button(root,text='Right',command=right) #right
- btn4.place(relx=0.3, rely=0.2, relwidth=0.1, relheight=0.1)
- inp1=Entry(root) #distance
- inp1.place(relx=0.6, rely=0.1, relwidth=0.3, relheight=0.1)
- inp2=Entry(root) #time
- inp2.place(relx=0.6, rely=0.2, relwidth=0.3, relheight=0.1)
- btn5=Button(root,text='Back Origin',command=move) #back
- btn5.place(relx=0.3, rely=0.8, relwidth=0.2, relheight=0.1)
- btn6=Button(root,text='Zero',command=zero) #
- btn6.place(relx=0.2, rely=0.6, relwidth=0.1, relheight=0.1)
- btn7=Button(root,text='Back ',command=back) #move
- btn7.place(relx=0.6, rely=0.8, relwidth=0.1, relheight=0.1)
- btn8=Button(root,text='Repeat',command=Repeat) #repeatbtn8.place(relx=0.8, rely=0.8, relwidth=0.1, relheight=0.1)
- lab1=Label(root,text="Length:")
- lab1.place(relx=0.4, rely=0.1, relwidth=0.2, relheight=0.1)
- lab2=Label(root,text="Speed:")
- lab2.place(relx=0.4, rely=0.2, relwidth=0.2, relheight=0.1)
- lab3=Label(root,text='')
- lab3.pack(padx=1,pady=206)
- getxy()
- lab4=Label(root,text="Coordinate:")
- lab4.place(relx=0.2, rely=0.4, relwidth=0.2, relheight=0.1)
- cap = cv2.VideoCapture(0)
- while(1):
- ret, frame = cap.read()
- cv2.imshow("capture", frame)
- if cv2.waitKey(1) & 0xFF == ord('q'):
- break
- root.bind("<Key>",Key)
- root.mainloop()
- cap.release()
- cv2.destroyAllWindows()
复制代码
现在可以运起来了,但是只有按钮界面,摄像头界面没有,是什么问题呀? |
|