I am very new to python and opencv world. I was just trying to read and show an image but I always get an error:
error: D:\Build\OpenCV\opencv-3.1.0\modules\highgui\src\window.cpp:289: error: (-215) size.width>0 && size.height>0 in function cv::imshow
I have created a module named test.py. In that module, I tried to read the image "car.png" which is in my system path "C:\cv\images" and show it as below:
import cv2;
import sys;
sys.path.append('C:\\cv\\images');
im = cv2.imread('car.png');
cv2.imshow('Car Figure',im);
cv2.waitKey(0);
When I debug the code, I can see that the im variable is never initialized which is why I get that error code. However, When I type sys.path in the interpreter it shows that the path was already added as many times I tried to run my module. And when I copy/paste the module contents directly in the interpreter, the code works fine and the image appears.
It seems that inside the module, the sys.path is not taken into consideration and python is unable to read the image.
Any idea if this is a normal behavior, or should I do something inside my module to let the interpreter read sys.path contents?