Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi I don't know could ask my question true, then I ask with an example. I have a file that has 6000 pictures within. The name of the pics has a prefix and then the number of each image {bn00000, bn00001, bn00002, ...., bn5999}.

How can I write a function with OpenCV to read all of them respectively?
In fact I want to read image number one(bn00000), do some works on it and save the results, then load next image and continue as same way.

I did this code:
C++
    for(int i=00000; i<05999; i++)
{

string s1="/home/chris/6000_dataset/bn";
string s2=".bmp";
int numm=i;
o<<s1<<numm<<s2;
string s=o.str();
img=imread("s", CV_LOAD_IMAGE_GRAYSCALE);
}


But I got an ambiguous error! The next problem is that I don't know how can I iterate from 00000 to 05999?
Posted
Updated 18-Jun-14 5:54am
v2
Comments
Code-o-mat 18-Jun-14 10:49am    
Which part of the task you described here do you have a problem with?
hor_313 18-Jun-14 11:59am    
I've edited the question
Legor 19-Jun-14 4:00am    
If all the images are in the same folder you can simply use the VideoCapture class of openCV which is also able to read in image sequences. Please see the Solution posted by Peter Leow for the link to a good example.
hor_313 19-Jun-14 15:15pm    
Please consider that All of my pictures are in one folder that name is "bang" and its Address is "/home/chris/bang" and the pictures name begin from bn00000 and end at bn05999.

when I write "cout<<argv[0];" the result is "/home/chris/new_opencv/testing/testing/bin/Debug/testing" , and when I write "cout<<argv[1];" I have no result.

And when I try to execute that example you mentioned, I get an error!
Can you write a simple code to help me pls?

1 solution

 
Share this answer
 
Comments
Legor 19-Jun-14 3:59am    
Note however that this only works if the images are in the same folder. OP stated that he have to parse a textfile which contains the image paths, so this may not be helpful. Still a viable solution.
hor_313 19-Jun-14 12:20pm    
I did that code and got an Error I put its image below.
So I'm agree with you and my images are in another folder. How can I write their name in a text file and read it in my program? There isn't any better solution?
hor_313 19-Jun-14 12:13pm    
I've copied that code but got this error in pic :
http://www.uploadax.com/images/97017262536015614712.png

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900