小编use*_*19o的帖子

使用多个键对 Python 列表进行排序

我为此搜索了很多时间。我对使用关键参数进行排序有了一些想法。

我有一个像这样的元组列表。它是由 OpenCV 霍​​夫圆检测获得的。

correctC = [(298, 172, 25), (210, 172, 25), (470, 172, 25), (386, 172, 22), (648, 172, 25), (384, 44, 22), (558, 110, 22), (562, 170, 25), (382, 108, 25), (734, 172, 25), (126, 172, 24), (646, 44, 22), (296, 110, 23), (126, 234, 26), (470, 236, 25), (296, 44, 25), (208, 108, 24), (38, 170, 25), (730, 110, 22), (730, 44, 25), (468, 110, 23), (468, 44, 25), (208, 44, 25), (124, 44, 22), (558, 44, …
Run Code Online (Sandbox Code Playgroud)

python sorting list python-2.7

5
推荐指数
2
解决办法
7138
查看次数

class Image没有属性'fromarray'

我正在使用OpenCV和Python Tkinter.我想将OpenCV的视频帧添加到Tkinter标签中.我使用了线程,因为我有两个循环.(我得到了这方面的指示)

当我试图运行代码它告诉我,

按任意键继续 ...线程中的异常Thread-2:Traceback(最后调用最后一次):文件"C:\ Python27\lib\threading.py",第808行,在__bootstrap_inner self.run()文件"C:\ Python27\lib\threading.py" ",第761行,在run self .__ target(*self .__ args,**self .__ kwargs)文件"c:\ users\user1\documents\visual studio 2013\Projects\defTstWindow\defT stWindow\defTstWindow.py",line 26,在makeGUI img = Image.fromarray(cv2image)AttributeError:class Image没有属性'fromarray'

我尝试使用Python类.我得到了同样的错误.

但是,如果我在一个功能运行的所有(如1日回答这个),它的正常工作.

我的代码有什么问题?

现在我有四个python模块.

1.Support.py

import cv2

global frame
frame=None
Run Code Online (Sandbox Code Playgroud)

2.CamHandler.py

import cv2
import numpy as np
import Support

cam=cv2.VideoCapture(0)


def getFrame():
    while 1:
     _,frm=cam.read()

     #cv2.imshow('frm',frm)
     Support.frame=frm

     if cv2.waitKey(1) & 0xFF == ord('q'):
        cv2.destroyAllWindows()
        break
Run Code Online (Sandbox Code Playgroud)

3.defTstWindow.py

import sys
import cv2
import Image, ImageTk

from Tkinter import *
import Support

def makeGUI(): …
Run Code Online (Sandbox Code Playgroud)

python multithreading opencv numpy tkinter

3
推荐指数
2
解决办法
5267
查看次数

C++中的int和const int

当我问到C++中int和const之间有什么不同?有人这样说.

可以在需要时修改int,它是读/写,而const int是只读的.(可以动态更改).您可以将const int用于类似固定值的内容,并且const int内存使用率小于普通int.

这是真正的const int内存使用量是否小于普通int.在C++中?

c++ arduino

2
推荐指数
1
解决办法
343
查看次数

标签 统计

python ×2

arduino ×1

c++ ×1

list ×1

multithreading ×1

numpy ×1

opencv ×1

python-2.7 ×1

sorting ×1

tkinter ×1