Ask Your Question
-1

Use OpenCV to create a system that integrates a user uploaded image into a pre-made video.

asked 2018-04-27 14:00:06 -0600

calebe gravatar image

updated 2018-04-27 15:01:06 -0600

Would it be possible to use openCV to have a user upload an image, and it is then tracked into a video automatically?

Similar to how Facebook will create "year in review" videos from your own photos on the fly and have them moving/animated/etc.

Example: https://www.youtube.com/watch?v=ODLh4... (starting at 0:20)

In the example video Facebook took several photos from a users profile and integrated them into an animated video in "fun" ways. It was done automatically and while the video is the same for every user, the photos in the video were dynamically unique for each user.

What I'm trying to achieve is the ability to have a user upload a photo and the program takes it and inserts it into an existing video(that I created) and have pre-determined animation data applied to the photo to move it with the videos motion.

edit retag flag offensive close merge delete

Comments

sorry to say so, but this is a "bad" (unclear) question. assume noone here is using facebook.

please try to rephrase it with "what i'm trying to achieve", and without that reference.

berak gravatar imageberak ( 2018-04-27 14:48:33 -0600 )edit

I added a video example and tried to clarify what I hoped to achieve

calebe gravatar imagecalebe ( 2018-04-27 14:55:36 -0600 )edit

please try to explain in words, what your problem is about, put in some effort

(if we need to see a youtube video to explain, we probably wont, so: -1)

berak gravatar imageberak ( 2018-04-27 14:55:49 -0600 )edit

Okay, I added in more words for you. Let me know if that's any clearer! Thank you for your patience and help.

calebe gravatar imagecalebe ( 2018-04-27 15:01:36 -0600 )edit

still sorry to say so, but this site is about using the opencv library, not about "how to replicate something facebook does".

we won't do, what should be your research

berak gravatar imageberak ( 2018-04-27 15:08:37 -0600 )edit

I fully understand what this site is, thanks for reminding me. I'm not asking for someone to do my research, this is part of my research. I was just hoping someone with more experience with openCV could share if this is something that's possible through the openCV library or if I should be looking elsewhere.

That's all.

calebe gravatar imagecalebe ( 2018-04-27 15:52:51 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-04-28 08:19:45 -0600

holger gravatar image

updated 2018-04-28 08:21:48 -0600

Was some good practise for me(i am currently i that area) here the code(tested locally with java and open cv 3.4.1) - translate to c++ or python if u like.

    String videoInputFile = "in.mp4";
    VideoCapture reader = new VideoCapture(videoInputFile);
    double fps = reader.get(Videoio.CAP_PROP_FPS);
    double width = reader.get(Videoio.CAP_PROP_FRAME_WIDTH);
    double height = reader.get(Videoio.CAP_PROP_FRAME_HEIGHT);
    //load image and resize for video
    Mat img = imread("img.jpg");
    resize(img, img, new Size(width, height));

    //carfully with choosing codec and output extension - could be that you need to install codecs
    String outputFileName = "out.avi";
    VideoWriter writer = new VideoWriter();
    int fourcc = VideoWriter.fourcc('M','J','P','G');
    writer.open(outputFileName, fourcc, fps, new Size(width, height));

    //write img on first position
    writer.write(img);
    Mat frame = new Mat();
    //just copy the video
    while(reader.read(frame)) {
        writer.write(frame);
    }
    writer.release();
    reader.release();
edit flag offensive delete link more

Comments

Thank you! I'll take a look at this soon in depth

calebe gravatar imagecalebe ( 2018-04-29 12:05:43 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-04-27 14:00:06 -0600

Seen: 118 times

Last updated: Apr 28 '18