0

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;
}
asked Mar 20, 2021 at 19:48

1 Answer 1

0

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 Mar 21, 2021 at 18:33

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.