Error in reading and displaying image in open cv. [closed]

asked 2017-07-13 05:01:18 -0600

AA gravatar image

here is the code:

import numpy as np
import cv2

img = cv2.imread('/home/Pi/Exp/result.jpg',0)
cv2.imshow('gghhss',img)

cv2.waitkey(0)
cv2.destroyAllWindows()

And the error:

Traceback (most recent call last):
  File "/home/pi/Exp/opcv.py", line 5, in <module>
    cv2.imshow('gghhss',img)
error: /build/opencv-ISmtkH/opencv-2.4.9.1+dfsg/modules/highgui/src/window.cpp:269: error: (-215) size.width>0 && size.height>0 in function imshow

This is from opencv tutorial here in the read image.

Thanks :) P.S. I did google and did not find anything. Please donot downvote,

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by berak
close date 2017-07-13 05:09:02.826815

Comments

berak gravatar imageberak ( 2017-07-13 05:08:47 -0600 )edit

It not duplicate i did add the directory the cv2.imshow('gghhs',img) is just the name the window will have will displaying img

AA gravatar imageAA ( 2017-07-13 05:12:06 -0600 )edit

you obviously did not learn the previous lesson ..

berak gravatar imageberak ( 2017-07-13 05:14:22 -0600 )edit

Your previous lesson was about declaring the directory. Well i have mentioned it. Whats the problem? Also how can it be a duplicate the errors are totally different (when looked up i don't know what they actually mean)?

AA gravatar imageAA ( 2017-07-13 05:19:33 -0600 )edit

no, it was about checking, if the image loaded, before proceeding.

berak gravatar imageberak ( 2017-07-13 05:23:43 -0600 )edit

If it did not load i would have gotten an error like 'NoneType' etc.. but the error is some funky stuff.

AA gravatar imageAA ( 2017-07-13 05:27:31 -0600 )edit