Ask Your Question
0

How to Save frames to directory

asked 2013-09-26 09:50:05 -0600

FLY gravatar image

updated 2013-09-26 13:31:28 -0600

I am trying to save the frames which have entropy >0.78 , i want to save that specific frames from my video file , it may be more than 100 frames , i tried it , Below is my code

if (entropy>0.78)
          {
            detector.detect(pre_img, keypoint2);
            if (keypoint2.size() >= 20)
            {
              RetainBestKeypoints(keypoint2, 20);
              dextract.compute( pre_img, keypoint2, descriptors_2);
              Mat my_img_3 = descriptors_2.reshape(1,1);

              float response = svm.predict(my_img_3);
              if (response==1)
              {
                 count_4++;

                 cv::imwrite("images.jpg", pre_img);

              }
         }
       }

This code is not saving all the images , i want to save it in a specific directory like D:\images\

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2013-09-26 13:55:22 -0600

Moster gravatar image

What did you expect this to do? You always write the same image called "images.jpg". You could simply achieve your task via stringstreams (#include <sstream>)

if (response==1)
{
    stringstream file;
    file << "image" << count_4 << ".jpg";
    count_4++;

    cv::imwrite(file.str(), pre_img);

}

If you want to write to a certain folder, you could try this. Im not 100% sure this works on windows. On linux it worked with the linux folder structure.

file << "D:\images\image" << count_4 << ".jpg";
edit flag offensive delete link more

Comments

In windows it works with the '/' file << "D:/images/image" << count_4 << ".jpg";

meera_c gravatar imagemeera_c ( 2018-10-10 05:32:35 -0600 )edit

Question Tools

Stats

Asked: 2013-09-26 09:50:05 -0600

Seen: 6,649 times

Last updated: Sep 26 '13