"Vision-camera 0" OPENCV Call USB Industrial camera

Source: Internet
Author: User

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;

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.