2012-06-30 84 views
1

我最近在遇到一些問題後成功運行了SimpleCV。我現在已經安裝了SimpleCV,並正在使用Eclipse Indigo。但是,我從SimpleCV導入的所有內容都標記爲紅色,並且Eclipse聲明它無法找到指定的導入(即使導入的函數工作正常)。使用Eclipse進行SimpleCV代碼完成

是否有任何方法讓Eclipse識別從SimpleCV導入,以便我可以使用其Ctrl-Space代碼完整功能?

我試圖將「SimpleCV」添加到Forced Builtins中,但沒有成功。 (這是我做的,當我有同樣的問題了OpenCV的,然後它的工作)

感謝您的諮詢!

回答

1

SimpleCV中導入非常多。我一直在努力解決你遇到的同樣的問題。而他們之所以不想修復它(按他們在其網站上(http://help.simplecv.org/question/472/code-completion-with-eclipse/答案)是不是因爲他們「都使用vim,emacs的,六」,但因爲有很多他們的代碼依賴於很多拉庫到本地命名空間爲*進口,最好是惰性編程,否則編程確實不好。 .py文件已被導入,這兩個文件都有大量的導入,我想知道爲什麼導入SimpleCV需要花費2秒以上才能在我的電腦上運行一個SSD,現在我知道了。文件有這些進口:

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 * 

你知道他們要求把所有這些不同的簡歷庫和應用「Python化」的方式給他們。但是,這種導入混亂只是證明他們錯了。

我在固定的進口嘗試是那些進口*的從他們init.py文件與它呈現在Eclipse中代碼完成滯有助於消除。然後導入SimpleCV雞蛋目錄(C:\ Python27 \ LIB \站點包\ simplecv-1.3-py2.7.egg)到Eclipse作爲外部庫。在那之後,我就能夠運行這個命令:

from SimpleCV.ImageClass import Image 

也是一樣的進口顏色:

from SimpleCV.Color import Color 

有周期性的進口,所以要小心那些,因爲他們可能會咬你。在導入SimpleCV.ImageClass之前嘗試導入SimpleCV.Color時,我自己有一個較早的版本。請注意,根據上述說明,我似乎可以從Eclipse獲得代碼完成。

+1

我怕我沒有SimpleCV我的系統上了,所以我不能檢查它。過了一段時間,我放棄了,但是,切換到OpenCV。一旦你通過了最初的學習曲線,那真的不是那麼糟糕。幹得好雖然讓它工作!我只是沒有耐心...... – casper