Ask Your Question
1

play video within video

asked 2015-07-15 03:22:39 -0500

Prem gravatar image

updated 2015-07-15 06:57:39 -0500

Here is my code which overlays an image ( replace1.jpg) on live camera feed. how can I play a video ( say .avi ) file in the specified area ? or what if I would like to play a sound ?

       Mat repImage = imread("replace1.jpg");
                vector<Point2f> imagePoints = { Point2f(0, 0), Point2f(repImage.cols, 0),                     Point2f(repImage.cols, repImage.rows), Point2f(0, repImage.rows), };

                Mat transmix = getPerspectiveTransform(imagePoints, newLEDPoints);
                warpPerspective(repImage, cameraFeed, transmix, cameraFeed.size(), cv::INTER_LINEAR, cv::BORDER_TRANSPARENT);

If I would like to play replace1.avi instead of displaying replace1.jpg how can it be possible?image description

edit retag flag offensive close merge delete

Comments

I don't really understand what you're trying to achieve with this code. You're applying a perspective transformation but you don't need that to overlay an image... Anyway, what do you mean by playing video, showing it? Then you just need to use the matrix that is storing the corresponding frames

LorenaGdL gravatar imageLorenaGdL ( 2015-07-15 06:08:55 -0500 )edit

@Lorena GdL this is part of an AR solution which needs to do perspective transformation. I identify the coordinates of markers in Live camera feed (newLEDPoints in code) and need to display additional information ( image replace1.jpg) at the position defined by markers. This is working fine. Now I would like to play a video within live camera frame at position defined by vertices of rectangle stored in newLEDPoints. I have added image in the question for clarity As you can see four points have been identified in Live Camera Feed and an image has been displayed after perspective transformation. If I would like to play a .avi file instead of displaying simple image on top of live camera feed, how can I do so?

Prem gravatar imagePrem ( 2015-07-15 06:53:01 -0500 )edit

As I said, you just need to replace the matrix containing the static image by the matrix containing the corresponding video frame, i.e. instead of using the Mat repImage use the Mat frame which is storing frames through the VideoCapture class: VideoCapture cap("myvideo.avi"); Mat frame; for(;;){ cap >> frame;}

You'll just need to be careful with synchronization and so on

LorenaGdL gravatar imageLorenaGdL ( 2015-07-15 07:06:06 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2015-07-15 09:58:09 -0500

Karthikeyan gravatar image

This is what you are asking please check the link, Simplar 2D AR. It would be useful. In the link they were using arcane C-api's. You can convert it to c++ and it is perfectly working.

There are options for,

1.Showing an Image over the pattern.

2.Playing a Clip over the pattern.

3.Marking the pattern.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-07-15 03:22:39 -0500

Seen: 208 times

Last updated: Jul 15 '15