//liyongbo 2015.05.06 changchun
//#include "stdafx.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <string>
using namespace cv;
using namespace std;
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <float.h>
#include <limits.h>
#include <time.h>
#include <ctype.h>
// OpenCV
#include <cxcore.h>
#include <cv.h>
#include <highgui.h>
#include <cvaux.h>
#include "cv.h"
#include "highgui.h"
#include <string>
#include <iostream>
#include <opencv2/calib3d/calib3d.hpp>
#define CV_CALIB_CB_ADAPTIVE_THRESH 1
#define CV_CALIB_CB_NORMALIZE_IMAGE 2
#define CV_CALIB_CB_FILTER_QUADS 4
#define CV_CALIB_CB_FAST_CHECK 8
int main()
{
int cube_length = 7;
CvCapture* capture;
capture = cvCreateCameraCapture(0);
if (capture == 0){
printf("无法捕获摄像头设备!\n\n");
return 0;
}
else{
printf("捕获摄像头设备成功!!\n\n");
}
IplImage* frame;
cvNamedWindow("帧截取窗口", 1);
//cvNamedWindow()函数用于在屏幕上创建一个窗口,将被显示的图像包含于该窗口中。
//函数的第一个参数指定了该窗口的窗口标题,如果要使用HighGUI库所提供的其他函数与该窗口进行交互时,我们将通过该参数值引用这个窗口。
printf("按“C”键截取当前帧并保存为标定图片...\n按“Q”键退出截取帧过程...\n\n");
int number_image = 1;
char *str1;
str1 = ".jpg";
char filename[20] = "";
while (true)
{
frame = cvQueryFrame(capture);// 从摄像头或者文件中抓取并返回一帧
if (!frame)
break;
cvShowImage("帧截取窗口", frame); //图像显示
if (cvWaitKey(10) == 'c'){
printf("进入截取程序!!!!!!");
sprintf_s(filename, "%d.jpg", number_image); // int sprintf_s( char *buffer, size_t sizeOfBuffer, const char *format [, argument] ... );
//这个函数的主要作用是将若干个argument按照format格式存到buffer中
cvSaveImage(filename, frame);//保存
cout << "成功获取当前帧,并以文件名" << filename << "保存...\n\n";
printf("按“C”键截取当前帧并保存为标定图片...\n按“Q”键退出截取帧过程...\n\n");
number_image++;
}
else if (cvWaitKey(10) == 'q'){
printf("截取图像帧过程完成...\n\n");
cout << "共成功截取" << --number_image << "帧图像!!\n\n";
brea