当前位置:网站首页>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);
}
边栏推荐
- Wanglaoji pharmaceutical's public welfare activity of "caring for the most lovely people under the scorching sun" was launched in Hangzhou
- Disruptor(一)Sequence
- A lost note for konjaku beginner
- LeetCode 41 ~ 50
- How to efficiently complete daily tasks?
- recvmsg & sendmsg
- Pre ++, post ++ and pre -- and post -- (+a, a++ and --a, a--)
- 轻轻松松理解指针
- Cs144 environment configuration
- NDK20b FFmpeg4.2.2 编译和集成
猜你喜欢
recvmsg & sendmsg
readv & writev
One stop solution EMQ for hundreds of millions of communication of Internet of things
Pointnet/Pointnet++学习
物联网亿万级通信一站式解决方案EMQ
Mot - clé C facile à comprendre statique
初识Opengl
-- EGFR FISH probe solution
Dataframe extracts data from a column and converts it into a list
Abnova actn4 DNA probe solution
随机推荐
17.11 std::atomic续谈、std::async深入谈
CS144 环境配置
如何制定可实现中长期目标?
How to set achievable medium - and long-term goals?
Computer shortcut keys commonly used by experts
Pixel6 unlock bootloader
Detailed explanation of WiFi related knowledge
字节序问题
初识Opengl
影响个人成长的三个因素
Gun make (5) variables in makefile
求n的乘阶
Wanglaoji pharmaceutical's public welfare activity of "caring for the most lovely people under the scorching sun" was launched in Hangzhou
如何使用命令将文件夹中的文件名(包括路径)写入到txt文件中
Dazhou suggested that we media bloggers do these four things in the early stage
如何制定一个可实现的年度目标?
PTA class a simulated fifth bomb: 1148-1151
V4L2+QT视频优化策略
Find the multiplication order of n
Finding the sum of N multiplications