imread() vs LoadImage() in Python [closed]

asked 2014-04-02 01:36:47 -0600

syang2100 gravatar image

Hi,

I am a new user to Python with OpenCV (1 week old). When I search for code for some specific function, but many of them does NOT work for me. For example, I found a command to load image, I found many example with imread() command, but, my Python only work with LoadImage(). It is really confuse me because it happen on other command too. If I wish to use imread() in Python, how can I make it work?

Is that version problem? What could be wrong with my setup? I appreciate it if anyone can help me. Thanks.

Version:

Python: 2.7.3, OpenCV: 2.4.3, numpy: 1.6.2, OS: MS-Windows 7

Below two command are fro Python:

Python: cv2.imread(filename[, flags]) → retval

Python: cv.LoadImage(filename, iscolor=CV_LOAD_IMAGE_COLOR) → None

Found from: http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by StevenPuttemans
close date 2014-04-02 02:44:14.630890

Comments

2

there just is no question: use cv2. (full stop)

the old cv api is being phased out, and won't be available in upcoming versions

import cv2
import numpy as np

im = cv2.imread("lean.jpg",1)

if that does not work for you, - update. (start with numpy, 1.6.2 looks pretty old)

berak gravatar imageberak ( 2014-04-02 01:50:07 -0600 )edit

It is new to me. Maybe I should focus on V2 code. Thanks.

syang2100 gravatar imagesyang2100 ( 2014-04-02 01:58:31 -0600 )edit
1

My code was: import cv2.cv as cv im = cv.imread("lean.jpg",1) Using wrong libery was the source of the problem. I got it now. Thanks.

syang2100 gravatar imagesyang2100 ( 2014-04-02 02:02:52 -0600 )edit

ah, ok. easy catch. good luck here!

berak gravatar imageberak ( 2014-04-02 02:05:14 -0600 )edit