c++ - Saving frames from stereo cameras using OpenCV -


i trying capture frames/images stereo web camera. imshow work when press capture key 99 save frames form both cameras give exception

unhandled exception @ 0x005a13af (msvcr100d.dll) in opencvconfig.exe: 0xc0000005: access violation reading location 0x7466656c 

and stop working. kindly me in regards. using opencv_2.4.11 , visual studio 2010.

here source code

//this works me on opencv 2.0 2 logicool webcams.  #include <opencv\cv.h> #include <opencv\highgui.h> #include <opencv2\opencv.hpp> #include <iostream> #include <string> #include "opencv2/opencv.hpp"  using namespace cv; using namespace std;   int main(int, char**) {     //to capture images pre variables      int key = 0;     string namel = "left";     string namer = "right";     char bufferl[20];     char bufferr[20];     int counter = 0;      ////////////////////////////////      cv::videocapture capleft(0); // open left camera     cv::videocapture capright(1); // open right camera      if(!capleft.isopened() || !capright.isopened())  // check if succeeded     {         std::cerr << "error: not open cameras." << std::endl;         return -1;     }       cv::namedwindow("left",1);     cv::namedwindow("right",1);      for(;;)     {         bool isvalid = true;           cv::mat frameleft;         cv::mat frameright;          try         {           capleft >> frameleft; // new frame left camera           capright >> frameright; //get new frame right camera         }         catch( cv::exception& e )         {           std::cout << "an exception occurred. ignoring frame. " << e.err << std::endl;           isvalid = false;         }          if (isvalid)         {           try           {             //capture frames , save them              while(key!=27)             {                 capleft >> frameleft; // new frame left camera                 capright >> frameright; //get new frame right camera                  cv::imshow("left", frameleft);                 cv::imshow("right", frameright);                  if(key==99)                 {                     sprintf(bufferl,"%s%s.ppm",namel,counter);                     imwrite(bufferl,frameleft);                      sprintf(bufferr,"%s%s.ppm",namer,counter);                     imwrite(bufferr,frameright);                 }                 key = waitkey(700);                 counter++;             }               /////////////// cool stuff ends            }           catch( cv::exception& e )           {             std::cout << "an exception occurred. ignoring frame. " << e.err << std::endl;           }         }         if(cv::waitkey(30) >= 0) break;     }      //the camera deinitialized automatically in videocapture destructor     return 0; } 


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -