How to Use Code Completion into Eclipse with Opencv

How to use code completion into Eclipse with OpenCV

For C/C++:

  1. Use CDT in Eclipse
  2. In your project root directory, create the project's Makefiles:

    cmake -G 'Eclipse CDT4 - Unix Makefiles'

  3. Import the project using Eclipse->File->Import->General->Existing Projects

  4. Enjoy code completion using Ctrl-Space

For Python

  1. Install PyDev
  2. In Eclipse Navigate to... Window->Preferences->PyDev->Interpreters
  3. Configure PyDev, selecting the Python interpreter to be used
  4. Add /usr/local/lib/python2.7/dist-packages (or other valid path(s)) to the System Libraries
  5. Add cv (or cv2) to the Forced builtins
  6. Enjoy code using Ctrl-Space

Code completion for OpenCV in Java

The problem was not OpenCV itself, but rather the fresh Eclipse distribution that I downloaded. Code completion (Ctrl + Space) was not working for anything, not just OpenCV. The solution can be found here: Eclipse/Java code completion not working.

Code completion for OpenCV in Java

The problem was not OpenCV itself, but rather the fresh Eclipse distribution that I downloaded. Code completion (Ctrl + Space) was not working for anything, not just OpenCV. The solution can be found here: Eclipse/Java code completion not working.

Getting documentation and source of OpenCV Python to eclipse

The documentation is available here: OpenCV Documentation.

But I could not find a way to include it to Eclipse.

This answer is related to my problem: Python documentation in Eclipse

Getting documentation and source of OpenCV Python to eclipse

The documentation is available here: OpenCV Documentation.

But I could not find a way to include it to Eclipse.

This answer is related to my problem: Python documentation in Eclipse

SimpleCV Code Completion with Eclipse

Imports are very much broken in SimpleCV. I've been struggling with the same problem you're having. And the reason they don't want to fix it (as per their answers on their site (http://help.simplecv.org/question/472/code-completion-with-eclipse/) is not because they "all use vim, emacs, vi" but because a lot of their code relies on pulling alot of libraries into the local namespace with * imports. It's lazy programming at best, and really bad programming otherwise.

Heck, you can't even import some of their files by themselves because they rely on the SimpleCV init.py file and base.py file being imported already. Both of those files have a lot of blanket imports. I was wondering why import SimpleCV took more than 2 seconds to run on my pc with an SSD. Now I know.

Their init.py file has these imports:

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 *

And their base.py file has yet more imports:

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 *

You know they claim to convert all these disparate CV libraries and apply "Pythonic" ways to them. But this import mess just plain out right proves them wrong.

My attempt at fixing their imports was to remove all those import *'s from their init.py file which helps with the code completion lag that it presents in eclipse. Then importing the SimpleCV egg directory (C:\Python27\Lib\site-packages\simplecv-1.3-py2.7.egg) into eclipse as an external library. After that, I was able to run this:

from SimpleCV.ImageClass import Image

Same goes for importing Color:

from SimpleCV.Color import Color

There are cyclical imports, so beware of those as they might bite you. I myself had one earlier while trying to import SimpleCV.Color before importing SimpleCV.ImageClass. Note, with the above instructions, I seem to be able to get code-completion from Eclipse.



Related Topics



Leave a reply



Submit