int main(int argc, char* argv[]) { int i; namedWindow("Frame"); //////////////////////////////////////////////////// Mat frame_4, frame; //double dWidth = 640; //get the width of frames of the video //double dHeight = 480; //get the height of frames of the video vector<Mat> layers; WebCore* web_core = WebCore::Initialize(WebConfig()); WebView* view = web_core->CreateWebView(WIDTH, HEIGHT); WebURL url(WSLit(URL_polar)); view->LoadURL(url); BitmapSurface* surface; Size frameSize(static_cast<int>(WIDTH), static_cast<int>(HEIGHT)); VideoWriter writer ("polarbearchillin.avi", CV_FOURCC('D','I','V','3'), 15, frameSize, true); //initialize the VideoWriter object for(int i=0; i<1000000; i++) //delay is added to pass advertisement on some of the URLs { web_core->Update(); } /////////////////////////////////////////////////// if ( !writer.isOpened() ) //if not initialize the VideoWriter successfully, exit the program { cout << "ERROR: Failed to write the video" << endl; return -1; } while(i != 27) { //////////////////////////////////////////////// web_core->Update(); surface = (BitmapSurface*)view->surface(); frame_4 = Mat(Size(WIDTH, HEIGHT), CV_8UC4, (unsigned char*)surface->buffer(), Mat::AUTO_STEP); split(frame_4, layers); layers.pop_back(); merge(layers, frame); //////////////////////////////////////////////// writer.write(frame); //writer the frame into the file imshow("Frame", frame); i=waitKey(30); } /////////////////////// view->Destroy(); WebCore::Shutdown(); /////////////////////// destroyAllWindows(); return 0; }
const BitmapSurface* surface()const { return static_cast<BitmapSurface*>(view_->surface()); };