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
Post a Comment