Ask Your Question

margaridamfo.gomes's profile - activity

2020-06-29 08:03:50 -0600 received badge  Notable Question (source)
2018-01-24 22:28:30 -0600 received badge  Popular Question (source)
2015-03-24 03:43:51 -0600 received badge  Supporter (source)
2015-03-02 11:51:59 -0600 commented question Detection of Black Pixels in Video

Using the mask and the function inRange() it doesn't return anything.

And using my solution even when the frame is black, it's cloned.

2015-03-02 11:04:03 -0600 commented question Detection of Black Pixels in Video

Is something like this correct?

            split(frame, bgrChannels); // split multi-channels into single-channel

            if (countNonZero(bgrChannels[0]) > 0
                    && countNonZero(bgrChannels[1]) > 0
                    && countNonZero(bgrChannels[2]) > 0) {
                black_frames = frame.clone();
                namedWindow("OutputVideo", WINDOW_AUTOSIZE);
                imshow("OutputVideo", black_frames);
                outputVideo.write(black_frames);
            }
2015-03-02 10:11:30 -0600 commented question Detection of Black Pixels in Video

But my frames have 3 channels. So I'll need to call the countnonzero() function for every channel?

I tried to set a timer. Like http://stackoverflow.com/questions/22148826/measure-opencv-fps but it doesn't return a correct fps.

2015-03-02 08:48:22 -0600 commented question Detection of Black Pixels in Video

Thanks :) I finally realized what you already tried to tell me. Any suggestion on the other thing?

2015-03-02 08:37:56 -0600 commented question Detection of Black Pixels in Video

So do something like total frames / total time of my video? And then do the rest?

2015-03-02 07:43:19 -0600 asked a question Detection of Black Pixels in Video

Hi everyone!

I still have problems with the property FPS, because I can't get it autocatically.

[avi @ 0x8e14540] time base not set
Could not open the output video for write: /home/margarida/Output.avi

Additionally, my goal is only to find colour frames, i.e. I need to remove all the frames constituted with black pixels from my input videos. And I get the error:

Segmentation fault (core dumped)

Does anyone detects any error? Or as a solution for my problems? Thanks in advance.

My code is:

