Mario
Mario

Reputation: 1469

create a window opencv

Happy new year.

I'm working on a project which I want to do now is to make a big black window and in order to put in the middle the capturing video. I have captured the video already with its window and now I want to create a new window but bigger than the first one and I want to put in the middle of this window the captured frame video.

Now my problem is that I'm getting the same size of the first window that I made which I want a window has bigger size than the captured frame, so let's suppose a captured a frame and around it a black space. My aim is to make a new one which is bigger and the background is black and in the middle the captured frame?

This is what I'm doing, here is the code

    cvNamedWindow("stabilized image", CV_WINDOW_AUTOSIZE );
    IplImage* image = cvCreateImage(cvSize(900,650),IPL_DEPTH_8U,3);

    cvZero( image );
    image=cvCloneImage(frame);

    cvShowImage("stabilized image", image );

Upvotes: 1

Views: 12423

Answers (2)

Adi Shavit
Adi Shavit

Reputation: 17265

You should cvCopy() your captured frame into (the center of) your black frame.
Set a ROI of the same size as your source frame positioned in the center of your black frame, and cvCopy() into it.

Upvotes: 2

Christian
Christian

Reputation: 1892

A window created with cvNamedWindow will have the size of the image when you set CV_WINDOW_AUTOSIZE.

To resize it you have to do it with:

cvResizeWindow(const char* name, int width, int height)

So this should make it:

cvNamedWindow("stabilized image", CV_WINDOW_AUTOSIZE );
IplImage* image = cvCreateImage(cvSize(900,650),IPL_DEPTH_8U,3);

cvZero( image );
image=cvCloneImage(frame);

cvShowImage("stabilized image", image );
cvResizeWindow("stabilized image", 1024, 768);

Check also:

http://opencv.willowgarage.com/documentation/user_interface.html?highlight=cvnamedwindow#cvNamedWindow

Upvotes: 1

Related Questions