小编Eli*_*vis的帖子

ImportError:没有名为cycler的模块

我正在使用wxpython和matplotlib来开发软件,当我完成我的工作时,我想通过py2exe将python文件转换为"*.exe"文件,因此它可以在Windows中使用.这是"setup.py"文件.

from distutils.core import setup  
import py2exe  
import sys  
includes = ["encodings", "encodings.*"]    
sys.argv.append("py2exe")  
options = {"py2exe":   { "bundle_files": 1 ,"dll_excludes":["MSVCP90.dll"]}}   
setup(options = options,  
      zipfile=None,   
      console = [{"script":'test.py'}])
Run Code Online (Sandbox Code Playgroud)

然后我执行了这个脚本python setup.py来生成test.exe,并且它有效.

当我执行test.exe时发布错误ImportError: No module named cycler

然后,我尝试import cycler在python shell中执行,并且没有发生错误.另外,我检查了python目录 c:/python27/Lib/site-packages/,该cycler-0.9.0-py2.7.egg文件存在于此处.

如何处理这个问题.

python wxpython py2exe matplotlib

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

Opencv将联系的圈子分成单个

我有一个要处理的图像.我需要检测图像中的所有圆圈.这就是它. 组织形象

这是我的代码.

import cv2
import cv2.cv as cv
img = cv2.imread(imgpath)
cv2.imshow("imgorg",img)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
cv2.imshow("gray",gray)
ret,thresh = cv2.threshold(gray, 199, 255, cv.CV_THRESH_BINARY_INV)
cv2.imshow("thresh",thresh)
cv2.waitKey(0)
cv2.destrotAllWindows()
Run Code Online (Sandbox Code Playgroud)

然后,我得到了这样的图像. 在此输入图像描述

我尝试使用侵蚀和扩张将它们分成单个.但它不起作用.我的问题是如何将这些接触的圆分成单个,所以我可以检测到它们.

根据@ Micka的想法,我尝试按照以下方式处理图像,这是我的代码.

import cv2
import cv2.cv as cv
import numpy as np

def findcircles(img,contours):
    minArea = 300;
    minCircleRatio = 0.5;
    for  contour  in contours:

        area = cv2.contourArea(contour)
        if area < minArea: 
            continue

        (x,y),radius = cv2.minEnclosingCircle(contour)
        center = (int(x),int(y))
        radius = int(radius)
        circleArea = radius*radius*cv.CV_PI;

        if area/circleArea < minCircleRatio:
             continue;
        cv2.circle(img, center, radius, (0, …
Run Code Online (Sandbox Code Playgroud)

python opencv

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

标签 统计

python ×2

matplotlib ×1

opencv ×1

py2exe ×1

wxpython ×1