displaying a picture in video

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

displaying a picture in video

Olli-2
Hi,

 

i am trying to display a picture in a video (frame) in a specific position
after using a mask to find that specific position.

(In that video I am holding a red piece of paper which is detected by the
mask.) Is there any opencv function which makes it possible to insert a
picture in that position.  I don't want to manipulate every single frame by
writing every single pixel of the picture I want to insert in the position
of the red piece of paper.

 

Thanks for your help.

 

Best regards

 

olli

 



[Non-text portions of this message have been removed]

Reply | Threaded
Open this post in threaded view
|

Re: displaying a picture in video

Olli-2
Hello,

 

First thank you very much for your help. Unfortunately I still have
problems. Maybe you could help me one more time?

 

Information:

IplImage* frame = the video frame

IplImage* blendFrame = the image I want to display in the video

IplImage* blendFrameSize = the resized blendFrame (its size changes during
the video.according to the red paper in the video)

Int gry = the y position in the video frame where the upper left corner of
the image shall be placed

Int xzugry = the x position in the video frame where the upper left corner
of the image shall be placed

Grx-klx = width of blendFrameSize

Gry-kly = height of blendFrameSize

 

 

This is the code:

 

//1. First I resize the IplImage, which I want to display in the videoframe

      blendFrameSize = cvCreateImage(cvSize(grx-klx,gry-kly),IPL_DEPTH_8U,
3);

      cvResize(blendFrame, blendFrameSize);

      resizeHoehe=gry-kly;

      resizeBreite=grx-klx;

     

 

      IplROI roi1;

      roi1.coi = 0; //'0' for to process on all channels

      roi1.height = resizeHoehe; //the height of the rectangle that you will
put the picture on

      roi1.width = resizeBreite; //the width of the rectangle that you will
put the picture on

      roi1.xOffset = xzugry; //x of the upper left corner of that rectangle

      roi1.yOffset = gry; //y of the upper left corner of that rectangle

 

      frame->roi = &roi1;

      cvResize(blendFrameSize, frame); // this will copy the image on that
ROI

 

 

 

I always get this Message:

 

Image step is wrong ()

In function cvInitMatHeader, . \cxarray.cpp(199)

 

In the debugging mode I get the information that the problem occurs, when I
try to display the "finished" image:

cvShowImage(windowname.c_str(), frame);

 

I really don't understand why - did I misunderstand something?

thanks for your help!

 

Olli

 

 

Hi,

 

First you may define the ROI (Region of Interest) of the video frame as
follows:

...

IplROI roi1;

roi1.coi = 0; //'0' for to process on all channels

roi1.height = height; //the height of the rectangle that you will put the
picture on

roi1.width = width; //the width of the rectangle that you will put the
picture on

roi1.xOffset = 20; //x of the upper left corner of that rectangle

roi1.yOffset = 30; //y of the upper left corner of that rectangle

...

Second, you may set the ROI of the video frame (I assume that is an IplImage
*) as the one you defined...

 

...

frame->roi = &roi1;

...

 

Finally, you may copy the image (assuming the image is also IplImage *) on
that region by,,

...

cvResize(image , frame); // this will copy the image on that ROI

...

 

If you want to use the whole frame again, you should first set the ROI of
the frame to NULL

...

frame->roi = &roi1;

...

 

By changing the ROI, yo can copy any image to the region you want.

 

Hope this helps...

 

 

 

Hi,

i am trying to display a picture in a video (frame) in a specific position
after using a mask to find that specific position.

(In that video I am holding a red piece of paper which is detected by the
mask.) Is there any opencv function which makes it possible to insert a
picture in that position. I don't want to manipulate every single frame by
writing every single pixel of the picture I want to insert in the position
of the red piece of paper.

Thanks for your help.

Best regards

olli






[Non-text portions of this message have been removed]