Ask Your Question

Locke's profile - activity

2016-10-27 12:56:07 -0600 received badge  Nice Question (source)
2016-10-27 10:18:26 -0600 received badge  Student (source)
2016-10-27 09:52:23 -0600 received badge  Editor (source)
2016-10-27 09:48:45 -0600 commented answer Exporting video from image sequence

You sir, are a gentleman and a scholar. I finally was able to get everything working. I found that my image wasn't actually being converted to gray-scale, it was just very dark for some reason. In order to get everything working I had to change the convertTo function to this:

frame32.convertTo(frame8, CV_8UC3, 550, 25);

This brightened my image and leveled everything out. Thank you for all the help.

I'll include my final solution in the Edited section above

2016-10-27 09:46:22 -0600 received badge  Supporter (source)
2016-10-27 09:44:59 -0600 received badge  Scholar (source)
2016-10-26 11:22:10 -0600 commented answer Exporting video from image sequence

Awesome, its finally exporting video, which is a huge step. My last problem is that the footage is now exporting grey-scale, with only the whitest whites showing up in the final video. Is there a way to convert with the color remaining intact?

I've been able to export the footage with color using -1 in place of the CV_FOURCC input, but I want the user to be able to run the program without having to use any extra steps on their part

2016-10-26 09:17:50 -0600 commented question Exporting video from image sequence

I'm finding that its type 21 (Float CV_32FC3). Is there a way to convert this to a usable format? I'm now getting an error that says "Assertion failed (image->depth == 8)" as well, if that helps

2016-10-25 16:37:39 -0600 asked a question Exporting video from image sequence

Hey guys,

So I'm working on a project that involves the user outputting a series of images that I would like to combine into a single video. Right now, these images are exported as HDR files, but I have tried this with a png sequence as well and run into the same issue. I'm running into an issue with combining these into a video. The images are read in fine, but when I try to open the VideoWriter, something isn't working.

I'm not sure if it has to do with the codec that I'm trying to use (I'll admit to a slight bit of ignorance when it comes to those) or something else entirely. The program does output an empty .AVI video of 0kb, which is obviously wrong.

Any help would be appreciated, so thanks in advance. Let me know if there's anything I can clarify on.

int main()
{

    //Passes through this sequence without any issues
    VideoCapture sequence("data/00001.HDR");
    if (!sequence.isOpened())
    {
        cerr << "Failed to open Image Sequence!\n" << endl;
        return -6;
    }

    double FPS = 60.0;
    int wid = sequence.get(CV_CAP_PROP_FRAME_WIDTH);
    int het = sequence.get(CV_CAP_PROP_FRAME_HEIGHT);

    VideoWriter oVideoWriter;
    oVideoWriter.open("data/MyVideo.avi", CV_FOURCC('F', 'M', 'P', '4'), FPS, Size(wid, het), true);

    //This is where something goes wrong and the program returns a -1
    if (!oVideoWriter.isOpened())
    {
        cout << "ERROR: Failed to write the video" << endl;
        return -1;
    }

    //Larger body of the remainder of the function
    ...

    return 1;
}

Final Solution

This was my final solution, based off of the comment string below.

int main()
{   
    VideoCapture sequence("data/00001.HDR", CAP_IMAGES);

    if (!sequence.isOpened())
    {
        cerr << "Failed to open Image Sequence!\n" << endl;
        return -6;
    }

    double FPS = 60.0;
    int wid = sequence.get(CV_CAP_PROP_FRAME_WIDTH);
    int het = sequence.get(CV_CAP_PROP_FRAME_HEIGHT);

    VideoWriter oVideoWriter;
    oVideoWriter.open("data/MyVideo.avi", CV_FOURCC_DEFAULT, FPS, Size(wid, het));

    if (!oVideoWriter.isOpened())
    {
        cerr << "ERROR: Failed to write the video" << endl;
        return -1;
    }

    Mat frame8;
    Mat frame32;

    try {
        do
        {
            sequence >> frame32;
            if (frame32.empty())
                break;

            frame32.convertTo(frame8, CV_8UC3, 550, 25);

            oVideoWriter.write(frame8);

        } while (!frame32.empty());
    }
    catch (Exception ex) {
        cout << ex.code << " " << ex.msg << endl;
        cin.get();
    }

    return 1;
}