Example #1
0
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;
}
Example #2
0
	// Inherited from Application::Listener
	virtual void OnLoaded() 
	{
	//	view_ = View::Create(800, 600, windowHandle_);
		view_ = app_->web_core()->CreateWebView(800, 600);

		//WebView* web_view = view_->web_view();
		view_->SetTransparent(true);

		BindMethods(view_);

		WebURL url(WSLit("file:///C:/_git/Dia/Cluiche/AwesomiumTest/app.html"));
		view_->LoadURL(url);

		while (view_->IsLoading())
			app_->web_core()->Update();

		Sleep(300);
		app_->web_core()->Update();

		isFinished = true;
	}