This project has moved and is read-only. For the latest updates, please go here.

Partial Intellisense for OpenCV

Dec 17, 2014 at 10:18 AM
Edited Dec 17, 2014 at 10:22 AM
Hi, I'm using VS 2013 Ultimate with PTVS 2.1 and Python 2.7 (x64) installed by anaconda.
I'm also using OpenCV-Python bindings additionally installed by a tool at
I have updated the completion DB in PTVS.

When I type the following code
import numpy
import cv2
img = cv2.imread('image.png')
print img.shape
the intellisense works properly at the third line (as I type "cv2." and "cv2.imread("),
but does not work at the forth line (as I type "img."), just showing the following items
There is also a message next to the intellisense box:
type(object) -> the object's type
type(name, bases, dict) -> a new type
Since the img is a numpy.array, the intellisense should show items such as "all, any, argmax, ..."

Does anyone have ideas?

Thanks in advance.
Dec 17, 2014 at 3:55 PM
Most likely the cv2 library doesn't provide enough information for us to determine the return type - if you hover over img it probably shows that we don't know what its type is.

For now, the closest thing to a workaround is to add assert isinstance(img, numpy.ndarray) after it's assigned, though note that your code will now fail if a different type is returned. When we get a chance to put resources into our code analyser, we'll be looking at ways to improve this situation, as it is very common for libraries to not provide enough information for us.
Dec 18, 2014 at 1:12 PM
Thanks for the reply and suggestion, Zooba.
I'm very looking forward to improving it.