python cvLoadImage problem

asked 2014-05-22 12:54:00 -0600

Adnane gravatar image

updated 2020-11-16 12:16:49 -0600

Hi, I am trying to get the width attribute of an Image that I have loaded wtih cvLoadImage in python using the following code:

frame = cvLoadImage(name, CV_LOAD_IMAGE_GRAYSCALE)
xres = frame.width
yres = frame.height

when the program arrives to these ligne it get stack and gives the following error:

 Traceback (most recent call last):
      File "track.py", line 686, in <module>
      xres_max = frame.width
 AttributeError: 'NoneType' object has no attribute 'width'

Can you please help me solve this problem.

P.S: sorry for my english.

edit retag flag offensive close merge delete

Comments

1

please, try to use the cv2 api instead of the outdated cv one.

import cv2
import numpy as np;
frame = cv2.imread(name,0)
print np.shape(frame)
berak gravatar imageberak ( 2014-05-22 13:05:25 -0600 )edit

due to some dependencies problem, I am using opencv 1.0 with python 2.5

Adnane gravatar imageAdnane ( 2014-05-22 13:22:09 -0600 )edit
1

baaaaaaaaaaaaaa.

get rid of those 'dependancy problems' in the 1st place.

any problems you might incur on the way are due to using outdated stuff., they are no more relevant today.

berak gravatar imageberak ( 2014-05-22 13:31:31 -0600 )edit
1

again, your english is not a problem at all, your usage of an outdated api is. (btw, you can imagine the difference between 1.0 and 2.4.9 ?)

berak gravatar imageberak ( 2014-05-22 13:34:12 -0600 )edit

:D, Ok done, in this part of the work python 2.7 and opencv 2.4 work just fine. thank you very much.

Adnane gravatar imageAdnane ( 2014-05-22 13:37:15 -0600 )edit

+1 @berak for "baaaaa" & "your english is not a problem at all, your usage of an outdated api is"..... Please copy/paste all those comments as answer. But I will upvote only if you put that "baaaaaaaaaaa" there... :D

Abid Rahman K gravatar imageAbid Rahman K ( 2014-05-23 01:04:37 -0600 )edit
1

hehe, no i won't ;) enough fun already.

berak gravatar imageberak ( 2014-05-23 01:19:09 -0600 )edit