Ask Your Question
0

Imread many image of type Mat

asked 2014-06-30 10:10:39 -0600

abir gravatar image

updated 2014-07-01 02:31:52 -0600

Hello , With my program I can read an image. Now I have many images in my database. How can I do read the image loop! (the type of image is Mat) Please! thank you

int main()
{
vector<Mat> frames;
char filename[100] ;
    for (int i=1;i<4;i++){
        sprintf(filename,"/home/user/Bureau/Nouveau dossier/sobel-test/uEyeImg000%d.tif",i);
        Mat frame=imread(filename);
        frames.push_back(frame);

    }
    waitKey(0);
     return 0 ;
}
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2014-06-30 12:56:09 -0600

If the images are named image1.jpg, image2.jpg and so on, you can save them to a vector using the following code:

vector<Mat> frames;    
    for (int i=1;i<K;i++){   
        sprintf(filename,"C:\\DB\\image%d.jpg",i);
        Mat frame=imread(filename);
        frames.push_back(frame);
    }
edit flag offensive delete link more

Comments

I did it as you told me but I have an error " segmentation fault" I've updated the code used

abir gravatar imageabir ( 2014-07-01 02:23:54 -0600 )edit

Question Tools

Stats

Asked: 2014-06-30 10:10:39 -0600

Seen: 418 times

Last updated: Jul 01 '14