开发者

py2exe on PIL ImageStat.Stat throws Exception: argument 2 must be ImagingCore, not ImagingCore

I'm trying to create a .exe from a python program using py2exe, but w开发者_高级运维hen I run the .exe I get a log file with

Exception in thread Thread-1:
Traceback (most recent call last):
  File "threading.pyc", line 532, in __bootstrap_inner
  File "threading.pyc", line 484, in run
  File "webcam.py", line 66, in loop
  File "ImageStat.pyc", line 50, in __init__
  File "PIL\Image.pyc", line 990, in histogram
TypeError: argument 2 must be ImagingCore, not ImagingCore

Here's some code:

#webcam.py
          cam = VideoCapture.Device();
          def getImage():
            return cam.getImage();
    ...
        camshot = grayscale(getImage());
        lightCoords = [];
        level = camshot.getextrema()[1]-leniency;
        for p in camshot.getdata():
          if p>=level:
            lightCoords.append(255);
          else:
            lightCoords.append(0);
        maskIm = new("L",res);
        maskIm.putdata(lightCoords);
    ...

    64      colorcamshot = getImage();
    65      camshot = grayscale(colorcamshot);
    66      brightness = ImageStat.Stat(camshot,maskIm).sum[0]/divVal;


Try importing PIL in your main thread before starting any worker threads. It looks like the same class has been imported twice, and type comparisons are acting wacky as a result.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