int main(int argc, char* argv[]) {
    VideoCapture cap;
    VideoWriter outputVideo;
    string name;
    Mat frame;
    int j;

    for (j = 1; j < argc; j++) {

        printf("%d: %s\n", j, argv[j]);

        string str1 = argv[j];
        unsigned found = str1.find_last_of("/");
        name = str1.substr(0, found);
        string newname = name + "/Output.avi";
        cout << newname << '\n';

        cap.open(argv[j]);
        if (!cap.isOpened()) {
            cout << "Could not open the input video: " << argv[j] << endl;
            return -1;
        }

        //codec type
        int ex = CV_FOURCC('X', 'V', 'I', 'D');
        //transform from int to char via Bitwise operators
        char EXT[] = { (char) (ex & 0XFF), (char) ((ex & 0XFF00) >> 8),
                (char) ((ex & 0XFF0000) >> 16),
                (char) ((ex & 0XFF000000) >> 24), 0 };

        cout << "Input Codec: " << EXT << endl;

        //acquire input size
        Size S = Size((int) cap.get(CV_CAP_PROP_FRAME_WIDTH),
                (int) cap.get(CV_CAP_PROP_FRAME_HEIGHT));

        //get fps
        //double fps = cap.get(CV_CAP_PROP_FPS);

        // Open the output
        //outputVideo.open(newname, ex, fps, S, true);
        outputVideo.open(newname, ex, 13, S, true);

        if (!outputVideo.isOpened()) {
            cout << "Could not open the output video for write: " << newname
                    << endl;
            return -1;
        }

        while (true) {
            cap >> frame;
            if (frame.empty()) {
                cerr << "didnt catch frame" << endl;
                break;
            }

            for (int i = 0; i < frame.cols; i++) {
                for (int j = 0; j < frame.rows; j++) {

                    //if all the pixels != 0 [black] - clone frame
                    if ((frame.at < Vec3b > (i, j).val[0] != 0)
                            && (frame.at < Vec3b > (i, j).val[1] != 0)
                            && (frame.at < Vec3b > (i, j).val[2] != 0)) {

                        Mat frame1 = frame.clone();

                        imshow("Output", frame1);
                        out.write(frame1);

                    }
                }
            }
        }

        return 0;
    }
2015-02-18 05:11:26 -0600 commented question Problems writing multiple .avi files

No, that's not the final goal, I'm just trying to learn how it works and then process the information of my videos (I don't know how I'm going to deal also). But this is essencial, because my result is to have compressed videos and if I don't have the output videos I can do nothing.

First I was using H264 but it doesn't work, now I'm trying XVID and I can't understand how can I fix the FPS problem.

2015-02-18 05:00:54 -0600 commented question Problems writing multiple .avi files

My data doesn't have the same FPS so I don't know how I'm going to fix this. Because like this, for example, if I gave 3 arguments, the ./blabla + 2 videos: the first video will be save, but the second won't, because it doens't have the same FPS and again I'm facing the Could not demultiplex stream.

2015-02-18 04:55:35 -0600 commented question Problems writing multiple .avi files

The input it isn't the webcam.

So I can't have multiple argv[] when I run the program? Because I need to set a writer for every file? And so I can't make it automatically?

2015-02-18 04:20:11 -0600 commented question Problems writing multiple .avi files

That isn't a problem at all.

My only problem is with FPS. Because as it is in my code it doesn't work, the cap.get(CV_CAP_PROP_FPS) doesn't return the FPS. So I get the error

[avi @ 0x8e14540] time base not set
Could not open the output video for write: /home/margarida/Output.avi
2015-02-17 17:31:48 -0600 commented answer Ubuntu OpenCV VideoWriter using ffmpeg with “Could not open codec 'libx264'” Error

My problem stays with the FPS, the get doesn't work. Can you please explain me again how can I return FPS the way you suggested above?

2015-02-17 17:28:42 -0600 asked a question Problems writing multiple .avi files

Hi everyone!

I'm using the latest 2.4 branch withou ffmpeg and Ubuntu 14.04 and I don't have at all ffmpeg in my Virtual Machine.

My previous goal was to write .mp4 video files, but now the challenge is to write files with AVI container and with XVID codec.

I was commenting in this post: http://answers.opencv.org/question/32...

So now I'm having problems with the property FPS.

[avi @ 0x8e14540] time base not set
Could not open the output video for write: /home/margarida/Output.avi

My .get doesn't work, so how can I get the correct FPS automatically?

My code is this:

int main(int argc, char* argv[]) {
    VideoCapture cap;
    VideoWriter outputVideo;
    string name;
    Mat frame;
    int j;

        for (j = 1; j < argc; j++) {

            printf("%d: %s\n", j, argv[j]);

            string str1 = argv[j];
            unsigned found = str1.find_last_of("/");
            name = str1.substr(0, found);
            string newname = name + "/Output.avi";
            cout << newname << '\n';

            cap.open(argv[j]);
            if (!cap.isOpened()) {
                cout << "Could not open the input video: " << argv[j] << endl;
                return -1;
            }

            //codec type
            int ex = CV_FOURCC('X', 'V', 'I', 'D');
            //transform from int to char via Bitwise operators
            char EXT[] = { (char) (ex & 0XFF), (char) ((ex & 0XFF00) >> 8),
                    (char) ((ex & 0XFF0000) >> 16), (char) ((ex & 0XFF000000)
                            >> 24), 0 };

            cout << "Input Codec: " << EXT << endl;

            //acquire input size
            Size S = Size((int) cap.get(CV_CAP_PROP_FRAME_WIDTH),
                    (int) cap.get(CV_CAP_PROP_FRAME_HEIGHT));

            //get fps
            double fps = cap.get(CV_CAP_PROP_FPS);

            // Open the output
            outputVideo.open(newname, ex, fps, S, true);

            if (!outputVideo.isOpened()) {
                cout << "Could not open the output video for write: " << newname
                        << endl;
                return -1;
            }

            while (true) {
                cap >> frame;
                if (frame.empty()) {
                    cerr << "didnt catch frame" << endl;
                    break;
                }

                imshow("OUTPUT", frame);

                outputVideo.write(frame);

            }
        }

    return 0;
}
2015-02-17 11:53:41 -0600 commented answer Ubuntu OpenCV VideoWriter using ffmpeg with “Could not open codec 'libx264'” Error

Another thing that I experimented: it only works if give the path of the file in the program. If I just write cap.open(argv[i]) it doesn't work.

What I am trying to say it is that when I run the program in the terminal it only works if it has only argv[0].

Is this the only way? Can't I give the argv[i]?

2015-02-17 09:29:01 -0600 commented answer Ubuntu OpenCV VideoWriter using ffmpeg with “Could not open codec 'libx264'” Error

But it doesn't work. I'm getting this error:

[avi @ 0x9438480] time base not set

And I just experimented specifying a FPS and it returns something. But I'm not supposed to guess and write the FPS for every file. Can't it be done automatically?

And another thing, when my program ends the result is a .avi file, with 0 Kb and the error I get is:

Could not demultiplex stream.
2015-02-17 08:39:06 -0600 commented answer Ubuntu OpenCV VideoWriter using ffmpeg with “Could not open codec 'libx264'” Error

I'm dealing with a lot of files, so I can't specify the FPS because all the FPS are different from file to file.
For the VideoWriter I have this:

outputVideo.open(newname, ex, cap.get(CV_CAP_PROP_FPS), S, true);

This should work right?

2015-02-17 08:04:15 -0600 commented answer Ubuntu OpenCV VideoWriter using ffmpeg with “Could not open codec 'libx264'” Error

But if I use the XVID codec with AVI container my output files get a higher frame rate then the input file. That is, the input video properties are lost and the new video does not become as desired.

How I can keep these properties?

2015-02-17 06:04:59 -0600 commented answer Ubuntu OpenCV VideoWriter using ffmpeg with “Could not open codec 'libx264'” Error

Does my problem have a solution? I really need to solve this and I don't know how. If the output that I gave is not enough please tell me what else do I need to give.

2015-02-16 08:38:25 -0600 commented question Can't write .mp4 files - Could not open codec 'libx264': Unspecified error

Is there any information missing? Please help!

2015-02-10 10:32:39 -0600 received badge  Student (source)
2015-02-09 06:28:37 -0600 received badge  Editor (source)
2015-02-09 06:25:49 -0600 commented answer Ubuntu OpenCV VideoWriter using ffmpeg with “Could not open codec 'libx264'” Error

My output is:

[libx264 @ 0x9357bc0] broken ffmpeg default settings detected
[libx264 @ 0x9357bc0] use an encoding preset (e.g. -vpre medium)
[libx264 @ 0x9357bc0] preset usage: -vpre <speed> -vpre <profile>
[libx264 @ 0x9357bc0] speed presets are listed in x264 --help
[libx264 @ 0x9357bc0] profile is optional; x264 defaults to high
Could not open codec 'libx264': Unspecified error
Could not open the output video for write: /home/margarida/exams_2014/Output.mp4

http://answers.opencv.org/question/54...

2015-02-09 06:24:21 -0600 asked a question Can't write .mp4 files - Could not open codec 'libx264': Unspecified error

Hi everyone!

Days ago I installed the latest 2.4 branch withou ffmpeg. I'm using Ubuntu 14.04 and I don't have at all ffmpeg in my Virtual Machine.

I want to write .mp4 video files and the input files are also .mp4. The input codec is avc1.

I can't obtain any results, the errors can be seen below.

Error:

[libx264 @ 0x9357bc0] broken ffmpeg default settings detected
[libx264 @ 0x9357bc0] use an encoding preset (e.g. -vpre medium)
[libx264 @ 0x9357bc0] preset usage: -vpre <speed> -vpre <profile>
[libx264 @ 0x9357bc0] speed presets are listed in x264 --help
[libx264 @ 0x9357bc0] profile is optional; x264 defaults to high
Could not open codec 'libx264': Unspecified error
Could not open the output video for write: /home/margarida/exams_2014/Output.mp4

Simplified Code:

        int main(int argc, char *argv[]) {
            VideoWriter outputVideo;

            // Get Codec Type
            int ex = static_cast<int>(cap.get(CV_CAP_PROP_FOURCC));

            // Transform from int to char via Bitwise operators
            char EXT[] = { (char) (ex & 0XFF), (char) ((ex & 0XFF00) >> 8),
                            (char) ((ex & 0XFF0000) >> 16), (char) ((ex & 0XFF000000)
                                    >> 24), 0 };

            // Acquire input size
            Size S = Size((int) cap.get(CV_CAP_PROP_FRAME_WIDTH),
                            (int) cap.get(CV_CAP_PROP_FRAME_HEIGHT));

            cout << "Input codec type: " << EXT << endl;

            // Open the output
            outputVideo.open(newname, ex, cap.get(CV_CAP_PROP_FPS), S, true);

            if (!outputVideo.isOpened()) {
                cout << "Could not open the output video for write " << endl;
                        return -1;
                    }

                    while (true) {
                        cap >> frame;
                        if (frame.empty()) {
                            cerr << "nao apanhou frame" << endl;
                            break;
                        }

                        cinzento = acinzentar(frame);
                        imshow("Cinzento", cinzento);

                        outputVideo.write(cinzento);

                        switch(waitKey(10)){

                        case 27:
                            //'esc' has been pressed (ASCII value for 'esc' is 27)
                            //exit program.
                            return 0;

                        }
                    }
                   return 0;
                }

My cmake was this:

cmake -D WITH_TBB=ON -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_VTK=ON -D WITH_FFMPEG=OFF -D WITH_IPP=OFF ..

Can anyone help solving my problem? Thanks in advance :)

