Unable to get the image from the webcam in a separate file. The output does not work at all any files in the folder where the expected photos. I tried to change the resolution, change cameras, use IplImage instead of Mat If I use IplImage , I get a completely gray image.
void ShowCam(int CameraToBeOpened) { int i = 0; cv::Mat frame; cv::VideoCapture cap(CameraToBeOpened); cvNamedWindow("Camera", CV_WINDOW_NORMAL); while (true) { if (cap.read(frame)) imshow("Camera", frame); char c = cvWaitKey(50); if (c == 27) break; if (c == 32) { char filename[200]; sprintf_s(filename, "\Test pictures\test_%d.jpg", i); i++; cv::imwrite(filename, frame); std::cout << "Image has been captured" << std::endl; } } cvDestroyAllWindows();
cv::imwritebefore checking the result in the folder? - αλεχολυτstd::cout << "Image has been captured" << std::endl;and it works out every time - zhuk