在遇到一些问题后,我最近设法启动并运行了SimpleCV。我现在已经安装了一个可以正常工作的SimpleCV,并将其与Eclipse Indigo一起使用。但是,我从SimpleCV导入的所有内容都被标记为红色,并且Eclipse声明它无法找到指定的导入(即使导入的函数可以正常工作)。
有没有办法让Eclipse识别来自SimpleCV的导入,这样我就可以使用它的Ctrl-Space代码完成功能?
我试图将"SimpleCV“添加到强制内建中,但没有成功。(这就是当我在OpenCV上遇到同样的问题时,我所做的事情,它当时起作用了)
谢谢你的建议!
发布于 2013-04-06 04:41:24
导入在SimpleCV中有很大的缺陷。我一直在努力解决你遇到的同样的问题。他们不想修复它的原因(根据他们在他们的网站(http://help.simplecv.org/question/472/code-completion-with-eclipse/)上的回答)并不是因为他们“都使用vim,emacs,vi”,而是因为他们的很多代码依赖于使用* imports将大量的库拖入本地命名空间。它充其量是懒惰的编程,否则就是非常糟糕的编程。
见鬼,你甚至不能自己导入他们的一些文件,因为他们依赖于已经导入的SimpleCV init.py文件和base.py文件。这两个文件都有大量的全面导入。我想知道为什么导入SimpleCV花了2秒多的时间才能在我的电脑上运行。现在我知道了。
他们的init.py文件具有以下导入:
from SimpleCV.base import *
from SimpleCV.Camera import *
from SimpleCV.Color import *
from SimpleCV.Display import *
from SimpleCV.Features import *
from SimpleCV.ImageClass import *
from SimpleCV.Stream import *
from SimpleCV.Font import *
from SimpleCV.ColorModel import *
from SimpleCV.DrawingLayer import *
from SimpleCV.Segmentation import *
from SimpleCV.MachineLearning import *而且他们的base.py文件还有更多的导入:
import os
import sys
import warnings
import time
import socket
import re
import urllib2
import types
import SocketServer
import threading
import tempfile
import zipfile
import pickle
import glob #for directory scanning
import abc #abstract base class
import colorsys
import logging
import pygame as pg
import scipy.ndimage as ndimage
import scipy.stats.stats as sss #for auto white balance
import scipy.cluster.vq as scv
import scipy.linalg as nla # for linear algebra / least squares
import math # math... who does that
import copy # for deep copy
import numpy as np
import scipy.spatial.distance as spsd
import scipy.cluster.vq as cluster #for kmeans
import pygame as pg
import platform
import copy
import types
import time
from numpy import linspace
from scipy.interpolate import UnivariateSpline
from warnings import warn
from copy import copy
from math import *
from pkg_resources import load_entry_point
from SimpleHTTPServer import SimpleHTTPRequestHandler
from types import IntType, LongType, FloatType, InstanceType
from cStringIO import StringIO
from numpy import int32
from numpy import uint8
from EXIF import *
from pygame import gfxdraw
from pickle import *你知道,他们声称要转换所有这些不同的CV库,并对它们应用"Pythonic“方法。但这种进口混乱只是明摆着地证明他们错了。
我试图修复他们的导入,从他们的init.py文件中删除所有那些导入*,这有助于消除eclipse中出现的代码完成延迟。然后将SimpleCV鸡蛋目录(C:\Python27\Lib\site-packages\simplecv-1.3-py2.7.egg)作为外部库导入eclipse。之后,我可以运行以下代码:
from SimpleCV.ImageClass import Image导入颜色也是如此:
from SimpleCV.Color import Color有周期性的导入,所以要小心那些,因为它们可能会咬你。在导入SimpleCV.ImageClass之前尝试导入SimpleCV.Color时,我自己也有一个。请注意,通过上面的说明,我似乎能够从Eclipse获得代码完成。
https://stackoverflow.com/questions/11272914
复制相似问题