Ask Your Question

developer2000's profile - activity

2018-02-19 11:10:55 -0600 edited question Alpha channel changed on OpenCV python

Alpha channel changed on OpenCV python I have an imgae with alpha channel. The alpha value is equal to 1. for all foregr

2018-02-19 10:55:13 -0600 received badge  Editor (source)
2018-02-19 10:55:13 -0600 edited question Alpha channel changed on OpenCV python

Alpha channel changed on OpenCV python I have an imgae with alpha channel. The alpha value is equal to 1. for all foregr

2018-02-19 10:54:42 -0600 asked a question Alpha channel changed on OpenCV python

Alpha channel changed on OpenCV python I have an imgae with alpha channel. The alpha value is equal to 1. for all foregr

2015-03-23 05:51:21 -0600 received badge  Student (source)
2014-09-29 09:09:16 -0600 asked a question Write a video from a list of grey scale images using opencv

Hello, I have a list of images named like this img_001,img_002,...,img_154. I want to write a video using this list of images. I code using Qt on mac os 10.9.5 Here is my code

  #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/opencv.hpp>
#include<string.h>
using namespace cv;
using namespace std;

int main()
{
    //Read sequence of images
    Size frameSize(1360,1024);
    Mat dst;//dst image
    Size size(800,600);
    //cout<<path<<endl;
    VideoCapture sequence("/Users/xxxxx/Documents/QtProject/xxxxx/build-getVideo-Desktop_Qt_5_3_clang_64bit-Debug/images/img_%03d.png");
    if (!sequence.isOpened())
       {
           cerr << "Failed to open Image Sequence!\n" << endl;
           return -1;
       }
    //Write video
    VideoWriter oVideoWriter ("/Users/xxxxx/Documents/QtProject/xxxxx/build-getVideo-Desktop_Qt_5_3_clang_64bit-Debug/renameimages/MyVideo.avi",CV_FOURCC('8','B','P','S'), 4
                              , frameSize);
    Mat imageGrey;
    if(!oVideoWriter.isOpened())
    {
      cout<<"ERROR: Failed to write the video"<<endl;
      return -1;
    }
    Mat Image;
    int i=0;
    while(true)
    {
    sequence>>Image;
    namedWindow( "Display frame",CV_WINDOW_AUTOSIZE);
    resize(Image,Image,Size(Image.cols/2, Image.rows/2));//resize image
    imshow("Display frame", Image);
    waitKey(0);
    if(Image.empty())
        break;
    cout<<i<<endl;
    Mat imageArr[] = {Image, Image, Image};
    merge(imageArr, 3, imageGrey);
    //cvtColor(Image,imageGrey,CV_GRAY2BGR);
    oVideoWriter.write(imageGrey);
    i++;
    }
    cout<<"video written!"<<endl;
    return 1;
}

I am getting this warning WARNING: Couldn't read movie file /Users/xxxxx/Documents/QtProject/xxxxx/build-getVideo-Desktop_Qt_5_3_clang_64bit-Debug/images/img_%03d.png and the program is freezed.