我在VideoCapture cap(0); // open the video camera no. 0
if (!cap.isOpened()) // if not success, exit program
{
cout << "Cannot open the video cam" << endl;
return -1;
}
double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video
cout << "Frame size : " << dWidth << " x " << dHeight << endl;
namedWindow("MyVideo", CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"
while (1)
{
Mat frame;
cap.retrieve(frame);
int i = 0; //index, we use it for testing
while ((i++ < 100) && !cap.read(frame)) //skip unread frames
{
cout << "frame " << i << " skipped" << endl;
}
if (i >= 100) //check webcam_0 failure
{
cout << "cannot read frames from webcam_0, check drivers" << endl;
waitKey(0);
return -1;
}
else
{
cout << "cam is ready" << endl;
}
bool bSuccess = cap.read(frame); // read a new frame from video
if (!bSuccess) //if not success, break loop
{
cout << "Cannot read a frame from video stream" << endl;
break;
}
imshow("MyVideo", frame); //show the frame in "MyVideo" window
if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
{
cout << "esc key is pressed by user" << endl;
break;
}
}
数据库中有多行数据,我想将它保存为服务器上sqlite
数据库中的单行,因为没有可用的答案,我不能为此制作任何算法。有人可以帮我制作这个算法,还是可以指导我做任何教程?