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.