New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative vs. Absolute Path #534

Closed
predmach opened this Issue Jun 3, 2013 · 3 comments

Comments

Projects
None yet
3 participants
@predmach

predmach commented Jun 3, 2013

TypeError: CvArr argument 'src' must be IplImage, CvMat, or CvMatND. Use fromarray() to convert numpy arrays to CvMat or cvMatND.

Received this error when executing SimpleCV [[img=Image('test.jpg'); img.save('test2.jpg')]] from a Celery task. It is possible that the current working directory of the celeryd is not the same as the directory, which would have made the image object invalid. The error indicates that the argument is the wrong type, not that the image wasn't loaded.

By changing the relative path to an absolute path, the error was resolved. (credit: ionelmc)

I would expect an error that would indicate that the image did not load.

@ionelmc

This comment has been minimized.

Show comment
Hide comment
@ionelmc

ionelmc Jun 3, 2013

Shouldn't it raise some IOError: file does not exist or something like that ?

ionelmc commented Jun 3, 2013

Shouldn't it raise some IOError: file does not exist or something like that ?

@jayrambhia

This comment has been minimized.

Show comment
Hide comment
@jayrambhia

jayrambhia Jun 3, 2013

Contributor

What version are you using?
on doing something like this

img = Image("some_image.jpg") # I don't have some_image.jpg in my directory.

I'm getting this error.

SimpleCV:3> img=Image("some_image.jpg")
---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
/home/jay/SimpleCV/SimpleCV/Shell/Shell.pyc in <module>()
----> 1 img=Image("some_image.jpg")

/home/jay/SimpleCV/SimpleCV/ImageClass.pyc in __init__(self, source, camera, colorSpace, verbose, sample, cv2image, webp)
   1061                     self._bitmap = cv.LoadImage(self.filename, iscolor=cv.CV_LOAD_IMAGE_COLOR)
   1062                 except:
-> 1063                     self._pil = pil.open(self.filename).convert("RGB")
   1064                     self._bitmap = cv.CreateImageHeader(self._pil.size, cv.IPL_DEPTH_8U, 3)
   1065                     cv.SetData(self._bitmap, self._pil.tostring())

/usr/lib/python2.7/dist-packages/PIL/Image.pyc in open(fp, mode)
   1950         import __builtin__
   1951         filename = fp
-> 1952         fp = __builtin__.open(fp, "rb")
   1953     else:
   1954         filename = ""

IOError: [Errno 2] No such file or directory: 'some_image.jpg'
Contributor

jayrambhia commented Jun 3, 2013

What version are you using?
on doing something like this

img = Image("some_image.jpg") # I don't have some_image.jpg in my directory.

I'm getting this error.

SimpleCV:3> img=Image("some_image.jpg")
---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
/home/jay/SimpleCV/SimpleCV/Shell/Shell.pyc in <module>()
----> 1 img=Image("some_image.jpg")

/home/jay/SimpleCV/SimpleCV/ImageClass.pyc in __init__(self, source, camera, colorSpace, verbose, sample, cv2image, webp)
   1061                     self._bitmap = cv.LoadImage(self.filename, iscolor=cv.CV_LOAD_IMAGE_COLOR)
   1062                 except:
-> 1063                     self._pil = pil.open(self.filename).convert("RGB")
   1064                     self._bitmap = cv.CreateImageHeader(self._pil.size, cv.IPL_DEPTH_8U, 3)
   1065                     cv.SetData(self._bitmap, self._pil.tostring())

/usr/lib/python2.7/dist-packages/PIL/Image.pyc in open(fp, mode)
   1950         import __builtin__
   1951         filename = fp
-> 1952         fp = __builtin__.open(fp, "rb")
   1953     else:
   1954         filename = ""

IOError: [Errno 2] No such file or directory: 'some_image.jpg'
@predmach

This comment has been minimized.

Show comment
Hide comment
@predmach

predmach Jun 3, 2013

You are right, it turned out to be that the image file name in the constructor was a Unicode string. Once encoded as ascii, the class performed properly. this is actually issue: #159

predmach commented Jun 3, 2013

You are right, it turned out to be that the image file name in the constructor was a Unicode string. Once encoded as ascii, the class performed properly. this is actually issue: #159

@predmach predmach closed this Jun 3, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment