Read JPEGs formats only

Aug 7, 2012 at 5:46am
How can I read JPEG file formats only using OpenCv and C++.

Can anyone point me to a tutorial?
Aug 7, 2012 at 6:06am
1
2
IplImage* img=0; 
img=cvLoadImage(fileName);

give fileName = you JPEG file path..
Aug 7, 2012 at 6:47am
I've tried this one but it's not working

Mat img = imread( "Desktop/img.jpg/", 1 );

and also can I use the wildcard character * instead of img.jpg so that it can only read jpeg files?

Aug 7, 2012 at 7:12am
@projectUser Frankly speaking i never encounter with that wildcard character
though i tried hard for *.jpg but i won't succeed in that...
try out cvLoadImage that will work for you..
Aug 7, 2012 at 8:57am
You should probably remove the last / in the file path.
Aug 7, 2012 at 5:09pm
Yeah. At runtime, the code is going to take a look at Desktop/img.jpg and wonder where the crap that is.
I've never used the library you're using, but try,
Mat img = imread( "YOURDRIVELETTER:/Documents and Settings/YOURUSERNAME/Desktop/img.jpg", 1 );
Or put the image in the same directory as the executable, and use:
Mat img = imread( "img.jpg", 1 );
I know some IDE's (such as Code::Blocks) when running the program with the dedicated 'run' button built into the IDE, it executes the program with a different working dir.
Therefore, if you are using an IDE such as Code::Blocks, try running the executable manually via the folder it's compiled to, with the image file in the same folder, and use Mat img = imread( "img.jpg", 1 );
Last edited on Aug 7, 2012 at 5:24pm
Topic archived. No new replies allowed.