OpenCV videocapture Capture Camera
Environmental win7+vs2010+opencv2.4.9
Camera3.cpp: Defines the entry point of the console application.
//
#include "stdafx.h"
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace CV;
using namespace Std;
int main ()
{
Declaring a video read-in class
Videocapture capture;
Read video from camera 0 means read from camera
Capture.open (0);
if (!capture.isopened ())//first determine whether to turn on the camera
{
return-1;
}
Namedwindow ("Win");
while (1) {
Mat cap;
Read Current frame
Capture >> Cap;
if (!cap.empty ())
Imshow ("Win", cap); If the current frame captures successfully, the display
Else
cout << "Can not";//processing of the last frame (empty processing)
Waitkey (30); Delay 30 ms
}
return 0;
}
Camera2.cpp: Defines the entry point of the console application.
//
#include "stdafx.h"
#include <opencv2\opencv.hpp>
using namespace CV;
-----------------------------------the main () function--------------------------------------------
Description: The entry function of the console application, our program starts here
//-------------------------------------------------------------------------------------------------
int main ()
{
"1" read the video from the camera
Videocapture Capture (0);//0,1,-1 combination continue;//break;
"2" cycle shows each frame
while (1)
{
Mat frame; Define a mat variable to store the image for each frame
capture>>frame; Read Current frame
if (Frame.empty ())
Continue
break; 0,1,-1 can not be combined
Processing of the last frame (empty processing)
Imshow ("read video", frame); Show Current frame
Waitkey (30); Delay 30ms
}
return 0;
}
Camera2.cpp: Defines the entry point of the console application.
//
#include "stdafx.h"
#include <opencv2\opencv.hpp>
using namespace CV;
-----------------------------------the main () function--------------------------------------------
Description: The entry function of the console application, our program starts here
//-------------------------------------------------------------------------------------------------
int main ()
{
"1" read the video from the camera
Videocapture Capture (0);//0,1,-1 combination continue;//break;
"2" cycle shows each frame
while (1)
{
Mat frame; Define a mat variable to store the image for each frame
capture>>frame; Read Current frame
if (Frame.empty ())
Continue
break; 0,1,-1 can not be combined
Processing of the last frame (empty processing)
Imshow ("read video", frame); Show Current frame
Waitkey (30); Delay 30ms
}
return 0;
}
if (Frame.empty ())
Continue;//break; 0,1,-1 can not be combined
Videocapture Capture (0);//0,1,-1 combination continue;//break;
if (Frame.empty ())
Break
May I
Videocapture Capture (0);
if (Frame.empty ())
Continue
Yes, but I don't know because of what, continue; it's the key.
Thank you
Camera3.cpp: Defines the entry point of the console application.
//
#include "stdafx.h"
#include <opencv2\opencv.hpp>
using namespace CV;
int main ()
{
Videocapture Capture (0);
while (1)
{
Mat frame;
if (capture.isopened ())
{
Capture >> frame;
Imshow ("final result", frame);
Waitkey (30);
}
}
return (0);
}
Camera3.cpp: Defines the entry point of the console application.
//
#include "stdafx.h"
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace CV;
using namespace Std;
int main ()
{
Declaring a video read-in class
Videocapture capture;
Read video from camera 0 means read from camera
Capture.open (0);
if (!capture.isopened ())//first determine whether to turn on the camera
{
return-1;
}
Namedwindow ("Win");
while (1) {
Mat cap;
Read Current frame
Capture >> Cap;
if (!cap.empty ())
Imshow ("Win", cap); If the current frame captures successfully, the display
Else
cout << "Can not";//processing of the last frame
Waitkey (30); Delay 30 ms
}
return 0;
}