Issue
I've tried to change the resolution on raspicam v2 with my raspberry pi 4 b, but this code gives me false every time I try to read frame... Is there anything I am missing? I can easily read frames without setting those parameters, but then it gives me really poor resolution.
#include "opencv2/opencv.hpp"
using namespace cv;
int main(int argc, char **argv)
{
VideoCapture cap;
if (!cap.open(0))
return 0;
cap.set(CAP_PROP_FRAME_WIDTH, 1920);
cap.set(CAP_PROP_FRAME_HEIGHT, 1080);
cap.set(CAP_PROP_FPS, 1);
for (;;)
{
Mat frame;
if(cap.read(frame))
{
std::cout << "I'm trying out" << std::endl;
imwrite("test.jpg",frame);
return 0;
} else{
std::cout << "doesn't went as planned" << std::endl;
}
}
return 0;
}
Solution
The problem was in raspi-config
, I thought I've enabled the camera through config.txt, but I've not. so when I've got into the interfaces tab and enabled the camera, everything worked perfectly. Thank you guys for help :)
Answered By - Marcin Wawrzków Answer Checked By - Willingham (WPSolving Volunteer)