I had written few python scripts on Windows using opencv 3.2.0 and python 2.7.13. I, then, installed the same version of opencv on my R-Pi, and tried running the very same scripts on it, but none of themm work. I am posting the simplest of the scripts here

import numpy as np
import cv2
img = cv2.imread('Photos\WIN_20170102_20_34_33_Pro.jpg', 0)
img = cv2.medianBlur(img, 5)
cv2.imshow('Veins', img)

This gives me the following error:

Traceback (most recent call last):
   File "/home/pi/Desktop/Basic Project codes/hist.py", line 8, in <module>
    cv2.imshow('Veins', img)
error: /home/pi/opencv-3.2.0/modules/highgui/src/window.cpp:304: error: (-215) size.width>0 && size.height>0 in function imshow

Other codes also return various errors. What can be the possible problem?


you should use in pythonos.path.join("Photos", "WIN_20170102_20_34_33_Pro.jpg") to join the path of a file OS-independent. The error might be because the image has no size when you are trying to show it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.