pythonwx+opencv+kociemba实现魔方还原

pythonwx+opencv+kociemba实现魔方还原

    • 源码:https://gitee.com/zouchengxin/cube
    • 窗口程序(cube_desktop.py)
    • 图像处理(colordetect.py)
    • 程序执行效果(https://gitee.com/zouchengxin/cube/blob/master/cube_desktop.PNG)
    • 说明

源码:https://gitee.com/zouchengxin/cube

窗口程序(cube_desktop.py)

import wx
import cv2
import colordetect as cd
import colordraw
class CubeFrame(wx.Frame):def __init__(self,*args,**kwargs):super(CubeFrame,self).__init__(*args,**kwargs)self.SetClientSize(600,680)self.SetMaxSize((600,680))self.SetMinSize((600,680))self.Bind(wx.EVT_IDLE,self.onIDLE)self.panel = wx.Panel(self, wx.ID_ANY)labelOne = wx.StaticText(self.panel, wx.ID_ANY, '机器人串口:')inputTxtOne = wx.TextCtrl(self.panel, wx.ID_ANY, 'COM3')labelTwo = wx.StaticText(self.panel, wx.ID_ANY, '摄像头串口:')inputTxtTwo = wx.TextCtrl(self.panel, wx.ID_ANY, '0')self.Bind(wx.EVT_TEXT,self.onCOM1,inputTxtOne)self.Bind(wx.EVT_TEXT, self.onCOM2, inputTxtTwo)self.cap=Noneself.index = 0self.COM2=0self.COM1="COM3"self.names=["up.jpg","down.jpg","left.jpg","right.jpg","front.jpg","back.jpg"]labelThree = wx.StaticText(self.panel, wx.ID_ANY, '魔方:')choice=wx.Choice(self.panel,choices=["上面","下面","左面","右面","前面","后面"])choice.SetSelection(self.index)self.Bind(wx.EVT_CHOICE,self.onChoice,choice)self.cameraBtn = wx.Button(self.panel, wx.ID_ANY, '拍照保存')self.cubeBtn = wx.Button(self.panel, wx.ID_ANY, '魔方还原')openBtn = wx.Button(self.panel, wx.ID_ANY, '打开摄像头')self.cameraBtn.Disable()#self.cubeBtn.Disable()self.Bind(wx.EVT_BUTTON, self.onCamera, self.cameraBtn)self.Bind(wx.EVT_BUTTON, self.onCube, self.cubeBtn)self.Bind(wx.EVT_BUTTON,self.onOpen,openBtn)self.pic=wx.StaticBitmap(self.panel)self.pic.SetSize((600,500))img=wx.Bitmap()img.Create(600,500)self.pic.SetBitmap(img)topSizer = wx.BoxSizer(wx.VERTICAL)inputOneSizer = wx.BoxSizer(wx.HORIZONTAL)btnSizer = wx.BoxSizer(wx.HORIZONTAL)inputOneSizer.Add(labelOne, 0, wx.ALL, 5)inputOneSizer.Add(inputTxtOne, 1, wx.ALL | wx.EXPAND, 5)inputOneSizer.Add(labelTwo, 0, wx.ALL, 5)inputOneSizer.Add(inputTxtTwo, 1, wx.ALL | wx.EXPAND, 5)inputOneSizer.Add(labelThree, 0, wx.ALL | wx.EXPAND, 5)inputOneSizer.Add(choice, 1, wx.ALL | wx.EXPAND, 5)btnSizer.Add(openBtn, 0, wx.ALL, 5)btnSizer.Add(self.cameraBtn, 0, wx.ALL, 5)btnSizer.Add(self.cubeBtn, 0, wx.ALL, 5)topSizer.Add(inputOneSizer, <

本文链接:https://my.lmcjl.com/post/9637.html

展开阅读全文

4 评论

留下您的评论.