采用大恒MER系列工业摄像机,不能用opencv自带函数打开摄像头,需要用厂商提供的API
工业摄像头采集的图片格式为BYTE,opencv需要从内存中读取BYTE,转化成IplImage *(in C) 或者Mat( in c++)
#include "stdafx.h"
#include "camera.h"
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace cv;
GX_DEV_HANDLE hDevice = NULL;
static int keycode;
MERCamera::MERCamera()
{
GX_STATUS status = GX_STATUS_SUCCESS;
int64_t nValue = 0;
GXInitLib();
status = GXOpenDeviceByIndex(1, &hDevice);
if(status != GX_STATUS_SUCCESS)
{
std::cout<<"open error"<<std::endl;
return;
}
}
MERCamera::~MERCamera()
{
GX_STATUS emStatus = GX_STATUS_SUCCESS;
if(m_bIsSnaping)
{
EndContinuesMode();
}
emStatus = GXCloseDevice(hDevice);
if(emStatus !=