海康机器人工业相机录屏例程
#include <opencv2/highgui.hpp>
#include <opencv2/videoio.hpp>
int main()
{
cv::Mat tmp;
while (!capture.
read(tmp))
ERROR_(
"fail to read the image.");
cv::VideoWriter writer("ts.avi", cv::VideoWriter::fourcc('F', 'L', 'V', '1'), 40, tmp.size());
int exposure = 1000;
int gain = 64;
int r_gain = 1200;
int g_gain = 1200;
int b_gain = 1200;
cv::FileStorage fs("out_para.yml", cv::FileStorage::READ);
if (fs.isOpened())
{
fs["exposure"].isNone() ? void(0) : (fs["exposure"] >> exposure);
fs["gain"].isNone() ? void(0) : (fs["gain"] >> gain);
fs["r_gain"].isNone() ? void(0) : (fs["r_gain"] >> r_gain);
fs["g_gain"].isNone() ? void(0) : (fs["g_gain"] >> g_gain);
fs["b_gain"].isNone() ? void(0) : (fs["b_gain"] >> b_gain);
}
cv::Mat frame;
while (capture.
read(frame))
{
imshow("frame", frame);
writer.write(frame);
if (cv::waitKey(1) == 27)
if (cv::waitKey(0) == 27)
break;
}
}
海康机器人相机库
定义 hik_camera.h:35
bool read(cv::OutputArray image)
从相机设备中读取图像
bool set(int propId, double value=0.0)
设置相机参数/事件
@ OpenCV
使用 OpenCV 的 'cvtColor' 进行处理
@ CAMERA_WB_BGAIN
白平衡蓝色分量
定义 camutils.hpp:107
@ CAMERA_WB_GGAIN
白平衡绿色分量
定义 camutils.hpp:106
@ CAMERA_MANUAL_EXPOSURE
手动曝光
定义 camutils.hpp:97
@ CAMERA_EXPOSURE
曝光值
定义 camutils.hpp:102
@ CAMERA_MANUAL_WB
手动白平衡
定义 camutils.hpp:100
@ CAMERA_WB_RGAIN
白平衡红色分量
定义 camutils.hpp:105
@ CAMERA_GAIN
模拟增益
定义 camutils.hpp:103
#define ERROR_(...)
定义 util.hpp:50
static CameraConfig create(Args &&...modes)
创建相机初始化配置模式
定义 camutils.hpp:70