Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

libpng warning: Image width is zero in IHDR

hello, I am trying to capture imgae from camera, using code `#include <opencv2 core="" core.hpp="">

include <opencv2 highgui="" highgui.hpp="">

include "opencv2/imgproc/imgproc.hpp"

include <iostream>

using namespace cv; using namespace std;

int main(int, char**) {

VideoCapture cap(0); // open the default camera
cap.set(CV_CAP_PROP_FRAME_WIDTH, 640);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 480);

if(!cap.isOpened())  // check if we succeeded
    return -1;

for(;;)
{
    Mat frame;

    cap >> frame; // get a new frame from camera

    imwrite("C:/Users/ankit/Desktop/12.png", frame);

}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;

}

`but i am getting error like, libpng warning: Image width is zero in IHDR libpng warning: Image height is zero in IHDR libpng error: Invalid IHDR data

please give me any suggesitions to solve this error.

Thank you very much in advace.

click to hide/show revision 2
No.2 Revision

updated 2015-04-18 04:57:34 -0600

berak gravatar image

libpng warning: Image width is zero in IHDR

hello, I am trying to capture imgae from camera, using code `#include <opencv2 core="" core.hpp="">

include <opencv2 highgui="" highgui.hpp="">

include "opencv2/imgproc/imgproc.hpp"

include <iostream>

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>

using namespace cv;
using namespace std;

std; int main(int, char**) {

{


    VideoCapture cap(0); // open the default camera
 cap.set(CV_CAP_PROP_FRAME_WIDTH, 640);
 cap.set(CV_CAP_PROP_FRAME_HEIGHT, 480);

 if(!cap.isOpened())  // check if we succeeded
     return -1;

 for(;;)
 {
     Mat frame;

     cap >> frame; // get a new frame from camera

     imwrite("C:/Users/ankit/Desktop/12.png", frame);

 }
 // the camera will be deinitialized automatically in VideoCapture destructor
 return 0;
}

}

`but but i am getting error like, like,

libpng warning: Image width is zero in IHDR
libpng warning: Image height is zero in IHDR
libpng error: Invalid IHDR data

data

please give me any suggesitions to solve this error.

Thank you very much in advace.

libpng warning: Image width is zero in IHDR

hello, I am trying to capture imgae from camera, using code

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int, char**)
{


    VideoCapture cap(0); // open the default camera
    cap.set(CV_CAP_PROP_FRAME_WIDTH, 640);
    cap.set(CV_CAP_PROP_FRAME_HEIGHT, 480);

    if(!cap.isOpened())  // check if we succeeded
        return -1;

    for(;;)
    {
        Mat frame;

        cap >> frame; // get a new frame from camera

        imwrite("C:/Users/ankit/Desktop/12.png", frame);

    }
    // the camera will be deinitialized automatically in VideoCapture destructor
    return 0;
}

but i am getting error like,

libpng warning: Image width is zero in IHDR
libpng warning: Image height is zero in IHDR
libpng error: Invalid IHDR data

please give me any suggesitions to solve this error.

Thank you very much in advace.