Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi there i've been playing a little bit discovering openCv on VS12, everything works fine for me concerning image processing. But i have a problem for processing video: i'm following basic tutorials, but when i compile, i only get one single frame through the video input. Where could this come from? I think i have a problem handling my frame, but i've been stricly following tutorials, this is what i write:

//example from a book void main() { // Open the video file cv::VideoCapture capture(0); // check if video successfully opened if (!capture.isOpened()) std::cout<<"not opened" <<std::endl;< p="">

// Get the frame rate double rate= capture.get(CV_CAP_PROP_FPS); bool stop(false); cv::Mat frame; // current video frame cv::namedWindow("Extracted Frame"); // Delay between each frame in ms // corresponds to video frame rate int delay= 1000/rate; // for all frames in video while (!stop) { // read next frame if any if (!capture.read(frame)) break; cv::imshow("Extracted Frame",frame); // introduce a delay // or press key to stop if (cv::waitKey(delay)>=0) stop= true; } // Close the video file. // Not required since called by destructor capture.release(); }

//another version i personnaly wrote void main (void){ bool stop; stop = false; cv::VideoCapture capture (0); //capture from the webcam

if(capture.isOpened() == false ){
    std::cout<< "Capture Error" <<std::endl;
}//test if opned

cv::Mat frame;
cv::namedWindow("w");

double rate= capture.get(CV_CAP_PROP_FPS);


while (stop == false){
    frame=capture.read();
    if (!capture.read(frame))
        break;


    if (cvWaitKey() ){
        stop = true;
    }

    cv::imshow("w",frame);

}// chose while
capture.release();
cvDestroyWindow("w");

}

everytime i get the same thing: One single image from the cam does appear, and then i can push any key to stop, but i dont get a video frame

Hi there i've been playing a little bit discovering openCv on VS12, everything works fine for me concerning image processing. But i have a problem for processing video: i'm following basic tutorials, but when i compile, i only get one single frame through the video input. Where could this come from? I think i have a problem handling my frame, but i've been stricly following tutorials, this is what i write:

void main() { //example from a book void main() { // Open the video file book

cv::VideoCapture capture(0);
// check if video successfully opened
     if (!capture.isOpened())
      std::cout<<"not opened" <<std::endl;< p="">

<<std::endl;

// Get the frame rate rate

double rate= capture.get(CV_CAP_PROP_FPS);
  bool stop(false);
  cv::Mat frame; // current video frame
  cv::namedWindow("Extracted Frame");

// Delay between each frame in ms // corresponds to video frame rate rate

int delay= 1000/rate;

// for all frames in video video

while (!stop) {

// read next frame if any any

    if (!capture.read(frame))
         break;
      cv::imshow("Extracted Frame",frame);

// introduce a delay // or press key to stop stop

    if (cv::waitKey(delay)>=0)
         stop= true;

} // Close the video file. // Not required since called by destructor capture.release(); }

//another version i personnaly wrote void main (void){ bool stop; stop = false; cv::VideoCapture capture (0); //capture from the webcam

if(capture.isOpened() == false ){
    std::cout<< "Capture Error" <<std::endl;
}//test if opned

cv::Mat frame;
cv::namedWindow("w");

double rate= capture.get(CV_CAP_PROP_FPS);


while (stop == false){
    frame=capture.read();
    if (!capture.read(frame))
        break;


    if (cvWaitKey() ){
        stop = true;
    }

    cv::imshow("w",frame);

}// chose while
capture.release();
cvDestroyWindow("w");

}

everytime i get the same thing: One single image from the cam does appear, and then i can push any key to stop, but i dont get a video frame