当前位置:网站首页>weishi相机显示
weishi相机显示
2022-06-26 00:26:00 【ooolmf】
void MVCamra::showCam()
{
//if (r == MVST_SUCCESS) return;
MVSTATUS_CODES r;
r = MVInitLib();
if (r != MVST_SUCCESS)
{
::MessageBox(NULL, _T("初始化失败 "), _T("错误"), MB_OK);
return;
/*cout << "初始化失败 " << "原因:" << MB_ICONWARNING << endl;*/
}
//查找连接到计算机上的相机数量
int numberofCams = 0;
MVGetNumOfCameras(&numberofCams);
//cout << numberofCams << endl;
if (numberofCams == 0)
{
::MessageBox(NULL, _T("没有发现相机! "), _T("错误"), MB_OK);
return;
}
else
{
//MessageBox(NULL, _T("发现相机! "), _T("正确"), MB_OK);
}
cam.hCam = NULL;
MVOpenCamByIndex(0, &cam.hCam);//打开相机,返回相机句柄
if (cam.hCam != NULL)
{
/*cout << "已经打开相机!" << endl;*/
}
//设置图像像素格式
cam.pixelformat = PixelFormat_BayerRG8;
MVSetPixelFormat(cam.hCam, cam.pixelformat);
//设置当前帧率
double fps = 40;
MVSetFrameRate(cam.hCam, fps);
//设置曝光时间
MVSetAutoExposureTimeLowerLimit(cam.hCam, 10);
MVSetAutoExposureTimeUpperLimit(cam.hCam, 300000);
//设置期望亮度
MVSetAutoTargetValue(cam.hCam, 128);
//设置亮度容差
MVSetAutoThreshold(cam.hCam, 0.3);
//设置触发方式
MVSetTriggerMode(cam.hCam, TriggerMode_Off);
//设置及获取图像宽高
int ww = 1600, hh = 1200;
MVSetWidth(cam.hCam, ww);
MVSetHeight(cam.hCam, hh);
MVGetWidth(cam.hCam, &ww);
MVGetHeight(cam.hCam, &hh);
//获取图像格式
MVGetPixelFormat(cam.hCam, &cam.pixelformat);
cam.mvimage.CreateByPixelFormat(ww, hh, cam.pixelformat);
//MVSetExposureTime(cam.hCam, 24000);
while (1)
{
//相机开始工作采集视频流(传输速率太快 会有丢帧 不影响性能)
MVSTATUS_CODES y;
if (dt.index <= 12 && dt.index >= 0)
{
//DLPC350_SetLedCurrents(30, 30, 30);
DLPC350_LoadImageIndex(dt.index);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
//cv::waitKey(10);
y = MVStartGrab(cam.hCam, StreamCB, (ULONG_PTR)this);
if (calib_button_flag/*&&dt.index >= 0*/)
{
grating.src_grating[dt.index] = cam.src.clone();
}
/*if (dt.index <= 9 && dt.index >= 0) cv::imwrite("F://cvs//image//0//0" + to_string(dt.index) + ".bmp", grating.src_grating[dt.index ]); else cv::imwrite("F://cvs//image//0//" + to_string(dt.index) + ".bmp", grating.src_grating[dt.index ]);*/
//cv::cvtColor(cam.src, grating.src_grating[dt.index - 1], CV_BGR2GRAY);
if (dt.index <= 9 && dt.index >= 0)
cv::imwrite("E://dlpcam//0" + to_string(dt.index) + ".bmp", grating.src_grating[dt.index ]);
else
cv::imwrite("E://dlpcam//" + to_string(dt.index) + ".bmp", grating.src_grating[dt.index ]);
//cv::waitKey(50);
dt.index++;
}
else
{
DLPC350_LoadImageIndex(0);
y = MVStartGrab(cam.hCam, StreamCB, (ULONG_PTR)this);
}
//if(dt.index >=13)DLPC350_LoadImageIndex(0);
//std::this_thread::sleep_for(std::chrono::milliseconds(60));
}
//关闭视频流
MVStopGrab(cam.hCam);
//关闭相机
MVCloseCam(cam.hCam);
}
边栏推荐
- 宁要一个完成,不要千万个开始(转载自豆瓣)
- PTA class a simulation bomb 10: 1119-1123
- 求n的乘阶
- Multi type study of Worthington collagen protease
- It's better to finish one than start thousands of times (reprinted from Douban)
- 如何使用命令将文件夹中的文件名(包括路径)写入到txt文件中
- tos cos dscp 区别和作用
- memory leak check tools 详解
- Talking about interface test (2)
- The 19th - 22nd week of scientific research training - about tnet and memnet
猜你喜欢

A lost note for konjaku beginner

热血男孩滕文泽 受邀担任第六季完美童模全球总决赛形象大使

biggan:large scale gan training for high fidelity natural image synthesis

Sunshine boy chenhaotian was invited to be the spokesperson for the global finals of the sixth season perfect children's model

Abnova CSV monoclonal antibody solution

Easy to understand C language keyword static

Chrome浏览器开发者工具使用

Differences and functions of TOS cos DSCP

CyCa children's physical etiquette Yueqing City training results assessment successfully concluded

How to add a "security lock" to the mobile office of government and enterprises?
随机推荐
keda 2.7.1 scaledJob 代码简要分析
readv & writev
regular expression
About vs scanf, 'scanf' appears: this function or variable may be unsafe Solutions to the problem of consumer usi
wifi 的理论速度计算方法
关于strlen与sizeof的区别
Dataframe converts the data type of a column
What happens from entering a web address in the browser's input box to seeing the contents of the web page?
俏皮少女王艺璇 受邀担任第六季完美童模全球总决赛推广大使
shell学习记录(二)
shell学习记录(一)
wifi 相关知识详解
Abnova actn4 DNA probe solution
清甜女孩李斯霞 受邀担任第六季完美童模全球总决赛小主持人
螺旋矩阵
Multi type study of Worthington collagen protease
论文阅读 Exploring Temporal Information for Dynamic Network Embedding
PTA class a simulated sixth bomb: 1156-1159
Dataframe extracts data from a column and converts it into a list
Abnova CSV monoclonal antibody solution