#include <unistd.h>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
using namespace std;
int exposure = 1000;
int gain = 64;
int r_gain = 100;
int g_gain = 100;
int b_gain = 100;
void exposureCallBack(int pos, void *)
{
exposure = pos;
}
void gainCallBack(int pos, void *)
{
gain = pos;
}
void rGainCallBack(int pos, void *)
{
r_gain = pos;
}
void gGainCallBack(int pos, void *)
{
g_gain = pos;
}
void bGainCallBack(int pos, void *)
{
b_gain = pos;
}
int main()
{
FileStorage fs("out_para.yml", FileStorage::READ);
if (fs.isOpened())
{
}
namedWindow("图像画面", WINDOW_NORMAL);
namedWindow("控制面板", WINDOW_AUTOSIZE);
Mat track_bar_img(Size(750, 1), CV_8UC1, Scalar(60, 60, 60));
createTrackbar("曝光值", "控制面板", nullptr, 10000, exposureCallBack, nullptr);
setTrackbarPos("曝光值", "控制面板", exposure);
createTrackbar("增益值", "控制面板", nullptr, 256, gainCallBack, nullptr);
setTrackbarPos("增益值", "控制面板", gain);
createTrackbar("红通道", "控制面板", nullptr, 200, rGainCallBack, nullptr);
setTrackbarPos("红通道", "控制面板", r_gain);
createTrackbar("绿通道", "控制面板", nullptr, 200, gGainCallBack, nullptr);
setTrackbarPos("绿通道", "控制面板", g_gain);
createTrackbar("蓝通道", "控制面板", nullptr, 200, bGainCallBack, nullptr);
setTrackbarPos("蓝通道", "控制面板", b_gain);
sleep(1);
[[maybe_unused]] int ch = system("clear");
const char *file_name = "out_para.yml";
printf("Press the 's' key to save the parameters to the yaml file: \033[33m%s\033[0m\n", file_name);
Mat frame;
if (!cap.read(frame))
return -1;
resizeWindow("图像画面", Size(frame.cols * 0.8, frame.rows * 0.8));
while (true)
{
if (!cap.read(frame))
continue;
imshow("图像画面", frame);
imshow("控制面板", track_bar_img);
char c = waitKey(1);
if (c == 27)
{
if (waitKey(0) == 27)
break;
}
else if (c == 's')
{
FileStorage fs(file_name, FileStorage::WRITE);
fs.write("exposure", exposure);
fs.write("gain", gain);
fs.write("r_gain", r_gain);
fs.write("g_gain", g_gain);
fs.write("b_gain", b_gain);
printf("\033[32mSuccess to write the parameters into \"%s\"\033[0m\n", file_name);
printf(" -- exposure: %d\n", exposure);
printf(" -- gain: %d\n", gain);
printf(" -- r_gain: %d\n", r_gain);
printf(" -- g_gain: %d\n", g_gain);
printf(" -- b_gain: %d\n", b_gain);
}
}
return 0;
}
@ CAP_PROP_RM_WB_BGAIN
白平衡蓝色分量 Blue channel gain of white balance
Definition: camera_define.h:63
@ CAP_PROP_RM_WB_RGAIN
白平衡红色分量 Red channel gain of white balance
Definition: camera_define.h:61
@ CAP_PROP_RM_EXPOSURE
曝光值 Expusure
Definition: camera_define.h:58
@ CAP_PROP_RM_MANUAL_EXPOSURE
手动曝光 Manual exposure
Definition: camera_define.h:56
@ CAP_PROP_RM_GAIN
模拟增益 Analog gain
Definition: camera_define.h:59
@ CAP_PROP_RM_MANUAL_WB
手动白平衡 Manual white balance
Definition: camera_define.h:57
@ CAP_PROP_RM_WB_GGAIN
白平衡绿色分量 Green channel gain of white balance
Definition: camera_define.h:62
@ RETRIEVE_CV
使用 OpenCV 的 'cvtColor' 进行处理 Retrieve using cvtColor function in OpenCV
Definition: camera_define.h:39
@ GRAB_CONTINUOUS
连续采样 Continuous grabbing
Definition: camera_define.h:29
void readExcludeNone(const _FileNode &n, Tp &t)
参数读取,忽略为空的节点
Definition: loader.hpp:41
MindVision camera driver header file
Definition: uty_math.hpp:63
Definition: camera.hpp:23
Definition: camera_define.h:19