当前位置:网站首页>Weishi camera display
Weishi camera display
2022-06-26 02:02:00 【ooolmf】
void MVCamra::showCam()
{
//if (r == MVST_SUCCESS) return;
MVSTATUS_CODES r;
r = MVInitLib();
if (r != MVST_SUCCESS)
{
::MessageBox(NULL, _T(" initialization failed "), _T(" error "), MB_OK);
return;
/*cout << " initialization failed " << " reason :" << MB_ICONWARNING << endl;*/
}
// Find the number of cameras connected to the computer
int numberofCams = 0;
MVGetNumOfCameras(&numberofCams);
//cout << numberofCams << endl;
if (numberofCams == 0)
{
::MessageBox(NULL, _T(" No camera found ! "), _T(" error "), MB_OK);
return;
}
else
{
//MessageBox(NULL, _T(" Discover camera ! "), _T(" correct "), MB_OK);
}
cam.hCam = NULL;
MVOpenCamByIndex(0, &cam.hCam);// Turn on camera , Return camera handle
if (cam.hCam != NULL)
{
/*cout << " The camera has been turned on !" << endl;*/
}
// Format image pixels
cam.pixelformat = PixelFormat_BayerRG8;
MVSetPixelFormat(cam.hCam, cam.pixelformat);
// Set the current frame rate
double fps = 40;
MVSetFrameRate(cam.hCam, fps);
// Set exposure time
MVSetAutoExposureTimeLowerLimit(cam.hCam, 10);
MVSetAutoExposureTimeUpperLimit(cam.hCam, 300000);
// Set the desired brightness
MVSetAutoTargetValue(cam.hCam, 128);
// Set the brightness tolerance
MVSetAutoThreshold(cam.hCam, 0.3);
// Set the trigger mode
MVSetTriggerMode(cam.hCam, TriggerMode_Off);
// Set and obtain image width and height
int ww = 1600, hh = 1200;
MVSetWidth(cam.hCam, ww);
MVSetHeight(cam.hCam, hh);
MVGetWidth(cam.hCam, &ww);
MVGetHeight(cam.hCam, &hh);
// Get image format
MVGetPixelFormat(cam.hCam, &cam.pixelformat);
cam.mvimage.CreateByPixelFormat(ww, hh, cam.pixelformat);
//MVSetExposureTime(cam.hCam, 24000);
while (1)
{
// The camera starts working to capture the video stream ( The transmission rate is too fast There will be frame loss No performance impact )
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));
}
// Turn off video streaming
MVStopGrab(cam.hCam);
// Turn off camera
MVCloseCam(cam.hCam);
}
边栏推荐
- shell学习记录(四)
- 【无标题】vsbiji esp....32
- cyclegan:unpaired image-to-image translation using cycle-consistent adversarial network
- 缓存技术之第一次亲密接触
- jenkins汉化及汉化无效解决方案
- Theoretical speed calculation method of WiFi
- Chinese and English instructions of collagen enzyme Worthington
- Detailed explanation of memory leak check tools
- 输入3个整数,从大到小输出出来
- easyexcel读取文件
猜你喜欢

分布式系统(二)分布式事务的理解

shell学习记录(二)

Dataframe extracts data from a column and converts it into a list

图形渲染管线

Xiaomi tablet 5 Pro unlock bootloader

Principle of voice wake-up

pixel 6 root

What happens from entering a web address in the browser's input box to seeing the contents of the web page?

Chrome浏览器开发者工具使用

物联网亿万级通信一站式解决方案EMQ
随机推荐
It's better to finish one than start thousands of times (reprinted from Douban)
CS144 环境配置
螺旋矩阵
宁要一个完成,不要千万个开始(转载自豆瓣)
Redis-SDS
如何制定可实现中长期目标?
Distributed systems (II) understanding of distributed transactions
tos cos dscp 区别和作用
关于strlen与sizeof的区别
recv & send
cv==biaoding---open----cv001
接口测试用例设计
Xiaomi tablet 5 Pro unlock bootloader
Theoretical speed calculation method of WiFi
轻轻松松理解指针
pixel 6 root
Steps of program compilation precompile compilation assembly connection
Mot - clé C facile à comprendre statique
Redis-链表
Dazhou suggested that we media bloggers do these four things in the early stage