Simple OpenCV test generates blank image from tutorial [closed]

asked 2016-02-22 08:33:14 -0600

TonyE gravatar image

ALL,

New to Python and OpenCV - trying to follow the tutorials.

Created Python 2.7.11 environments (32b & 64b) with Miniconda Included numpy 1.10.4 & matplotlib 1.5.1 Added opencv (3.1.0) cv2.pyd to the sit-packages from opencv build\python\2.7[x64|x86]\cv2.pyd

Entered environment and did the following: (Note: this is the x64 output, x86 was identical.)


[OCV] C:\Users\XXXXXX>python
Python 2.7.11 |Continuum Analytics, Inc.| (default, Jan 29 2016, 14:26:21) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import numpy as nb
>>> import cv2
>>> import os
>>> os.chdir('C:\Users\XXXXXX\Pictures\Invoices')
>>> os.getcwd()
'C:\\Users\\XXXXXX\\Pictures\\Invoices'
>>> img = cv2.imread('invoice.jpg',0)
>>> print img
[[255 255 255 ..., 255 255 255]
 [255 255 255 ..., 255 255 255]
 [255 255 255 ..., 255 255 255]
 ...,
 [255 255 255 ..., 255 255 255]
 [255 255 255 ..., 255 255 255]
 [255 255 255 ..., 255 255 255]]
>>> cv2.__version__
'3.1.0'
>>> exit()

[OCV] C:\Users\XXXXXX>conda list
# packages in environment at C:\Miniconda2\envs\OCV:
#
cycler                    0.9.0                    py27_0
jpeg                      8d                        vc9_0  [vc9]
libpng                    1.6.17                    vc9_1  [vc9]
libtiff                   4.0.6                     vc9_1  [vc9]
matplotlib                1.5.1               np110py27_0
mkl                       11.3.1                        0
msvc_runtime              1.0.1                     vc9_0  [vc9]
numpy                     1.10.4                   py27_0
pip                       8.0.2                    py27_0
pyparsing                 2.0.3                    py27_0
pyqt                      4.11.4                   py27_5
python                    2.7.11                        2
python-dateutil           2.4.2                    py27_0
pytz                      2015.7                   py27_0
qt                        4.8.7                     vc9_6  [vc9]
setuptools                19.6.2                   py27_0
sip                       4.16.9                   py27_2
six                       1.10.0                   py27_0
tk                        8.5.18                    vc9_0  [vc9]
wheel                     0.29.0                   py27_0
zlib                      1.2.8                     vc9_2  [vc9]

Now - I'm pretty sure that the img object should have had something other than black/white in the array - How would I troubleshoot/Debug this? Is there an incompatibility with OpenCV and the stack(s) created?

Thanks - Tony

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-20 09:56:59.394640

Comments

add a cv2.waitKey() after the cv2.imshow(), else nothing will get drawn

(no, it's not about your environment, it's a simple n00b mistake)

berak gravatar imageberak ( 2016-02-22 08:38:24 -0600 )edit