I am always getting a grey screen when showing image using opencv, the image is captured from camera. Any help?
#include "stdafx.h"
#include <opencv2\opencv.hpp>
#include <opencv2\imgcodecs.hpp>
using namespace cv;
cv::Mat takePicture() {
cv::Mat pic;
VideoCapture cam(0);
while (!cam.isOpened()) {
std::cout << "Failed to make connection to cam" << std::endl;
VideoCapture cam(0);
}
cam >> pic;
return pic;
}
int main()
{
cv::Mat pic1;
pic1 = takePicture();
imshow("camera", pic1);
}