If there is no solution please respond.

2015-02-06 09:25:00 -0600 commented answer Ubuntu OpenCV VideoWriter using ffmpeg with “Could not open codec 'libx264'” Error

I grabbed the lastest 2.4 branch from Github and removed ffmpeg from my system, so no sign of ffmpeg. But I still have this problem, I can't write videos with the codec H.264 with the container .mp4.

2015-02-06 06:07:18 -0600 received badge  Enthusiast
2015-02-06 06:07:18 -0600 received badge  Enthusiast
2015-02-06 06:07:18 -0600 received badge  Enthusiast
2015-02-04 07:56:25 -0600 commented question Installing Opencv from Git on Ubuntu 14.04

Thank you so much Steven! Your suggestion worked :)

2015-02-03 17:15:19 -0600 asked a question Installing Opencv from Git on Ubuntu 14.04

I'm having problems with installing opencv. I installed the dependencies and then I got opencv from git and cloned it. Then I created a build directory and ran the command cmake:

cmake -D WITH_FFMPEG=OFF -DWITH_QT=ON -DWITH_OPENGL=ON -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_XINE=ON -DBUILD_EXAMPLES=ON ..

The result from make was image description

I don't know how to fix this, please help. Thanks in advance :)

2015-01-28 16:46:45 -0600 commented answer Ubuntu OpenCV VideoWriter using ffmpeg with “Could not open codec 'libx264'” Error

Can you explain how can I install opencv 2.4.10? Because I tried all day and I can't do the step make, it stands on 0%.

2015-01-27 22:28:09 -0600 answered a question Ubuntu OpenCV VideoWriter using ffmpeg with “Could not open codec 'libx264'” Error

I also have this problem. I'm using opencv 2.4.9. on Ubuntu 14.04.

StevenPuttemans, you say that if I remove ffmpeg that it will work? And it could write the videos?