I am new to OpenCV and have been trying to figure everything out through tutorials and online documentation but I have run into a bit of an issue, most likely stemming from my imperfect understanding of how Visual studio grabs and uses header files.
My end goal is simply to adjust the exposure time of a video stream so that it will be lighter and I can actually track the objects I want. It has gotten me deeper into trying to understand everything though so here is my issue.
- I understand that the old C API headers are obsolete now and that I should be using the C++ API. I also know they are in the same folder for compatibility. My confusion is in whether both old and new headers will be loaded when i set the path to build\include\opencv2 and whether that will cause issues. I have been looking around for the code to change exposure and have found many different functions but none seem to have worked. I tried
set(CV_CAP_PROP_EXPOSURE, 150); cap.set(CV_CAP_PROP_EXPOSURE, 150); cvSetCaptureProperty(cap, CV_CAP_PROP_EXPOSURE, 480);
- among others. any help on which is current would be great
My code is below. Sorry for the length of post. I am happy to put in the work but I have run into a wall. I have loaded and moved the headers several times trying to figure out.
- Also, if a header is linked in the Solution Explorer does that mean you don't have to "#include<module.hpp>" it?
//#include < opencv\cv.h>
//#include < opencv\highgui.h>
include < opencv2\opencv.hpp>
//#include < opencv2\core\cvdef.h>
//#define CV_WRAP
using namespace cv;
using namespace std;
int main(){
//create matrix to store image
Mat image;
//initialize capture
VideoCapture cap;
cap.open(0);
//create window to show image
cvNamedWindow("window", WINDOW_NORMAL);
cap.set( CV_CAP_PROP_FRAME_WIDTH, 2048);
cap.set( CV_CAP_PROP_FRAME_HEIGHT, 1536);
while (1){
//copy webcam stream to image
cap >> image;
//print image to screen
imshow("window", image);
//part I'm struggling with
set(CV_CAP_PROP_EXPOSURE, 150);
//delay 33ms
waitKey(33);
//print camera brightness setting
switch (waitKey(10)){
case 27:
//'esc' has been pressed (ASCII value for 'esc' is 27)
//exit program.
return 0;
}
}
return 0;}