c++ - Reading successive images of a video file in opencv -


i'm working on project , @ moment need pull successive frames video find , match features on them. problem when call videocapture::read(mat &image) overwrites both images want compare same image. think because same buffer being used , therefore both values pointing same space. i'm not how around this.

here's problem code: (don't worry poor exception handling)

    mat m1, m2; videocapture cap(argv[1]); if(!cap.isopened()){     throw std::exception("could not open file"); } int num = 0;  while(num < 20){     try{     cap.read(m1);     cap.read(m2);      num++;       match(m1,m2,num);      }catch(std::exception){         std::cout << "oh no!";     } } 

match(m1,m2,num) feature detection business , outputs image "image_%d.jpg" , num. image both images side side matches displayed. image same image twice in row though. match() work because have tested still images, confident problem lies in cap.read code. help/suggestions appreciated.

well easy making sure each image deep copy of captures image.

m1 >> cap m1 = m1.clone(); 

did trick, although less elegantly hoped for.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -